Hardware Reference
In-Depth Information
Now you are all ready to let some software access it. Soon you will know just how hot and humid it is! Hong
Kong is always very humid so for me this part may not be very useful. With that in mind it's time to move on to the
software part.
Reading the DHT11 in Linux
With the DHT11 sensor connected, you're going to need a way to read it. You will recall from the start of this chapter
that the DHT11 uses its own digital signaling. To enable you to use this sensor I have included some source code from
the excellent Adafruit web site.
the application comes as source code. You're going to need to compile this on your raspberry pi. You can
download the source code zip file from the apress web site to get the required files, or you can visit http://rpi.horan.hk
to get the source code.
Note
Now that you have the source code unpacked, you will see three files:
A make file
Adafruit_DHT.c
Adafruit_DHT.o
These three files are the source code, an object file, and a make file. Because all the hard work has been done for
you, the main file you care about is the make file. This file tells the make application how to build the Adafruit_DHT.c
source into an application. Go ahead and invoke the make application by running the following command in the
project directory:
# make
You will quickly notice that it won't work:
-bash: /usr/bin/make: No such file or directory
Or something similar will appear. By default the Raspberry Pi Fedora image comes with no development tools.
Go ahead and install make with this command:
# yum install -y make
Now that you have make installed, shouldn't it be fine?
Nope. You are now most likely getting this error:
make: gcc: Command not found
gcc is the tool you use to build c and other programs. Install gcc with this command:
# yum install -y gcc
gcc is quite big so this may be a good time to grab a nice beverage or two (in my case a tin of Tsing Tao).
Once gcc is installed you can type in make again. You will notice once again it has failed, this time with some
cryptic message about the BCM2835 not being found. You can see the full error in Figure 3-22 .
 
 
Search WWH ::




Custom Search