ESP8266/IoT B.Tech/Diploma Beginner

ESP8266 & DHT11 Humidity Temperature Monitor on ThingSpeak

Humidity & Temperature Monitor using DHT11 & NodeMCU ESP8266 on ThingSpeak to monitor Sensor Data on Cloud Server with Source Code & Circuit

  • Suitable forB.Tech/Diploma ESP8266/IoT students
  • Build time1-2 weeks
  • LevelBeginner
  • Available atAjvika Labs, Kakinada

About this project

DHT11 Humidity Temperature Monitor with 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 be used to 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.
This guide is based on the
Arduino IDE
and is specifically written for the NodeMCU ESP8266 board. However, the same concept can be applied to any ESP8266-based development board for
real-time
temperature and humidity monitoring.
Before you begin, check this previous article related to
DHT11 and Arduino interfacing
to help you get started.
Bill of Materials
You just need NodeMCU ESP-12E WiFi Development board and a humidity sensor DHT11 or DHT22. In addition to this breadboard and connecting wires are required.
S.N.
Components Name
Quantity
Purchase Links

NodeMCU ESP8266 Board

Amazon
AliExpress

DHT11 Sensor

Amazon
AliExpress

Connecting Wires

Amazon
AliExpress

Breadboard

Amazon
AliExpress
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
, which means no analog input is required — making it ideal for microcontrollers like the
NodeMCU ESP8266
Arduino
, and
ESP32
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
Parameter
Value
Humidity Range
20% to 90% RH
Humidity Accuracy
±5% RH
Temperature Range
0°C to 50°C
Temperature Accuracy
±2°C
Sampling Rate
1 reading every 1–2 seconds
Operating Voltage
3.3V to 5V
Interface
Single-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.
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
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.
Create a New Channel
After login, 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
Add an optional description and metadata if needed
Scroll down and click
“Save Channel”
to create it successfully.
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 a 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:
Copy and paste the code
into your Arduino IDE.
Download and install the DHT11/DHT22 library
from GitHub (or through Arduino Library Manager) and ensure it is added to your project.
Select the correct board
by navigating to:
Tools → Board → NodeMCU 1.0 (ESP-12E Module)
Insert your ThingSpeak Write API Key
into the code at the specified location. This is the same key you generated while creating your channel.
Edit the Wi-Fi credentials
, replacing the default SSID and Password with your own network details.
Verify (Compile) the code
and then
upload
it to the NodeMCU board.

/*
NodeMCU (ESP8266) + DHT11 → ThingSpeak
--------------------------------------
- Reads temperature & humidity from DHT11
- Posts data to ThingSpeak Channel fields
- Uses a safe 20 s upload interval (ThingSpeak min = 15 s; DHT11 ~2 s)
Wiring (NodeMCU 1.0 ESP-12E):
DHT11 VCC -> 3V3
DHT11 DATA -> D3 (GPIO0) // you can change the pin if you prefer
DHT11 GND -> GND
(Most DHT11 modules already have a 10k pull-up on DATA)
*/
#include <ESP8266WiFi.h>
#include <DHT.h>
// -------------------- USER SETTINGS --------------------
const
char
*
ssid
=
;
// <-- replace with your WiFi SSID
const
char
*
password
=
"alhabibi"
;
// <-- replace with your WiFi password
// ThingSpeak settings
const
char
*
server
=
"api.thingspeak.com"
;
const
char
*
writeAPI
=
"H38TEGNC0XKW43BB"
;
// <-- replace with your ThingSpeak WRITE API key
// Map your fields in the channel: Field1 = Temperature (°C), Field2 = Humidity (%RH)
// Sensor settings
#define DHTPIN 0 // GPIO0 (NodeMCU pin label: D3)
#define DHTTYPE DHT11
// ------------------------------------------------------
DHT
dht
(
DHTPIN
DHTTYPE
)
;
WiFiClient
client
;
// Upload every ≥15 s. Use 20 s for safety.
const
unsigned
long
UPLOAD_INTERVAL_MS
=
20000
;
unsigned
long
lastUpload
=

;
void
connectWiFi
(
)
{
Serial
(
"Connecting to WiFi: "
)
;
Serial
println
(
ssid
)
;
WiFi
mode
(
WIFI_STA
)
;
WiFi
begin
(
ssid
password
)
;
// Wait for connection
uint8_t
tries
=

;
while
(
WiFi
status
(
)
!=
WL_CONNECTED
)
{
delay
(

)
;
Serial
(
'.'
)
;
if
(
++
tries
>=

)
{
// ~30 seconds timeout
Serial
println
(
"\nWiFi connect timeout. Restarting..."
)
;
ESP
restart
(
)
;
}
}
Serial
println
(
"\nWiFi connected!"
)
;
Serial
(
"IP address: "
)
;
Serial
println
(
WiFi
localIP
(
)
)
;
}
void
setup
(
)
{
Serial
begin
(
115200
)
;
delay
(

)
;
Serial
println
(
)
;
Serial
println
(
"DHT11 + NodeMCU → ThingSpeak"
)
;
dht
begin
(
)
;
connectWiFi
(
)
;
}
bool
postToThingSpeak
(
float
temperatureC
float
humidity
)
{
// Build URL-encoded POST body. API key can go in header (X-THINGSPEAKAPIKEY)
// or as field "api_key" in the body. We’ll send it in the header and keep
// the body to fields only.
String
postBody
=
"field1="
+
String
(
temperatureC

Technologies used

ESP32ESP8266ArduinoThingSpeakWiFiBLEDHT11DHT22Arduino IDE

Hardware components

  • ESP32
  • ESP8266
  • Arduino
  • DHT11
  • DHT22

Software & tools

  • Arduino IDE
  • ThingSpeak

What you get

  • Working project / hardware kit, tested before delivery
  • Complete source code with explanation
  • Project demo and guidance for your viva
  • Project report, PPT and IEEE paper support (on request)
Delivery & Payment
Delivery takes a minimum of two weeks from the date your inquiry is confirmed. Payment is in two parts: • 50% advance to start the project • Remaining 50% before delivery Note: • Documentation and PPT are not included by default • If you need documentation/PPT, it can be arranged for extra time and cost We'll confirm the exact timeline and cost with you after reviewing your requirements.