Shows room temperature on a local web page and logs it to a ThingSpeak graph.
Built and tested by Anju.A · Industrial Robotics Institute

A temperature monitor with two ways to view it. A DHT11 sensor feeds an ESP8266, which hosts a small web page showing the live temperature (auto-refreshing every 5 seconds) and also uploads readings to a ThingSpeak cloud channel every 15 seconds for remote graphs.
| Component | Qty |
|---|---|
| ESP8266 NodeMCU | 1 |
| DHT11 Temperature Sensor | 1 |
| Breadboard | 1 |
| Jumper Wires | As needed |
| USB Cable | 1 |
| From | Connect to |
|---|---|
| DHT11 VCC | 3.3V |
| DHT11 GND | GND |
| DHT11 DATA | D4 (GPIO2) |
Complete, tested Arduino C++ code for this project. Copy it into Arduino IDE and upload it to the ESP8266 NodeMCU.
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <DHT.h>
#include <ThingSpeak.h>
#define DHTPIN D4
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
const char* ssid = "YOUR_WIFI_NAME";
const char* password = "YOUR_WIFI_PASSWORD";
WiFiClient client;
ESP8266WebServer server(80);
unsigned long channelID = 0000000; // your ThingSpeak channel ID
const char* writeAPIKey = "YOUR_API_KEY";
float temperature;
unsigned long lastUpload = 0;
String webpage() {
String page = "<!DOCTYPE html><html>";
page += "<head><meta http-equiv='refresh' content='5'/>";
page += "<title>Temperature Monitor</title></head>";
page += "<body style='text-align:center; font-family:Arial;'>";
page += "<h1>IoT Temperature Monitoring</h1>";
page += "<h2>Temperature: " + String(temperature) + " °C</h2>";
page += "</body></html>";
return page;
}
void handleRoot() {
temperature = dht.readTemperature();
server.send(200, "text/html", webpage());
}
void setup() {
Serial.begin(9600);
dht.begin();
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting...");
}
Serial.print("IP Address: ");
Serial.println(WiFi.localIP());
ThingSpeak.begin(client);
server.on("/", handleRoot);
server.begin();
}
void loop() {
server.handleClient();
// Upload to ThingSpeak every 15 s without blocking the web page
if (millis() - lastUpload > 15000) {
lastUpload = millis();
temperature = dht.readTemperature();
if (!isnan(temperature)) {
ThingSpeak.writeField(channelID, 1, temperature, writeAPIKey);
Serial.println("Temperature Sent: " + String(temperature));
}
}
}A temperature monitor with two ways to view it. A DHT11 sensor feeds an ESP8266, which hosts a small web page showing the live temperature (auto-refreshing every 5 seconds) and also uploads readings to a ThingSpeak cloud channel every 15 seconds for remote graphs.
You need: ESP8266 NodeMCU (1), DHT11 Temperature Sensor (1), Breadboard (1), Jumper Wires, USB Cable (1). Software: Arduino IDE, ESP8266 board package, DHT sensor library, ThingSpeak library, ThingSpeak account.
It is rated intermediate and takes about 2–3 hours to build, using the ESP8266 NodeMCU. The guide on this page explains every connection and step.
The complete, tested Arduino C++ code is free on this page. Copy it into Arduino IDE and upload it to the board.
Yes. IRI sells a kit with the parts for this project (PRJ-142). Message IRI on WhatsApp at +91 86060 82634 for the kit price and delivery details.