Hardware and software requirements
We have already discussed most of the requirements for this project in the first chapter of this book. Here, you will simply need an additional component: a DHT11 sensor (https://www.adafruit.com/products/386). The following image shows the sensor:
You can of course use other similar sensors, for example the DHT22, which is more precise. To use a DHT22, you will only need to change one thing inside the code we'll see later.
You will also need a 4.7k Ohm resistor to make the sensor work, as well as jumper wires and a breadboard.
Hardware configuration
Let's now look at how to configure the hardware for this project; basically, how to connect the sensor to the Pi Zero board.
The following figure is a schematic to help you out:
As it's the first project we are actually building using the Raspberry Pi Zero, there is something important I wanted to point out here. To connect the board to components like this sensor here, we have two options. You can either use jumper wires directly (as shown on the schematic), or use a cobbler kit to connect all the pins of the Pi to the breadboard, as shown in the following image:
This is up to you, and to be clear, I'll always show only the individual wires on the schematics, but use a cobbler kit to actually build the projects.
Here, you simply need to place the DHT11 on the breadboard, and then connect the resistor between the VCC and the data pins. Then, connect the VCC to the 3.3V pin of the Raspberry Pi, GND to GND, and finally, connect the data pin of the sensor to pin 4 of the Raspberry Pi board.
Software configuration
Now we are going to install additional software on your Pi to make sure we can read data from the sensor.
Following the instructions from Chapter 1, Configuring Your Raspberry Pi Zero Board log into your Pi via SSH, or just use it with an external screen with mouse and keyboard.
- Inside a terminal, type the following:
wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.50.tar.gz
- Wait for the download to complete and then type the following:
tar zxvf bcm2835-1.50.tar.gz
- Next, type the following:
cd bcm2835-1.50
- Now, configure the software you just downloaded with the following:
./configure
- Build this software with the following:
make
- Now, verify that everything is okay with the following:
sudo make check
- If there are no errors, you can then install the software on your Pi with the following:
sudo make install
After that last step, you can now move on to the projects of this chapter!