• 9970077733
  • parag.achaliya143@gmail.com
  • Chandwad, Nashik

NodeMCU-DHT11-ThingSpeak

Humidity & Temperature Monitoring using DHT11 & NodeMCU on ThingSpeak

In this tutorial, we will learn how to monitor humidity and temperature using the DHT11 sensor and NodeMCU ESP8266, and then upload the readings to the ThingSpeak cloud server. The DHT11 will measure temperature and humidity, while ThingSpeak will serve as our IoT cloud platform to store, visualize, and analyze the sensor data from anywhere in the world.

DHT11 Humidity & Temperature Sensor:

The DHT11 is a simple, ultra–low-cost digital sensor used for measuring temperature and humidity. It combines a capacitive humidity sensor and an NTC thermistor to sense the environmental moisture and temperature. The Sensor provides a calibrated digital output on its single data pin, so no analog input is required—making it ideal for microcontrollers like the NodeMCU ESP8266, Arduino, and ESP32.

Humidity & Temperature Monitoring using DHT11 & NodeMCU on ThingSpeak

The DHT11 communicates using a single-wire protocol, and while it is easy to interface, the data communication requires precise timing. Fortunately, there are well-supported Arduino libraries that handle all timing requirements, making it very beginner-friendly.

Although the DHT11 is widely used in DIY and IoT projects, it does come with a few limitations. The most notable is its slow sampling rate — it can only provide a new reading once every 2 seconds. This means that when you request data, the values may be up to 2 seconds old. Additionally, its measurement range and accuracy are modest compared to other sensors like the DHT22.

DHT11 Specifications:

ParameterValue
Humidity Range20% to 90% RH
Humidity Accuracy±5% RH
Temperature Range0°C to 50°C
Temperature Accuracy±2°C
Sampling Rate1 reading every 1–2 seconds
Operating Voltage3.3V to 5V
InterfaceSingle-Wire Digital

Key Features:

  • Single-wire digital output (no analog pin needed)
  • Low-cost and easy to interface
  • Calibrated output — no complex calculations required
  • Compatible with 3.3V and 5V controllers
  • Compact and reliable for basic environmental monitoring

Circuit Diagram & Connection:

To interface the DHT11 temperature and humidity sensor with the NodeMCU ESP8266, we only need three active pins: VCC, Data, and GND. The DHT11 communicates using a single-wire digital interface, which makes the wiring very simple.

Circuit ESP8266 DHT11 Connection

In the circuit shown above, the DATA OUT pin of the DHT11 is connected to GPIO0 (D3) of the NodeMCU, and the Sensor is powered through the NodeMCU’s 3.3V supply. Since the ESP8266 GPIO pins work at 3.3V logic, the DHT11 is fully compatible and does not require any level shifting.

Setting Thingspeak & Getting API Key:

To store and visualize your sensor data on the cloud, we will be using ThingSpeak, a popular IoT analytics platform. Follow the steps below to create your channel and get the required API Key.

Thingspeak for IoT Projects 576x272

  1. Create a ThingSpeak Account
    Visit https://thingspeak.com/ and sign in. If you are a new user, create a free account by completing a simple registration process. Once your account is activated, log in to your dashboard.
  2. Create a New Channel
    After logging in, click on “New Channel” from the dashboard.

      • Enter a Channel Name (e.g., Humidity & Temperature Monitoring)
      • Enable at least two fields:
        • Field 1 → Temperature
        • Field 2 → Humidity

    Thingsepak DHT11 ESP8266

    • Add an optional description and metadata if needed
      Scroll down and click “Save Channel” to create it successfully.
  3. Get the API Key
    Once your channel is created, navigate to the “API Keys” tab.
    Here you will find two keys:

    • Write API Key – used for uploading data from NodeMCU
    • Read API Key – used for reading/displaying data

    Copy the Write API Key and save it in Notepad — you will need this key later in the Arduino code to send your DHT11 data to ThingSpeak.

Source Code/Program:

The complete program for monitoring Humidity and Temperature using the DHT11 sensor and NodeMCU on ThingSpeak is provided below. Follow the steps to upload it through the Arduino IDE:

  1. Copy and paste the code into your Arduino IDE.
  2. Download and install the DHT11/DHT22 library from GitHub (or through Arduino Library Manager) and ensure it is added to your project.
  3. Select the correct board by navigating to:
    Tools → Board → NodeMCU 1.0 (ESP-12E Module).
  4. Insert your ThingSpeak Write API Key into the code at the specified location. This is the same key you generated while creating your channel.
  5. Edit the Wi-Fi credentials, replacing the default SSID and Password with your own network details.
  6. Verify (Compile) the code and then upload it to the NodeMCU board.

Once the upload is complete and your NodeMCU is powered on, it will automatically connect to Wi-Fi and begin sending DHT11 sensor data to your ThingSpeak channel.

Monitor Humidity and Temperature Data on ThingSpeak

Once powered, the DHT11 continuously measures humidity and temperature from the surrounding air. The NodeMCU requests the sensor data through the DATA pin, and then sends the collected values to the ThingSpeak cloud via Wi-Fi.

DHT11 ESP8266 Serial Monitor Thingspeak

To monitor your sensor readings on ThingSpeak, open your channel and navigate to the “Private View” section. The temperature and humidity data will be displayed as real-time graphs, updating each time your NodeMCU uploads new values.

Thingspeak Data