Pages

Sunday, July 3, 2022

Arduino Uno Temperature and Humidity Reading with DHT-11 Sensor

DHT-11 is a temperature and humidity sensor module. It use a serial data transmission between the module and the controller. It has the following features:

  • Operating Voltage: 3.5V to 5.5V
  • Operating current: 0.3mA (measuring) 60uA (standby)
  • Output: Serial data
  • Temperature Range: 0°C to 50°C
  • Humidity Range: 20% to 90%
  • Resolution: Temperature and Humidity both are 16-bit
  • Accuracy: ±1°C and ±1%

Arduino Uno Temperature and Humidity Reading with DHT-11 Sensor
A simple DHT-11 Sensor
It's suitable for in-house temperature controlling, or the irrigation system. This module is very popular to apply with the Arduino. The DATA pin of this module is the serial data I/O pin. It requires an additional pull up resistor, typically a 5kOhm resistor.

Arduino Uno Temperature and Humidity Reading with DHT-11 Sensor
Typical connection
In this example, the Arduino Uno will read the environmental data from this module, and it will show on a character display. The LCD I use here is a 16x2 character LCD. I use an additional PCF8574T I2C to parallel I/O to the LCD.

Arduino Uno Temperature and Humidity Reading with DHT-11 Sensor
Arduino running program

The pull up resistor I used here is 10kOhm.

  1. //Two-Wire library
  2. #include <Wire.h>
  3. #include <LiquidCrystal_I2C.h>
  4. //DHT-11 Sensor Library
  5. #include <SimpleDHT.h>
  6.  
  7. //Default address 0x27, LCD is 16x4
  8. LiquidCrystal_I2C lcd(0x27,16,4);
  9.  
  10. //DHT-11 connects to pin A0
  11. SimpleDHT11 dht11(A0);
  12.  
  13. void setup(){
  14. //Initialize the LCD
  15. lcd.init();
  16. //Turn on the backlight
  17. lcd.backlight();
  18.  
  19. //show some information
  20. lcd.print("BTE Technician");
  21. lcd.setCursor(0,1);
  22. lcd.print("Arduino Uno And");
  23. lcd.setCursor(-4,2);
  24. lcd.print("DHT-11 Sensor");
  25. lcd.setCursor(-4,3);
  26. lcd.print("LCD Example");
  27. delay(3000);
  28. lcd.clear();
  29. }
  30.  
  31. byte temperature,humidity;
  32.  
  33. void loop(){
  34. //Get temperature, humidity, and no raw data
  35. dht11.read(&temperature,&humidity,NULL);
  36.  
  37. lcd.setCursor(0,0);
  38. lcd.print("Temperature:");
  39.  
  40. lcd.setCursor(3,1);
  41. lcd.print(String(temperature,DEC)+" "+char(223)+"C");
  42.  
  43. lcd.setCursor(-4,2);
  44. lcd.print("Humidity:");
  45.  
  46. lcd.setCursor(-1,3);
  47. lcd.print(String(humidity,DEC)+" %RH");
  48. delay(3000);
  49. }

Its wiring diagram is shown below.

Arduino Uno Temperature and Humidity Reading with DHT-11 Sensor
Wiring diagram

Click here to download its source file.

No comments:

Post a Comment