This document outlines how to create a temperature and humidity monitoring system using an ESP8266, DHT11 sensor, and Arduino Cloud Monitoring. The system measures environmental data and sends it to the Arduino IoT Cloud, allowing real-time monitoring from a web dashboard or mobile app.
Components Required
- ESP8266 (e.g., NodeMCU or Wemos D1 Mini)
- DHT11 Temperature and Humidity Sensor
- Jumper wires
- Breadboard
- USB cable for ESP8266
Step 1: Arduino Cloud Setup
- Sign in to Arduino Cloud:
- Visit the Arduino IoT Cloud and log in with your Arduino account.
- Create a Thing:
- Define a new “Thing” and add variables for temperature and humidity.
- Configure the Device:
- Add your ESP8266 device to the cloud using its unique device ID.
- Dashboard Design:
- Create a dashboard and add widgets like gauges or charts to display the temperature and humidity.
Step 2: Connecting the Hardware
- DHT11 Pinout:
- VCC: 3.3V or 5V
- GND: GND of ESP8266
- DATA: GPIO pin (e.g., D4 for NodeMCU)
- Wiring Diagram:
- Connect the DHT11 VCC to 3.3V on ESP8266.
- Connect GND to GND.
- Connect DATA to a GPIO pin.
Step 3: Programming ESP8266
- Install Required Libraries:
- DHT sensor library by Adafruit.
- Arduino IoT Cloud library.
- Sample Code:
- The Arduino IoT Cloud automatically generates boilerplate code after setting up your Thing. Add the following logic to read the DHT11 data:
#include "thingProperties.h"
#include <DHT.h>
#define DHTPIN D4
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
initProperties();
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
dht.begin();
}
void loop() {
ArduinoCloud.update();
temperature = dht.readTemperature();
humidity = dht.readHumidity();
if (isnan(temperature) || isnan(humidity)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
Serial.print("Temperature: ");
Serial.println(temperature);
Serial.print("Humidity: ");
Serial.println(humidity);
}
Step 4: Uploading the Code
- Select NodeMCU 1.0 (or your ESP8266 board) in the Arduino IDE.
- Choose the correct COM port.
- Upload the code to the ESP8266.
Step 5: Monitoring the Data
- Access the Arduino Cloud Dashboard to view real-time temperature and humidity readings.
- Use the Arduino IoT Remote app on your smartphone for mobile monitoring.
Applications
- Home Automation: Monitor indoor temperature and humidity for comfort.
- Greenhouses: Track environmental conditions for plant health.
- Weather Stations: Build simple weather monitoring setups.