In this article I show you how to connect and configure the temperature and humidity sensor DHT22 or DHT11 to HoneyPi. But first I will talk about the differences between DHT22 and DHT11.
DHT22 vs. DHT11
The following data table shows that the DHT22 (white) is more accurate than the DHT11 (blue). The temperature range of the DHT22 is -40 to 125°C, with an accuracy of ± 0.5°C. The temperature range of the DHT11 is only from 0 to 50 °C with an accuracy of ± 2 °C. The temperature range of the DHT22 is from -40 to 125 °C, with an accuracy of ± 2 °C. This means that it does not go into the negative temperature range, which can be a disadvantage on cold winter days at the hives. The humidity range of the DHT22 measures the full range (0 to 100 %), while the DHT11 can only measure 20 to 80 % humidity.
We recommend to use the DHT22 for HoneyPi, because it can also measure negative temperature values. In addition, it is more accurate than the DHT11, which is why it costs a little more than the DHT11, but is still very cheap. Here you can buy the DHT22?.
|Temperature range||-40 –125 °C||0 – 50 °C|
|Temperature accuracy||± 0,5 °C||± 2 °C|
|Humidity range||0 – 100 %||20 – 80 %|
|Humidity accuracy||± 2 – 5 %||± 5 %|
|Dimensions||15,1 mm x 25 mm x 7,7 mm||15,5 mm x 12 mm x 5,5 mm|
|Operating voltage||3 – 5 V||3 – 5 V|
|Current||2,5 mA||2,5 mA|
Structure of the DHT22/DHT11
The functions of the pins of the two sensors are identical. Pin 1 in the following figure supplies the sensor with current (3 – 5 V). Pin 2 transmits the measurement data. The third pin does not have to be connected. And the fourth pin provides grounding.
1 = VCC (3 – 5 V)
2 = Daten
3 = no connection
4 = Ground
Attaching components to the Raspberry Pi
The DHT22 or DHT11 is connected to the Raspberry Pi Zero W (or Raspberry Pi 3B/B+) as follows. I also connected a button ? (square on the right side of the breadboard) to switch the maintenance mode on and off and to configure the sensor.
Neben dem Sensor selbst und ein paar Kabel, benötigt ihr einen Pull-Up-Widerstand mit 4,7 kΩ – 10 kΩ. Diesen könnt ihr hier kaufen ?. Leider kann man Widerstände nur in großen Mengen online kaufen. Falls ihr nur wenige Widerstände benötigt, könnt ihr diese natürlich auch im Elektrohandel kaufen oder als Bundle mit anderen Bauteilen ?.
Besides the sensor itself and a few cables, you need a pull-up resistor with 4.7 kΩ – 10 kΩ. You can buy it here ?. Unfortunately you can only buy resistors in large quantities online. If you only need a few resistors, you can also buy them in electrical stores or as a bundle with other components ?.
Attention: The DHT sensors do not support the 1-Wire interface. Multiple sensors cannot be connected to the same pin (such as the DS18B20). Each DHT sensor needs its own data pin.
The following figure shows how to solder one end of the resistor to pin 1 (VCC) of the sensor and the other end to pin 2 (data) together with the corresponding cables.
Configuring the Sensor in Maintenance Mode
After you have flashed the firmware onto the MicroSD card and powered the Raspberry Pi, wait about 90 seconds until the Raspberry Pi is powered up. Then you can press the connected button ? to start the maintenance mode. You should now see the network HoneyPi among the available networks of your PC or Smartphone. The default password is: HoneyPi!
If you are connected to the HoneyPi network, you can go to the configuration page in your browser at http://192.168.4.1/ and click on “Configure”. If you haven’t done so yet, you will need to enter your Channel ID and Write API key under “ThingSpeak Settings”.
You can find this data in your ThingSpeak account under your channel in the “API Keys” tab. If you haven’t created a ThingSpeak account or channel yet, you can follow these instructions.
Under “Connected Sensors” click on “Add Sensor” and then select the DHT11/DHT22. Below you can select the ThingSpeak fields for temperature and humidity and enter the GPIO number (not pin number) to which you have connected the sensor’s data pin. Finally click on “Save” in the upper right corner.
Now your DHT11 or DHT22 should be correctly connected and configured to your HoneyPi 🙂
Translated 11.08.2019 by JK