User Tools

Site Tools


amc2020:group_n:dht22

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
amc2020:group_n:dht22 [2020/07/28 20:43] – [3. Technical Specifications and Setup of the Sensor] jonas001amc2020:group_n:dht22 [2021/08/24 17:35] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +<html>
 +  <left>
 +    <a href="https://wiki.eolab.de/doku.php?id=amc2020:group_n:start"; onmouseover="style.color='green'";>
 +      <span style="color:#2E71B8"; onmouseover="style.color='green'"; onmouseout="style.color='#2E71B8'";>
 +        &#8617 Back to the main page
 +      </span>
 +    </a>
 +  </left>
 +</html>
 +
 ====== DHT-22 Air Temperature and Humidity Sensor ====== ====== DHT-22 Air Temperature and Humidity Sensor ======
  
Line 81: Line 91:
 ===== 3. Technical Specifications and Setup of the Sensor ===== ===== 3. Technical Specifications and Setup of the Sensor =====
  
-The DHT-22 comes with 4 pins and can be plugged into a breadboard. Pin 1 (VDD) is connected to the power supply, pin 2 (DATA) is the 1-wire data-bus and is connected to GPIO 15, pin 3 (NC) is not connected, and pin 4 (GND) is connected to 0 Volts (figure . Information on the technical specifications can be found in table 1.+The DHT-22 comes with 4 pins and can be plugged into a breadboard. Pin 1 (VDD) is connected to the power supply, pin 2 (DATA) is the 1-wire data-bus and is connected to GPIO 15, pin 3 (NC) is not connected, and pin 4 (GND) is connected to 0 Volts (figure 3). Information on the technical specifications can be found in table 1.
  
 ^**//Table 1//** Technical specifications, sensor accuracy and ranges^^^ ^**//Table 1//** Technical specifications, sensor accuracy and ranges^^^
Line 95: Line 105:
 | Repeatability             | $\pm$ 1 % RH                       | $\pm$ 0.2 °C       | | Repeatability             | $\pm$ 1 % RH                       | $\pm$ 0.2 °C       |
 The specifications are also available in the {{https://cdn-shop.adafruit.com/datasheets/Digital+humidity+and+temperature+sensor+AM2302.pdf| AM2302 Datasheet}}. The specifications are also available in the {{https://cdn-shop.adafruit.com/datasheets/Digital+humidity+and+temperature+sensor+AM2302.pdf| AM2302 Datasheet}}.
 +
 +^{{:amc2020:group_n:esp32_dht22.png?direct&300|Figure 3}}^
 +|**//Figure 3//** Connection of ESP32 and DHT-22.|
  
 ==== 3.1 Pullup Resistors ==== ==== 3.1 Pullup Resistors ====
Line 104: Line 117:
 $$R_{max}=\left(\frac{1}{80000\Omega}+\frac{1}{4700\Omega}\right)^{-1}=4439.2\Omega$$ $$R_{max}=\left(\frac{1}{80000\Omega}+\frac{1}{4700\Omega}\right)^{-1}=4439.2\Omega$$
  
-When the sensor data pin and the GPIO of the ESP32 are connected through a longer cable (>50cm), it is advisable to use another external pullup-resistor. This is due to the fact that the wire acts as a capacitor, and the longer the wire is, the larger the capacitance. After a 0V pulse, the wire-capacitor has to be charged again before the data-bus reaches the full 3.3V potential. That means, instead of having a clean pronounced voltage signal, which can be interpreted as a 0 or 1, the signal looks like the charging curve of a capacitor (see figure 3). The longer the cable, the larger the capacitance resulting in a longer charging time and a less pronounced signal, which may lead to errors in the communication. Adding another external pullup resistor, for example a 10kΩ resistor, decreases the total pullup-resistance, because the resistors are connected in parallel. The new minimum and maximum resistances are thus:+When the sensor data pin and the GPIO of the ESP32 are connected through a longer cable (>50cm), it is advisable to use another external pullup-resistor. This is due to the fact that the wire acts as a capacitor, and the longer the wire is, the larger the capacitance. After a 0V pulse, the wire-capacitor has to be charged again before the data-bus reaches the full 3.3V potential. That means, instead of having a clean pronounced voltage signal, which can be interpreted as a 0 or 1, the signal looks like the charging curve of a capacitor (see figure 4). The longer the cable, the larger the capacitance resulting in a longer charging time and a less pronounced signal, which may lead to errors in the communication. Adding another external pullup resistor, for example a 10kΩ resistor, decreases the total pullup-resistance, because the resistors are connected in parallel. The new minimum and maximum resistances are thus:
  
 $$R'_{min}=\left(\frac{1}{30000\Omega}+\frac{1}{4700\Omega}+\frac{1}{10000\Omega}\right)^{-1}=2889.3\Omega$$ $$R'_{min}=\left(\frac{1}{30000\Omega}+\frac{1}{4700\Omega}+\frac{1}{10000\Omega}\right)^{-1}=2889.3\Omega$$
Line 110: Line 123:
 $$R'_{max}=\left(\frac{1}{80000\Omega}+\frac{1}{4700\Omega}+\frac{1}{10000\Omega}\right)^{-1}=3074.4\Omega$$ $$R'_{max}=\left(\frac{1}{80000\Omega}+\frac{1}{4700\Omega}+\frac{1}{10000\Omega}\right)^{-1}=3074.4\Omega$$
  
-As the total pullup resistance decreases, the current increases and the wire-capacitor is charged faster (that means 3.3V on the data-bus is reached faster as well), which steepens the charging curve of the capacitor and thus makes the signal more “square”, so it is more pronounced and leads to less errors during communication between MCU and DHT-22. This effect is demonstrated in figure and also occurs for other wire-connected bus-systems like I²C.+As the total pullup resistance decreases, the current increases and the wire-capacitor is charged faster (that means 3.3V on the data-bus is reached faster as well), which steepens the charging curve of the capacitor and thus makes the signal more “square”, so it is more pronounced and leads to less errors during communication between MCU and DHT-22. This effect is demonstrated in figure and also occurs for other wire-connected bus-systems like I²C.
  
-^{{:amc2020:group_n:dht-22_signal_pullup_resistance.png?direct&800| Figure 3}}^ +^{{:amc2020:group_n:dht-22_signal_pullup_resistance.png?direct&800| Figure 4}}^ 
-|**//Figure 3//** Schematic of how different pullup resistances affect the voltage-time-curve of high voltage level pulses when the wire length is high.|+|**//Figure 4//** Schematic of how different pullup resistances affect the voltage-time-curve of high voltage level pulses when the wire length is high.|
  
 ==== 3.2 Other Issues and Problems that occurred ==== ==== 3.2 Other Issues and Problems that occurred ====
Line 129: Line 142:
 === 3.2.3 Upload-issues using the ESP32 DevkitC VB === === 3.2.3 Upload-issues using the ESP32 DevkitC VB ===
  
-When using the ESP32 instead of an Arduino, the Arduino IDE can give a time out error (figure 4) during the upload if the DHT-22 is already connected to the ESP32:+When using the ESP32 instead of an Arduino, the Arduino IDE can give a time out error (figure 5) during the upload if the DHT-22 is already connected to the ESP32:
  
-^{{:amc2020:group_n:upload_error_message.png?direct&800| Figure 4}}^ +^{{:amc2020:group_n:upload_error_message.png?direct&800| Figure 5}}^ 
-|**//Figure 4//** Time out error during upload of code to the ESP32 DevkitC VB with the DHT-22 connected to it.|+|**//Figure 5//** Time out error during upload of code to the ESP32 DevkitC VB with the DHT-22 connected to it.|
  
 This seems to be an issue caused by the power supply to the DHT-22 during the upload process. Other users reported to have fixed the problem by This seems to be an issue caused by the power supply to the DHT-22 during the upload process. Other users reported to have fixed the problem by
Line 283: Line 296:
  
 Between the printing of the results (line 3, 4, 5) and the start of the next measurement process (line 6) a time difference of 2.04 seconds could be observed. 2 seconds are due to the delay in the main loop (code section 10), the rest is due to the print() functions which consume comparably much time.  Between the printing of the results (line 3, 4, 5) and the start of the next measurement process (line 6) a time difference of 2.04 seconds could be observed. 2 seconds are due to the delay in the main loop (code section 10), the rest is due to the print() functions which consume comparably much time. 
 +
 +<html>
 +  <center>
 +    <span>
 +    <a href="javascript:self.scrollTo(0,0)"; onmouseover="style.color='green'";>
 +      <span style="color:#2E71B8"; onmouseover="style.color='green'"; onmouseout="style.color='#2E71B8'";>
 +        Back to the top &#10548
 +      </span>
 +    </a>
 +    </span>
 +  </center>
 +</html>
amc2020/group_n/dht22.1595961829.txt.gz · Last modified: 2021/08/24 17:34 (external edit)