ESP8266-Based Live Temperature and Humidity Monitoring Using DHT11 on the KiwisIoT Platform
by SUDHAKAR N in Circuits > Microcontrollers
88 Views, 0 Favorites, 0 Comments
ESP8266-Based Live Temperature and Humidity Monitoring Using DHT11 on the KiwisIoT Platform
Introduction:
- In this project, we will build a simple temperature and humidity monitoring system using a NodeMCU ESP8266 development board and a DHT11 digital temperature and humidity sensor.
- The DHT11 sensor measures the surrounding temperature and relative humidity and sends the readings digitally to the ESP8266. The NodeMCU processes the sensor data and transmits the measurements over Wi-Fi to the KiwisIoT platform for real-time monitoring and visualization.
- The KiwisIoT platform is used to display the sensor readings as live temperature and humidity values on an IoT dashboard. This allows users to monitor the environmental conditions remotely through the KiwisIoT website.
- This project demonstrates the fundamentals of sensor interfacing, microcontroller programming, Wi-Fi communication, IoT data transmission, and real-time environmental monitoring.
- This project is suitable for beginners who want to learn about ESP8266, DHT11 sensors, Arduino programming, Wi-Fi-enabled IoT systems, and real-time data visualization using the KiwisIoT platform.
Supplies
Hardware
- NodeMCU ESP8266 development board – 1
- DHT11 Temperature and Humidity Sensor Module – 1
- Jumper wires – 3
- USB cable – 1
- Computer/Laptop – 1
Software
- Kiwisiot.in
- Arduino IDE
- ESP8266 Board Package
- DHT Sensor Library
- Adafruit Unified Sensor Library
- Kiwisiot Library
Connect the DHT11 Sensor to NodeMCU ESP8266
Description:
- In this step, we will connect the DHT11 temperature and humidity sensor module to the NodeMCU ESP8266 development board.
- The DHT11 sensor provides digital temperature and relative humidity measurements. The NodeMCU ESP8266 receives this data through one of its GPIO pins and processes it using the Arduino program.
- For this project, the DHT11 sensor is connected to the NodeMCU as follows:DHT11 → NodeMCU ESP8266
->VCC → 3.3V
->DATA → D4
->GND → GND
- Carefully check the wiring before connecting the USB cable to the NodeMCU. A correct power and data connection is essential for reliable sensor readings.
Configure Arduino IDE
Description:
- Before programming the NodeMCU, we need to configure the Arduino IDE to support the ESP8266 development board.
- Open the Arduino IDE and install the ESP8266 board package using the Boards Manager.
- After installation, select:
- Tools → Board → ESP8266 Boards → NodeMCU 1.0 (ESP-12E Module)
- Then select the appropriate USB/serial port connected to the NodeMCU.
- Next, open the Library Manager and install the following libraries:
->DHT sensor library
->Adafruit Unified Sensor library
- These libraries provide the functions required to communicate with the DHT11 sensor and read temperature and humidity values.
Upload the DHT11 Monitoring Program
Description:
- After completing the hardware connections and configuring the Arduino IDE, upload the following program to the NodeMCU ESP8266.
- The program initializes the DHT11 sensor and continuously reads temperature and humidity values. The measurements are then displayed through the Serial Monitor.
Code:
#include <KiwisIoT.h>
#include <DHT.h>
const char* ssid = "HOTSPOT NAME";
const char* pass = "HOTSPOT PASS";
const char* topic = "dash_idxxxxxxxxxx";
KiwisIoT kiwisiot(ssid, pass, topic);
// DHT11 configuration
#define DHT_PIN D5
#define DHT_TYPE DHT11
DHT dht(DHT_PIN, DHT_TYPE);
void setup() {
Serial.begin(9600);
dht.begin();
kiwisiot.begin();
}
void loop() {
kiwisiot.run();
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();
// Check whether DHT11 reading is valid
if (isnan(temperature) || isnan(humidity)) {
Serial.println("Failed to read from DHT11!");
delay(2000);
return;
}
// Send temperature to widget ID 1
kiwisiot.send("1", temperature);
// Send humidity to widget ID 2
kiwisiot.send("2", humidity);
Serial.print("Temperature = ");
Serial.print(temperature);
Serial.println(" °C");
Serial.print("Humidity = ");
Serial.print(humidity);
Serial.println(" %");
delay(2000);
}
Set Up the KiwisIoT Dashboard
Description:
- KiwisIoT is used in this project to visualize the temperature and humidity data collected by the DHT11 sensor.
- Create or open an IoT dashboard in KiwisIoT and configure the required widgets for displaying the sensor readings.
- For this project, the dashboard contains:
- Temperature Display – Displays the temperature measured by the DHT11.
- Humidity Display – Displays the relative humidity measured by the DHT11.
- The ESP8266 sends the sensor readings to KiwisIoT through the configured data channels. Once the device is connected and data is received, the values are displayed in real time on the dashboard.
Program the ESP8266 to Send Data to KiwisIoT
Description:
- After configuring the hardware and KiwisIoT dashboard, program the NodeMCU ESP8266 to read the DHT11 sensor and transmit the measurements to KiwisIoT.
- The program connects the ESP8266 to Wi-Fi, reads the temperature and humidity values from the DHT11 sensor, and sends the readings to the configured KiwisIoT dashboard.
- The DHT11 DATA pin is connected to D4 .
Connect the NodeMCU to Wi-Fi
Description:
- Power the NodeMCU through the USB cable and upload the program.
- After starting, the ESP8266 connects to the configured Wi-Fi network. Once the connection is established, the NodeMCU begins reading the DHT11 sensor values and transmitting them to KiwisIoT.
- The Serial Monitor can be used to verify the Wi-Fi connection and monitor the sensor data being sent by the ESP8266.
Monitor Temperature and Humidity on KiwisIoT
Description:
- Once the NodeMCU is connected to Wi-Fi and successfully sends sensor data, open the KiwisIoT dashboard.
- The temperature and humidity values collected from the DHT11 are displayed using the configured dashboard widgets.
- This allows the sensor data to be monitored in real time through the KiwisIoT platform without relying only on the Arduino Serial Monitor.
- The complete data flow is:
- DHT11 → NodeMCU ESP8266 → Wi-Fi → KiwisIoT → Dashboard
- The KiwisIoT dashboard provides a convenient interface for visualizing the environmental data collected by the sensor.
Test and Verify the IoT System
Description:
- To verify the complete system, observe the temperature and humidity values on the KiwisIoT dashboard.
- Allow the system to run for several readings and confirm that the values are updating correctly.
- Changes in the surrounding environment should be reflected in the sensor readings and subsequently updated on the KiwisIoT dashboard.
- Successful real-time updates confirm that the DHT11, NodeMCU ESP8266, Wi-Fi connection, and KiwisIoT dashboard are working together correctly.
Working Principle
- The DHT11 sensor measures the temperature and relative humidity of the surrounding environment.
- The sensor sends the measurements to the NodeMCU ESP8266 through the DATA pin connected to D4.
- The ESP8266 processes the sensor readings and uses its built-in Wi-Fi capability to transmit the data to KiwisIoT.
- KiwisIoT receives the data and displays the temperature and humidity values through dashboard widgets.
Data Flow:
DHT11 Sensor
↓
NodeMCU ESP8266
↓
Wi-Fi
↓
KiwisIoT
↓
Temperature & Humidity Dashboard
Applications
This IoT-based temperature and humidity monitoring system can be used in:
- Smart home monitoring
- Indoor environmental monitoring
- Smart agriculture
- Greenhouse monitoring
- Weather monitoring
- Industrial environmental monitoring
- IoT-based data logging
- Remote environmental monitoring
Future Improvements
- The project can be further enhanced by adding additional sensors and automation features to the KiwisIoT dashboard.
- Possible improvements include:
- Adding more environmental sensors
- Creating historical data graphs
- Adding threshold-based alerts
- Adding automated control systems
- Integrating additional IoT devices
- Developing a larger smart-environment monitoring system
- Extending the project toward AIoT-based data analysis