Hardware Reference
In-Depth Information
An Embedded Network Client Application
Now that you've made your first server, it's time to make a client. This project is an
embedded web scraper . It takes data from an existing website and uses it to affect
a physical output. It's conceptually similar to devices made by Ambient Devices,
Nabaztag, and others—but it's all yours.
Project 7
Networked Air-
Quality Meter
MATERIALS
In this project, you'll make a networked
air-quality meter. You'll need an analog
panel meter, like the kind you find in
speedometers and audio VU meters. I got
mine at a yard sale, but you can often find
them in electronics surplus stores or junk
shops. The model recommended in the
parts list is less picturesque than mine,
but it will do for a placeholder until you
find one you love.
» 1 Arduino Ethernet or
» 1 Arduino Ethernet shield and 1 Arduino
microcontroller module
» 1 Ethernet connection to the Internet
» 1 solderless breadboard
» 1 voltmeter
» 4 LEDs
» 4 220-ohm resistors
Control the Meter Using the Microcontroller
First, you need to generate a changing voltage from the
microcontroller to control the meter. Microcontrollers
can't output analog voltages, but they can generate a
series of very rapid on-and-off pulses that can be filtered
to give an average voltage. The higher the ratio of on-time
to off-time in each pulse, the higher the average voltage.
This technique is called pulse-width modulation (PWM) . In
order for a PWM signal to appear as an analog voltage, the
circuit receiving the pulses has to react much more slowly
than the rate of the pulses. For example, if you pulse-width
modulate an LED, it will seem to be dimming because your
eye can't detect the on-off transitions when they come
faster than about 30 times per second. Analog voltmeters
are very slow to react to changing voltages, so PWM works
well as a way to control these meters. By connecting the
positive terminal of the meter to an output pin of the
microcontroller, and the negative pin to ground, and pulse-
width modulating the output pin, you can easily control the
position of the meter. Figure 4-9 shows the whole circuit
for the project.
Figure 4-8 shows how it works: the microcontroller makes
a network connection to a PHP script through the Ethernet
shield. The PHP script connects to another web page,
reads a number from that page, and sends the number
back to the microcontroller. The microcontroller uses
that number to set the level of the meter. The web page
in question is AIRNow, www.airnow.gov , the U.S. Environ-
mental Protection Agency's site for reporting air quality. It
reports hourly air quality status for many U.S. cities, listed
by ZIP code. When you're done, you can set a meter from
your home or office to see the current air quality in your
city (assuming you live in the U.S.).
Search WWH ::




Custom Search