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

ESP32-Controlled Smart Home Automation System with I2C LCD Feedback

View and Edit Project In Cirkit DesignerImage of ESP32-Controlled Smart Home Automation System with I2C LCD Feedback

Circuit Documentation

Summary

The circuit in question is designed to control a 4-channel relay module using an ESP32 microcontroller. The ESP32 is also interfaced with a 20x4 LCD display over I2C for user feedback. The relay module can control various loads, which are not specified in the provided information. The ESP32 is programmed to connect to a Wi-Fi network and interface with the Blynk IoT platform, allowing remote control of the connected loads via virtual pins. The LCD display shows the status of each load controlled by the relay module.

Component List

ESP32 (30 pin)

LCD Display 20x4 I2C

4 Channel Relay Module

Wiring Details

ESP32 (30 pin)

LCD Display 20x4 I2C

4 Channel Relay Module

Documented Code

#define BLYNK_TEMPLATE_ID "TMPL3eoClDWHt"
#define BLYNK_TEMPLATE_NAME "project"
#define BLYNK_AUTH_TOKEN "p3gTohJHQL_1TlT8Z16XCBZkD07SGxWN"
#include <LiquidCrystal_I2C.h> 
#include <Wire.h>
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

LiquidCrystal_I2C lcd(0x27, 20, 4); 

char ssid[] =  "wifiname";
char pass[] =  "password";

const int fan = 25;
const int light = 26;
const int pump = 27;
const int ac = 14;
const int baudRate = 115200;
const int interval = 100;

BLYNK_CONNECTED() {
  // Request the latest state from the server
  Blynk.syncVirtual(V0);
  Blynk.syncVirtual(V1);
  Blynk.syncVirtual(V2);
  Blynk.syncVirtual(V3);
}

void setup()
{
  lcd.init(); 
  lcd.backlight();
  lcd.setCursor(1, 0); 
  lcd.print("WELCOME");
  Serial.begin(baudRate);

  Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);

  pinMode(fan, OUTPUT);
  pinMode(light, OUTPUT);
  pinMode(pump, OUTPUT);
  pinMode(ac, OUTPUT);
  lcd.clear();
  delay(1000);
}

void loop()
{
  Blynk.run();
  mydisplay(digitalRead(fan), digitalRead(light), digitalRead(pump), digitalRead(ac));
}

BLYNK_WRITE(V0) {
  int pinValue = param.asInt();
  digitalWrite(fan, pinValue);
}

BLYNK_WRITE(V1) {
  int pinValue = param.asInt();
  digitalWrite(light, pinValue);
}

BLYNK_WRITE(V2) {
  int pinValue = param.asInt();
  digitalWrite(pump, pinValue);
}

BLYNK_WRITE(V3) {
  int pinValue = param.asInt();
  digitalWrite(ac, pinValue);
}

void mydisplay(int f, int l, int p, int a) {
  lcd.setCursor(0,0);
  lcd.print("Fan L1  Pump  L2");
  lcd.setCursor(0,1);

  if(f == 0)
    lcd.print("OFF");
  else
    lcd.print("ON ");

  if(l == 0)
    lcd.print(" OFF");
  else
    lcd.print(" ON ");

  if(p == 0)
    lcd.print(" OFF ");
  else
    lcd.print(" ON ");

  if(a == 0)
    lcd.print("  OFF");
  else
    lcd.print("  ON ");
  delay(1000);
  lcd.clear();
}

This code initializes the LCD and sets up the ESP32 to connect to the specified Wi-Fi network and Blynk server. It configures the relay control pins as outputs and handles Blynk virtual pin writes to control the state of the relays. The mydisplay function updates the LCD with the status of each relay.