Interface DHT11 (Humidity Sensor) Using NodeMCU

Introduction: Interface DHT11 (Humidity Sensor) Using NodeMCU

Hey Makers!

In this Instructables you will learn how to set up the DHT11 Humidity and Temperature sensor on your NodeMCU. And learn about how the Humidity sensor works, and how to check output readings from the Serial monitor.

Step 1: Components Required

Here is the list of components required to get started with the Instructable,

Hardware Components

NodeMCU

DHT11 Humidity and Temperature sensor

Breadboard

Jumper Wires (Optional)

Micro USB Cable

Software Components

Arduino IDE

Step 2: Description

The DHT11 detects water vapor by measuring the electrical resistance between two electrodes. The humidity sensing component is a moisture holding substrate with electrodes applied to the surface. When water vapor is absorbed by the substrate, ions are released by the substrate which increases the conductivity between the electrodes. The change in resistance between the two electrodes is proportional to the relative humidity. Higher relative humidity decreases the resistance between the electrodes, while lower relative humidity increases the resistance between the electrodes.

Step 3: Two Different DHT11

There are two different versions of the DHT11 you might come across.

One type has four pins, and the other type has three pins and is mounted to a small PCB.

The PCB mounted version is nice because it includes a surface mounted 10K Ohm pull up resistor for the signal line. Here are the pin outs for both versions.

Step 4: ​How to Setup DHT11 on an NodeMCU

Wiring the DHT11 to the NodeMCU is really easy, but the connections are different depending on which type you have either 3-pins or 4-pins.

The wiring connections are made as follows :Pin 1 of the DHT11 goes into +3v of the NodeMCU.

Pin 2 of the DHT11 goes into Digital Pin D4 of the NodeMCU.

Pin 3 of the DHT11 goes into Ground Pin (GND) of the NodeMCU.

Step 5: Coding Time

Before you use the DHT11 with NodeMCU, you need to install the DHTLib library. It has all the functions needed to get the humidity and temperature readings from the sensor. It’s easy to install.

Open up the Arduino IDE, then go to Sketch > Include Library > Manage Libraries > Search DHTLib

After it’s installed, upload this program to the NodeMCU by download the attached code "DHT11.ino" below and check output in the serial monitor.

Comments

Absolutely love this project!I made one myself but every time I let the project check itself or try to upload it it says that «dth» isn't compatible with the nodemcu.Do you have any suggestions how to fix this?