DEV Community

Cover image for DHT11 Temperature and Humidity Monitoring with ESP8266 and KiwisIoT
manikanda balamurugan S
manikanda balamurugan S

Posted on

DHT11 Temperature and Humidity Monitoring with ESP8266 and KiwisIoT

ESP8266 DHT11 IoT Project: Real-Time Temperature and Humidity Monitoring Using KiwisIoT 🌡️

Introduction

In this project, we build an IoT-based temperature and humidity monitoring system using the ESP8266 NodeMCU and DHT11 sensor.

The DHT11 sensor measures the surrounding temperature and humidity. The ESP8266 collects the sensor readings and sends them to the KiwisIoT dashboard through Wi-Fi.

The dashboard displays temperature and humidity values in real time, making environmental monitoring simple and convenient.

Project Overview

This project uses an ESP8266 NodeMCU connected to a DHT11 sensor. The sensor collects environmental data, and the microcontroller sends the readings to the KiwisIoT platform.

Main Features:

  • Real-time temperature monitoring.
  • Real-time humidity monitoring.
  • Wireless data transmission using Wi-Fi.
  • Live dashboard visualization.
  • Simple and beginner-friendly IoT implementation.

Components Required

  1. ESP8266 NodeMCU
  2. DHT11 Sensor
  3. Jumper Wires
  4. USB Cable

Software Required

  1. Arduino IDE
  2. ESP8266 Board Package
  3. DHT Sensor Library
  4. KiwisIoT Arduino Library

Circuit Connections

Connect the DHT11 sensor to the ESP8266 NodeMCU as follows:

DHT11 Sensor ESP8266 NodeMCU
VCC 3.3V
DATA D5
GND GND

Make sure all connections are correct before powering the board.

Working Procedure

  1. The DHT11 sensor measures the surrounding temperature and humidity.
  2. The ESP8266 reads the sensor values.
  3. The ESP8266 connects to the Wi-Fi network.
  4. The sensor readings are sent to the KiwisIoT platform.
  5. The KiwisIoT dashboard displays the temperature and humidity values.
  6. The readings are updated every two seconds.

Dashboard Configuration

Create a dashboard in the KiwisIoT platform and configure two channels.

  • Channel 0: Temperature (°C)
  • Channel 1: Humidity (%)

Add suitable gauge widgets to display both readings.

Arduino Code

Install the required libraries in Arduino IDE before uploading the program.

Replace the Wi-Fi name, password and dashboard topic ID with your own values. Do not publish your actual Wi-Fi password or private dashboard credentials.

#include <ESP8266WiFi.h>
#include <KiwisIoT.h>
#include <DHT.h>

const char* ssid = "YOUR_WIFI_NAME";
const char* pass = "YOUR_WIFI_PASSWORD";

const char* topic = "YOUR_DASHBOARD_TOPIC_ID";

#define DHT_PIN D5
#define DHT_TYPE DHT11

DHT dht(DHT_PIN, DHT_TYPE);

KiwisIoT kiwisiot(ssid, pass, topic);

void sendDHTData() {

  float temperature = dht.readTemperature();
  float humidity = dht.readHumidity();

  if (isnan(temperature) || isnan(humidity)) {
    Serial.println("Failed to read DHT11!");
    return;
  }

  Serial.println();
  Serial.println("---------- DHT11 MONITORING ----------");

  Serial.print("Temperature: ");
  Serial.print(temperature, 1);
  Serial.println(" °C");

  Serial.print("Humidity: ");
  Serial.print(humidity, 1);
  Serial.println(" %");

  String temperatureData = String(temperature, 1);
  kiwisiot.send("0", temperatureData);

  String humidityData = String(humidity, 1);
  kiwisiot.send("1", humidityData);
}

void setup() {

  Serial.begin(115200);

  Serial.println("DHT11 MONITORING");

  dht.begin();

  Serial.println("DHT11 initialized");

  kiwisiot.begin();

  Serial.println("KiwisIoT initialized");
  Serial.println("Starting monitoring...");
}

void loop() {

  kiwisiot.run();

  static unsigned long lastSend = 0;

  if (millis() - lastSend >= 2000) {

    lastSend = millis();
    sendDHTData();
  }

  delay(100);
}
Enter fullscreen mode Exit fullscreen mode

Output

After uploading the code successfully, the ESP8266 reads the temperature and humidity values from the DHT11 sensor.

The readings are transmitted to the KiwisIoT dashboard through Wi-Fi.

Example Output:

Temperature: 32.3 °C

Humidity: 71.0 %

The dashboard displays both values using gauge widgets.

Applications

  • Indoor environmental monitoring.
  • Room temperature monitoring.
  • Humidity monitoring.
  • Smart home applications.
  • IoT-based environmental monitoring systems.

Real time image:

Conclusion

This project demonstrates how to build a simple IoT-based temperature and humidity monitoring system using ESP8266 and DHT11.

By connecting the sensor to the KiwisIoT platform, we can monitor environmental conditions remotely through a dashboard.

This project also provides practical experience with sensors, microcontrollers, Wi-Fi communication and IoT platforms.

Thank you for reading! 🚀

Top comments (0)