

The circuit is designed to control a 220V fan and monitor temperature and humidity using an ESP32 Devkit V1 microcontroller. The system includes a DHT22 sensor for measuring temperature and humidity, a two-channel 5V relay to control the fan, LEDs for status indication, an LCD display for user feedback, a buzzer for alerts, and a power supply to provide the necessary voltages. The ESP32 is programmed to communicate with the Blynk platform for remote monitoring and control.
3V3 connected to DHT22 VCC and LCD Display VCC.GND connected to DHT22 GND, LCD Display GND, both LED cathodes, Buzzer NEGATIVE, and Two Channel Relay GND.D4 connected to DHT22 OUT.D21 (SDA) and D22 (SCL) connected to LCD Display I2C pins.D26 connected to Two Channel Relay IN1.D27 connected to Red LED anode.D14 connected to Green LED anode.D13 connected to Buzzer POSITIVE.VIN connected to Two Channel Relay VCC and POWER SUPPLY 12V-24V Output (DC).IN1 and IN2 controlled by ESP32.VCC connected to ESP32 VIN.GND connected to ESP32 GND.C1 connected to Timer L1.NO1 connected to 220V Fan L, Timer L2, Socket life, and POWER SUPPLY 220V Positive Pole (AC).N connected to Socket neutral and POWER SUPPLY 220V Negative Pole (AC).L connected to Relay NO1.cathode connected to ESP32 GND.anode connected to ESP32 D27.cathode connected to ESP32 GND.anode connected to ESP32 D14.VCC connected to ESP32 3V3.OUT connected to ESP32 D4.GND connected to ESP32 GND.SCL connected to ESP32 D22.SDA connected to ESP32 D21.VCC connected to ESP32 3V3.GND connected to ESP32 GND.220V Positive Pole (AC) connected to Relay NO1.220V Negative Pole (AC) connected to 220V Fan N.GND (DC) connected to ESP32 GND.12V-24V Output (DC) connected to ESP32 VIN.POSITIVE connected to ESP32 D13.NEGATIVE connected to ESP32 GND.earth connected to POWER SUPPLY GND.life connected to Relay NO1.neutral connected to 220V Fan N.S1 and S2 not connected.L1 connected to Relay C1.L2 connected to Relay NO1.#define BLYNK_TEMPLATE_ID "TMPL6-vn2VN_V"
#define BLYNK_TEMPLATE_NAME "Quickstart Template"
#define BLYNK_AUTH_TOKEN "vO02bgbn-43wyzsgJdoY47qDX3Jl8R8y"
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <DHT.h>
#include <WiFi.h>
#include <BlynkSimpleEsp32.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h> // I2C LCD library
#define DHTPIN 4 // Pin where the DHT22 data pin is connected
#define DHTTYPE DHT22 // DHT 22 (AM2302)
#define RELAY_PIN 26 // GPIO pin where relay is connected (IN1)
#define RED_LED_PIN 27 // GPIO pin where RED LED is connected
#define GREEN_LED_PIN 14 // GPIO pin where GREEN LED is connected
#define TEMP_MAX_THRESHOLD 65.0 // Maximum temperature threshold in Celsius
#define TEMP_MIN_THRESHOLD 60.0 // Minimum temperature threshold in Celsius
// WiFi credentials
char ssid[] = "haiyaaa";
char pass[] = "430578440";
// Initialize DHT sensor
DHT dht(DHTPIN, DHTTYPE);
// Initialize I2C LCD (address 0x27)
LiquidCrystal_I2C lcd(0x27, 16, 2);
bool blowerState = false; // Blower state, controlled by Blynk
int blowerbutton;
int countdown = 0; // Timer countdown (initially 0 seconds)
bool countdownActive = false;
BlynkTimer timer; // Timer for sensor values and countdown
void setup() {
Serial.begin(115200);
dht.begin(); // Start reading the DHT sensor
// Set relay and LED pins as outputs
pinMode(RELAY_PIN, OUTPUT);
pinMode(RED_LED_PIN, OUTPUT);
pinMode(GREEN_LED_PIN, OUTPUT);
// Ensure relay and RED LED are off initially, GREEN LED is off
digitalWrite(RELAY_PIN, HIGH); // Turn off the relay initially
digitalWrite(RED_LED_PIN, LOW); // Turn RED LED off initially
digitalWrite(GREEN_LED_PIN, LOW); // Turn GREEN LED off initially
Serial.println("System initialized...");
// Initialize LCD
lcd.init(); // Initialize the LCD with 16 columns and 2 rows
lcd.backlight(); // Turn on the LCD backlight
lcd.setCursor(0, 0);
lcd.print("Connecting to");
lcd.setCursor(0, 1);
lcd.print("Wifi");
// Initialize Blynk connection
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Connected!!");
delay(3000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Cloth Dryer");
digitalWrite(RELAY_PIN, HIGH); // Turn blower OFF
digitalWrite(RED_LED_PIN, LOW); // Turn RED LED OFF (blower is OFF)
digitalWrite(GREEN_LED_PIN, LOW); // Turn GREEN LED OFF
// Set a timer to read the sensor values every 2 seconds
timer.setInterval(2000L, readDHTAndSendToBlynk);
}
// Blynk virtual pin to control the blower (relay)
BLYNK_WRITE(V1) {
blowerbutton = param.asInt(); // Get value from Blynk app (1 or 0)
if (blowerbutton == 1 && !countdownActive) {
// If the blower is manually turned on from Blynk, start countdown
countdownActive = true;
startBlower();
} else if (blowerbutton == 0) {
stopBlower(); // Stop the blower if turned off in Blynk
}
}
// Function to set the timer duration via Blynk app
BLYNK_WRITE(V2) {
int timeSelected = param.asInt(); // Get selected time in minutes
countdown = timeSelected * 60; // Convert minutes to seconds
if (countdown > 0) {
countdownActive = true;
startBlower();
timer.setInterval(1000L, countdownFunction); // Start countdown every second
}
}
// Function to start the blower
void startBlower() {
digitalWrite(RELAY_PIN, LOW); // Turn blower ON
digitalWrite(RED_LED_PIN, HIGH); // Turn RED LED ON
digitalWrite(GREEN_LED_PIN,