How DHT11 and DHT22 Sensors Work With Arduino - Electronic and Telecommunication Engineering

Post Top Ad

Responsive Ads Here

How DHT11 and DHT22 Sensors Work With Arduino

Share This

DHT11 Vs DHT22/AM2302

       The DHT22 is the more high priced model which manifestly has better specs. Its temperature measuring variety is from -40°C to +one hundred twenty 5°C with +-zero.Five levels accuracy, on the equal time as the DHT11 temperature range is from 0°C to 50°C with +-2 ranges accuracy. Also the DHT22 sensor has higher humidity measuring variety, from 0 to a hundred% with 2-five% accuracy, even as the DHT11 humidity variety is from 20 to 80% with 5% accuracy.






Though DHT22 is more precise, extra correct and works in a bigger sort of temperature & humidity; there are three matters where the DHT11 beats the hell out of DHT22. It’s much less steeply-priced, smaller in period and has higher sampling charge. The sampling price of the DHT11 is 1Hz i.E. One studying each 2nd, even as the sampling rate of DHT22 is zero.5Hz i.E. One analyzing every  seconds.

However, the running voltage of every sensors is from three to 5 volts, on the identical time because the max modern-day used in some unspecified time in the future of conversion (at the same time as soliciting for statistics) is two.5mA. And the best element is that DHT11 and DHT22 sensors are ‘swappable’ – meaning, in case you build your mission with one you can definitely unplug it and use some other. Your code also can have to alter a hint however as a minimum the wiring is the identical!

Hardware Overview

The casing is in  additives that allows you to get indoors it is super a depend amount of having a pointy knife and splitting the case aside. Inside the case, on the sensing element, there can be a humidity sensing hassle collectively with a NTC temperature sensor (or thermistor)





   Humidity sensing detail is used, of course to diploma humidity, which has  electrodes with moisture preserving substrate (usually a salt or conductive plastic polymer) sandwiched among them. The ions are released with the aid of manner of way of the substrate as water vapor is absorbed via it, which in turn will boom the conductivity the numerous electrodes. The exchange in resistance a number of the  electrodes is proportional to the relative humidity. Higher relative humidity decreases the resistance the numerous electrodes, at the same time as decrease relative humidity will growth the resistance among the electrodes.





Besides, they embody a NTC temperature sensor/Thermistor to diploma temperature.. Technically, all resistors are thermistors – their resistance modifications barely with temperature – but the exchange is usually very very small and tough to diploma.

Thermistors are made genuinely so the resistance changes notably with temperature without a doubt so it is able to be 100 ohms or more of trade steady with diploma! The time period “NTC” technique “Negative Temperature Coefficient”, which means that that that the resistance decreases with boom of the temperature.






On the possibility trouble, there is a small PCB with an 8-bit SOIC-14 packaged IC. This IC measures and strategies the analog sign with stored calibration coefficients, does analog to digital conversion and spits out a digital signal with the temperature and humidity.


DHT11 and DHT22 Pinout

 DHT11 and DHT22 sensors are fairly smooth to attach. They have 4 pins:







  • VCC pin elements power for the sensor. Although deliver voltage tiers from 3.3V to 5.5V, 5V supply is usually recommended. In case of 5V strength deliver, you can maintain the sensor as long as 20 meters. However, with 3.3V deliver voltage, cable duration shall not be greater than 1 meter. Otherwise, the road voltage drop will motive mistakes in measurement.
  • Data pin is used to conversation a number of the sensor and the microcontroller.
  • NC Not associated
  • GND have to be related to the floor of Arduino.

Connecting DHT11 and DHT22 to Arduino UNO

        They have quite lengthy zero.1″-pitch pins so that you can with out issues plug them into any breadboard. Power the sensor with 5V and connect floor to ground. Finally, join the Data pin to a digital pin #2.

        We moreover want to area a pull-up resistor of 10KΩ among VCC and records line to preserve it HIGH for proper communique amongst sensor and MCU. If you show as much as have a breakout board of the sensor, you want not upload any out of doors pull-up. It comes with a integrated pull-up resistor.




Arduino Code  and Printing values on Serial Monitor

The DHT11 and DHT22 sensors have their very own unmarried twine protocol used for moving the records. This protocol calls for unique timing. Fortunately, we don’t should fear a great deal approximately this because we are going to use the DHT library which takes care of virtually the whole lot.

Download the library first, with the aid of touring the GitHub





Once you have got the library hooked up, you can replica this comic strip into the Arduino IDE. The following check cartoon will print the temperature and relative humidity values on the serial display. Try the sketch out; and then we will provide an explanation for it in some detail.




#encompass <dht.H>
#outline dataPin eight // Defines pin quantity to which the sensor is attached
dht DHT; // Creats a DHT item

void setup() 

  Serial.Begin(9600);

void loop() 

  //Uncomment something type you're the use of!
  Int readData = DHT.Read22(dataPin); // DHT22/AM2302
  //int readData = DHT.Read11(dataPin); // DHT11

  waft t = DHT.Temperature; // Gets the values of the temperature
  waft h = DHT.Humidity; // Gets the values of the humidity

  // Printing the effects at the serial display
  Serial.Print("Temperature = ");
  Serial.Print(t);
  Serial.Print(" ");
  Serial.Print((char)176);//suggests levels character
  Serial.Print("C nine.Zero) / five.Zero + 32.Zero);//print the temperature in Fahrenheit
  Serial.Print(" ");
  Serial.Print((char)176);//shows tiers person
  Serial.Println("F ");
  Serial.Print("Humidity = ");
  Serial.Print(h);
  Serial.Println(" % ");
  Serial.Println("");

  postpone(2000); // Delays 2 secods



1 comment:

Post Bottom Ad

Responsive Ads Here

Pages