Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

ESP8266-Based Wi-Fi Humidity and Temperature Sensor

View and Edit Project In Cirkit DesignerImage of ESP8266-Based Wi-Fi Humidity and Temperature Sensor

Circuit Documentation

Summary

The circuit in question is designed to measure temperature and humidity using a DHT11 Humidity and Temperature Sensor interfaced with an ESP8266 microcontroller. The ESP8266 reads the sensor data and outputs the readings through its serial interface. A resistor and a ceramic capacitor are included in the circuit, likely for signal conditioning or power supply stabilization.

Component List

ESP8266

DHT11 Humidity and Temperature Sensor

Resistor

Ceramic Capacitor

Wiring Details

ESP8266

DHT11 Humidity and Temperature Sensor

Resistor

Ceramic Capacitor

Documented Code

The following code is written for the ESP8266 microcontroller to interface with the DHT11 sensor. The code is written in C++ and is intended to be compiled and uploaded using the Arduino IDE.

#include <DHT.h>

#define DHTPIN D1      // Pin de données du DHT11 connectée à D4
#define DHTTYPE DHT11   // Type de capteur

DHT dht(DHTPIN, DHTTYPE);

void setup() {
    Serial.begin(115200);
    dht.begin();
}

void loop() {
    float humidity = dht.readHumidity();
    float temperature = dht.readTemperature();

    if (!isnan(humidity) && !isnan(temperature)) {
        Serial.print("Humidité : ");
        Serial.print(humidity);
        Serial.print(" %  |  Température : ");
        Serial.print(temperature);
        Serial.println(" °C");
    } else {
        Serial.println("Erreur de lecture du capteur !");
    }

    delay(2000);  // Attendre 2 secondes entre chaque lecture
}

Filename: sketch.ino

This code initializes the DHT library with the DHT sensor connected to pin D1 of the ESP8266. In the setup() function, it begins serial communication at 115200 baud and initializes the sensor. The loop() function reads the humidity and temperature from the sensor and prints it to the serial monitor. If the sensor fails to provide a reading, an error message is printed. There is a 2-second delay between readings.