Table of Contents
In this tutorial we will see how to interface DHT11 sensor with Arduino and then we write DHT11 sensor arduino code.
DHT sensor comes in two models DHT11 and DHT22 here we will use DHT11. For measuring temperature and humidity in digital form we use DHT sensors.
These values are measured in analog form, because all signals in nature present in only analog form but then they are converted into digital form.
COMPONENTS REQUIRED
S.N. | COMPONENT | QUANTITY |
1. | Arduino UNO | 1 |
2. | DHT11 Sensor module | 1 |
3. | Connecting wires | 3 |
CIRCUIT DIAGRAM INTERFACING DHT11 SENSOR WITH ARDUINO
DHT11 TECHNICAL SPECIFICATION
Operating Voltage | 3.3 V to 5V | |
Humidity | Range | 20 – 90 % RH |
Accuracy | ± 5 % RH | |
Temperature | Range | 0 – 50 °C |
Accuracy | ± 2 °C |
DHT11 SENSOR ARDUINO CODE
Click to Download DHT Library file from here
/* Tutorial link: https://pijaeducation.com/arduino/sensor/dht11-sensor-arduino-code/ */ /* To download Library - link: https://pijaeducation.com/download/ */ #include <DHT.h>; #define DHTPIN 2 // data pin we're connected to #define DHTTYPE DHT11 // or DHT 22 (AM2302) DHT dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor //Variable to Store humidity and temperature value float hum, temp; void setup() { Serial.begin(9600); dht.begin(); } void loop() { //Read data and store it to variables hum and temp hum = dht.readHumidity(); temp = dht.readTemperature(); //Delay 2 sec, this is important to maintain that much delay in each reading delay(2000); //Print temp and humidity values to serial monitor Serial.print("Humidity: "); Serial.print(hum); Serial.print(" %, Temp: "); Serial.print(temp); Serial.println(" Celsius"); }
OUTPUT
Once you upload the arduino sketch to your board then you will see these types of values in the Serial Monitor.
READ NEXT
PRESSURE SENSOR WITH ARDUINO