Difference between revisions of "Sensors: DHT22"

From HiveTool
Jump to: navigation, search
(Spec Sheets)
(Test Results)
 
(13 intermediate revisions by the same user not shown)
Line 1: Line 1:
DHT22 and AS2302
+
[[File:Dht22 wiring1.jpg|thumb|right|500px|Left: DHT22 from Adafruit mounted on PCB with pull up and bypass capacitor.<br>Right: Bare sensor from EBay without pull up or bypass.]]
 +
[[File:Wired dht22c.jpg|thumb|right|500px|Wired DHT22 '''WARNING''' DHT22 wire colors do not match telephone wire colors. Red: +5, Black: Ground, Yellow: Signal]]
 +
 
 +
The AM2302 (DHT22) is a 3 wire (Vcc, data, gnd) temperature and humidity sensor manufactured by Aosong.
  
 
==Spec Sheets==
 
==Spec Sheets==
[[Media:AM2302.pdf|AM2302 spec sheet]]
+
[[Media:AM2302.pdf|AM2302 spec sheet]]<br>
 
[[Media:AM2302b.pdf|New AM2302/DHT22 spec sheet]]
 
[[Media:AM2302b.pdf|New AM2302/DHT22 spec sheet]]
 +
 +
==Test Results==
 +
http://www.kandrsmith.org/RJS/Misc/hygrometers.html
  
 
==Pull Up Resistor==
 
==Pull Up Resistor==
  
If everything is working fine, don't touch it. Just keep the r and c in mind should you start having trouble.
+
The Adafruit module (left) includes a 5.1K pull up resistor and a bypass capacitor.
 
   
 
   
The Pi does have internal pull ups that are turned on. I'm going by this article:
+
The Pi does have internal pull ups that are turned on. They are about 50K. Our tests on 3 meter cables did not show any significant difference in performance or read errors whether or not the 5.1K pull up or bypass capacitor was used.  However, good engineering practices would use the pull up and bypass cap.
http://www.mosaic-industries.com/embedded-systems/microcontroller-projects/raspberry-pi/gpio-pin-electrical-specifications
 
 
   
 
   
See figure one for a schematic.
+
The new DHT22 spec sheet shows the pull up value as 1K in Figure 5.
 +
The old spec sheet said: "single bus usually require an external about 5.1kΩ pull-up resistor."
 +
 
 +
==Read Time==
 +
 
 +
You must wait at least 2 seconds before reading again or you will get a bad read (the checksum will fail).
 
   
 
   
They say
+
The new spec sheet: "the interval of whole process must beyond 2 seconds."
While a pull-up/down resistor value of 50 KΩ is shown in the figure, Broadcom doesn't specify its value. It is likely to be in the 40 to 100 KΩ range, as shown in Table 1. The transistors that enable the pull-up/down resistor contribute their appreciable nonlinear resistance to it, so the effective resistance is not constant over the input pin voltage range. The pull-up behavior is somewhat of a cross between constant resistance and constant current behavior.  
 
 
   
 
   
If you are trying to rapidly shove bits over a long wire, 50K is pretty high if the device is open collector.
+
The old spec sheet:
 
The DHT22 spec sheet doesn't show the output circuit.  The latest translation is here
 
 
https://www.adafruit.com/datasheets/Digital%20humidity%20and%20temperature%20sensor%20AM2302.pdf
 
 
They don't discus the value of the pull up, but show it as 1K in Figure 5.
 
The old spec sheet said:
 
"single bus usually require an external about 5.1kΩ pull-up resistor."
 
Guess that is where Adafruit got the 5.1K they use.
 
 
Ideally I think that the resistor should be located on the board and the capacitor at the DHT22.  I've been doing my testing with the r and c at the DHT22.
 
 
I've played with different timing in the code.  Emil is right that the longer between reads, the fewer bad reads. That is strange.
 
 
The spec sheet does say: "the interval of whole process must beyond 2 seconds."
 
 
The old spec sheet said:
 
 
   
 
   
 
3.Read the sensor minimum time interval for the 2S; read interval is less than 2S, may cause the temperature and humidity are not allowed or communication is unsuccessful, etc..
 
3.Read the sensor minimum time interval for the 2S; read interval is less than 2S, may cause the temperature and humidity are not allowed or communication is unsuccessful, etc..
 
4.Temperature and humidity values are each read out the results of the last measurement For real-time data that need continuous read twice, we recommend repeatedly to read sensors, and each read sensor interval is greater than 2 seconds to obtain accurate data.
 
4.Temperature and humidity values are each read out the results of the last measurement For real-time data that need continuous read twice, we recommend repeatedly to read sensors, and each read sensor interval is greater than 2 seconds to obtain accurate data.
+
 
What is weird, it seems you need a delay before you read each sensor:
+
WARNINGThe spec sheet refers to this a a "1-wire" device. This is not a [https://en.wikipedia.org/wiki/1-Wire 1-Wire] bus trademarked by Dallas Semiconductor CorpThe later spec sheet has a disclaimer.
   
 
delay 5
 
read DHT22-1
 
delay 5
 
read DHT22-2
 
   
 
works better than
 
delay 5
 
read DHT22-1
 
read DHT22-2
 
 
or
 
delay 10
 
read DHT22-1
 
read DHT22-2
 
 
even though DHT22-1 and DHT22-2 use different GPIO pinsWeird.  They only thing they share is the 3.3 volt power supply.
 

Latest revision as of 03:19, 27 August 2018

Left: DHT22 from Adafruit mounted on PCB with pull up and bypass capacitor.
Right: Bare sensor from EBay without pull up or bypass.
Wired DHT22 WARNING DHT22 wire colors do not match telephone wire colors. Red: +5, Black: Ground, Yellow: Signal

The AM2302 (DHT22) is a 3 wire (Vcc, data, gnd) temperature and humidity sensor manufactured by Aosong.

Spec Sheets

AM2302 spec sheet
New AM2302/DHT22 spec sheet

Test Results

http://www.kandrsmith.org/RJS/Misc/hygrometers.html

Pull Up Resistor

The Adafruit module (left) includes a 5.1K pull up resistor and a bypass capacitor.

The Pi does have internal pull ups that are turned on. They are about 50K. Our tests on 3 meter cables did not show any significant difference in performance or read errors whether or not the 5.1K pull up or bypass capacitor was used. However, good engineering practices would use the pull up and bypass cap.

The new DHT22 spec sheet shows the pull up value as 1K in Figure 5. The old spec sheet said: "single bus usually require an external about 5.1kΩ pull-up resistor."

Read Time

You must wait at least 2 seconds before reading again or you will get a bad read (the checksum will fail).

The new spec sheet: "the interval of whole process must beyond 2 seconds."

The old spec sheet:

3.Read the sensor minimum time interval for the 2S; read interval is less than 2S, may cause the temperature and humidity are not allowed or communication is unsuccessful, etc.. 4.Temperature and humidity values are each read out the results of the last measurement For real-time data that need continuous read twice, we recommend repeatedly to read sensors, and each read sensor interval is greater than 2 seconds to obtain accurate data.

WARNING: The spec sheet refers to this a a "1-wire" device. This is not a 1-Wire bus trademarked by Dallas Semiconductor Corp. The later spec sheet has a disclaimer.