DHT11 sensor with ESP8266/NodeMCU using Arduino IDE
In this tutorial i a telling to you How to use DHT11 sensor with ESP8266/NodeMCU using Arduino IDE. First i am telling to you about DHT11 and DHT22 temperature and humidity sensor and Difference between DHT11 and DHT22.
What is DHT11 and DHT22?
The DHT11 and DH22 are both temperature and humidity sensors, but what’s the difference between the two? Let’s go through the important differences, and how they may affect which one you choose for your next project. These sensors are very basic and slow, but are great for hobbyists who want to do some basic data logging. The DHT sensors are made of two parts, a capacitive humidity sensor and a thermistor. There is also a very basic chip inside that does some analog to digital conversion and spits out a digital signal with the temperature and humidity. The digital signal is fairly easy to read using any microcontroller.
DHT11 vs DHT22
We have two versions of the DHT sensor, they look a bit similar and have the same pinout, but have different characteristics. Here are the specs:
DHT11
- Ultra low cost
- 3 to 5V power and I/O
- 2.5mA max current use during conversion (while requesting data)
- Good for 20-80% humidity readings with 5% accuracy
- Good for 0-50°C temperature readings ±2°C accuracy
- No more than 1 Hz sampling rate (once every second)
- Body size 15.5mm x 12mm x 5.5mm
- 4 pins with 0.1″ spacing
DHT22
- Low cost
- 3 to 5V power and I/O
- 2.5mA max current use during conversion (while requesting data)
- Good for 0-100% humidity readings with 2-5% accuracy
- Good for -40 to 80°C temperature readings ±0.5°C accuracy
- No more than 0.5 Hz sampling rate (once every 2 seconds)
- Body size 15.1mm x 25mm x 7.7mm
- 4 pins with 0.1″ spacing
As you can see, the DHT22 is a little more accurate and good over a slightly larger range. Both use a single digital pin and are ‘sluggish’ in that you can’t query them more than once every second or two.
DHT11 sensor with ESP8266/NodeMCU using Arduino IDE
Make the following connections –
Now You need to two libraries, Download these libraries.
https://drive.google.com/drive/folders/1SYM_B1k3SE0Qkxa3NFsw7W2IyVzNVJhq?usp=sharing
Arduino .ino Code
#include "DHT.h" // including the library of DHT11 temperature and humidity sensor
#define DHTTYPE DHT11 // DHT 11
#define dht_dpin 0
DHT dht(dht_dpin, DHTTYPE);
void setup(void)
{
dht.begin();
Serial.begin(9600);
Serial.println("Humidity and temperature\n\n");
delay(700);
}
void loop() {
float h = dht.readHumidity();
float t = dht.readTemperature();
Serial.print("Current humidity = ");
Serial.print(h);
Serial.print("% ");
Serial.print("temperature = ");
Serial.print(t);
Serial.println("C ");
delay(800);
}
Output
Upload the above code to the NodeMCU and open serial monitor. Following output should be shown on the serial monitor
You may like also:
- ESP32 BLE with DHT11
- NodeMcu to DHT Interface in Blynk app
- DHT11 vs DHT22: Overview
- Mongoose OS – an IoT firmware development framework
- How To Enable Free HTTPS on your website
- How To Create Secure MQTT Broker
- MQTT Public Brokers List
- Controlling LED with Raspberry Pi
- Home automation | IoT Products for Home Automation
Buy now : Raspberry PI 3 Model B+ Motherboard
i hope you like this post How to use DHT11 sensor with ESP8266/NodeMCU using Arduino IDE.
Pingback: Mongoose OS is now an STMicroelectronics Authorized Partner
Pingback: Johnny Five : The JavaScript Robotics & IoT Platform
Pingback: How to Use I2C LCD with ESP32 Using Arduino IDE
Pingback: ESP32 BLE Tutorials | How to use ESP32 with BLE
Pingback: InfluxDB | Installation | How To Use | Time Series Database ?
Pingback: How to Fix Broken Packages in Ubuntu - IoTbyHVM - Bits & Bytes of IoT
Pingback: Managing Files with NodeMCU | NodeMCU Examples
Pingback: IoT Sensors and Actuators - IoTbyHVM - Bits & Bytes of IoT
Pingback: IoT Protocols and Communication APIs - IoTbyHVM - Bits & Bytes of IoT
Pingback: NodeRed Alternatives - Visual programming tools -IoTbyHVM
Pingback: ATOMIC Pi - A high power alternative to RPi - IoTbyHVM
Pingback: Arduino SPI Tutorial - IoTbyHVM - Bits & Bytes of IoT
Pingback: Symphony Link LPWAN IoT Network - IoTbyHVM - Bits & Bytes of IoT
Pingback: Program Your Arduino With an Android Device -IoTbyHVM
Pingback: Orient Electic introduces India’s first IoT-enabled Aeroslim ceiling fan
Pingback: Log Temperature Sensor Data to Google Sheet using NodeMCU ESP8266
Pingback: GPIO Pins of ESP32 | ESP32 Tutorials - IoTbyHVM - Bits & Bytes of IoT
Pingback: Interface LDR module with NodeMCU - IoTbyHVM - Bits & Bytes of IoT
Pingback: InfluxDB | Time Series Database ? | TickStack | Tickscript ?
I follow this and found 255 shown for both temp and humidity measurement. Can’t identify what is going wrong???