Hardware Reference
In-Depth Information
• It uses three wires, and only one wire for communication! This means that only
three GPIO pins on your Raspberry Pi will be used (and only one general-purpose
pin needs to be reserved).
In fact, the only real downside to using the AM2302 is that it does not (as of the time
of this writing) have a native Linux kernel driver for it. This means that we cannot easily
plug it into the lm_sensors infrastructure, as described in Hack #37 .
Adding the AM2302 to the Linux Kernel
The AM2302 has a DHT22 temperature-humidity sensor at its core. It should be
rather simple for someone with a basic understanding of C and the Linux kernel to
add a hwmon driver for the DHT22. If you're looking for a good starter Linux kernel
development project, this might be it! We hope that one day this note will become
obsolete once someone writes this code, and then this hack becomes much sim-
pler for everyone!
Again, Adafruit comes to the rescue. They provide an open source C program for
reading the temperature and humidity values off the AD2302. We'll get to that in a
moment, but first, you'll want to wire it to your Raspberry Pi. The AD2302 has three
wires coming out of the plastic case:
Red
For 3.3 V power
Black
For Ground (GND)
Yellow
Where the data comes out
Technically, you can connect any of the generic I/O pins on the GPIO header and it will
work, but we know you're going to ask us to tell you which pin to use … so just go ahead
and connect the yellow data wire to BCM Pin 4 (P1-07). Why? Well, it is the first generic
I/O pin underneath the 3.3 V (the two pins above it are I2C pins).
Connect the red wire to the 3.3V power pin (P1-01) and the black wire to a Ground
(GND) pin. If you aren't sure what all of these GPIO terms mean, check out Hack #14 .
The simplest way to wire these pins to the Raspberry Pi is with a solderless breadboard
and a Pi Cobbler ( Hack #15 ). The wires coming from the AD2302 are a little too thin to
insert into the breadboard, so you'll probably want to connect them directly to some
thicker wire first. There are a number of ways to do this:
• Solder the wire to a thicker wire.
 
Search WWH ::




Custom Search