Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

ESP32-Based Wi-Fi Temperature and Humidity Monitor with Blynk Integration

Image of ESP32-Based Wi-Fi Temperature and Humidity Monitor with Blynk Integration

Circuit Documentation

Summary of the Circuit

This circuit integrates an ESP32 microcontroller with a DHT11 temperature and humidity sensor. The ESP32 is a versatile microcontroller with Wi-Fi capabilities, which is used here to read data from the DHT11 sensor and send it to the Blynk IoT platform. The DHT11 sensor is a basic, low-cost digital temperature and humidity sensor that provides readings which the ESP32 processes and then transmits over the internet.

Component List

ESP32 (30 pin)

  • Description: A 30-pin microcontroller with Wi-Fi and Bluetooth capabilities, suitable for a wide range of IoT applications.
  • Purpose: Acts as the central processing unit of the circuit, reads sensor data, and communicates with the Blynk server.
  • Pins: EN, VP, VN, D34, D35, D32, D33, D25, D26, D27, D14, D12, D13, GND, Vin, D23, D22, TX0, RX0, D21, D19, D18, D5, TX2, RX2, D4, D2, D15, 3V3

DHT11

  • Description: A basic, low-cost digital temperature and humidity sensor.
  • Purpose: Measures the ambient temperature and humidity and provides this data to the ESP32.
  • Pins: DATA, GND, VCC

Wiring Details

ESP32 (30 pin)

  • D27: Connected to the DATA pin of the DHT11 sensor.
  • GND: Common ground with the DHT11 sensor.
  • Vin: Power supply to the DHT11 sensor's VCC pin.

DHT11

  • DATA: Connected to the D27 pin of the ESP32.
  • GND: Common ground with the ESP32.
  • VCC: Powered by the Vin pin of the ESP32.

Documented Code

The following code is written for the ESP32 microcontroller to interface with the DHT11 sensor and send data to the Blynk platform.

#define BLYNK_PRINT Serial

/* Fill in information from Blynk Device Info here */
#define BLYNK_TEMPLATE_ID           "TMPL39uRWQ5AP"
#define BLYNK_TEMPLATE_NAME         "NVIDIA RTX 4090"
#define BLYNK_AUTH_TOKEN            "PAUlOh6Dq3eATQVGA4OzGpCC-j00X2UC"

#include <DHT.h>
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#define DHTPIN 27         // ESP32 pin connected to DHT11 data pin
#define DHTTYPE DHT11     // DHT11 sensor type
DHT dht(DHTPIN, DHTTYPE);

// Blynk virtual pins
#define VIRTUAL_PIN_TEMP V5
#define VIRTUAL_PIN_HUM V6

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "StarLink";    // WiFi SSID
char pass[] = "nitesh@123";  // WiFi password

void setup()
{
  // Debug console
  Serial.begin(115200);
  dht.begin();

  Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
}

void loop()
{
  Blynk.run();
  // Read temperature and humidity
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  // Check if any reads failed
  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
  // Print values to serial monitor
  Serial.print("Humidity: ");
  Serial.print(h);
  Serial.print(" %  ");
  Serial.print("Temperature: ");
  Serial.print(t);
  Serial.println(" *C");
  // Send values to Blynk
  Blynk.virtualWrite(VIRTUAL_PIN_TEMP, t);
  Blynk.virtualWrite(VIRTUAL_PIN_HUM, h);
  // Wait a few seconds between measurements
  delay(2000);
}

This code initializes the DHT11 sensor and sets up the Wi-Fi and Blynk configurations. It continuously reads the temperature and humidity from the DHT11 sensor and sends this data to the Blynk platform, where it can be monitored remotely. The BLYNK_PRINT macro is used for debugging purposes, and the BLYNK_TEMPLATE_ID, BLYNK_TEMPLATE_NAME, and BLYNK_AUTH_TOKEN are placeholders for the user's specific Blynk configuration. The Wi-Fi credentials should be replaced with the actual SSID and password for the network to which the ESP32 will connect.