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

Wi-Fi Controlled 4-Channel Relay System with Arduino and ESP8266

View and Edit Project In Cirkit DesignerImage of Wi-Fi Controlled 4-Channel Relay System with Arduino and ESP8266

Circuit Documentation

Summary

This circuit is a Wi-Fi controlled 4-channel relay system using an Arduino UNO and an ESP8266 ESP-01 WiFi module. The relays can be controlled via a web interface served by the ESP8266. The Arduino UNO handles the relay control and communicates with the ESP8266 via serial communication. An LCD display is used to show the status of each relay. The relays are connected to various 220V AC red lights.

Component List

  1. ESP8266 ESP-01 WiFi Module

    • Description: WiFi module for wireless communication.
    • Pins: TXD, CH_PD, RST, VCC, GND, GPIO_2, GPIO_0, RXD
  2. Relay 4 Channel 5v

    • Description: 4-channel relay module for controlling high voltage devices.
    • Pins: GND, IN1, IN2, IN3, IN4, VCC, COM1, COM2, COM3, COM4, NO1, NO2, NO3, NO4, NC1, NC2, NC3, NC4
  3. Arduino UNO

    • Description: Microcontroller board based on the ATmega328P.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  4. LCD Display 16x4 I2C

    • Description: 16x4 character LCD display with I2C interface.
    • Pins: SCL, SDA, VCC, GND
  5. Red Light 220VAC

    • Description: 220V AC red indicator light.
    • Pins: -, +
  6. AC Source

    • Description: AC power source.
    • Pins: -, +

Wiring Details

ESP8266 ESP-01 WiFi Module

Relay 4 Channel 5v

Arduino UNO

LCD Display 16x4 I2C

Red Light 220VAC

AC Source

Code Documentation

/*
 * Wi-Fi Controlled 4-Channel Relay with Arduino and ESP8266
 * This code allows control of 4 relays via Wi-Fi using the ESP8266 module.
 * The relays can be controlled through a web interface served by the ESP8266.
 * The relays are connected to digital pins D7, D8, D9, and D10 of the Arduino.
 * The ESP8266 communicates with the Arduino via serial communication.
 * The LCD display shows the status of each relay.
 */

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 4);

const int relayPins[4] = {7, 8, 9, 10};

void setup() {
  Serial.begin(115200); // Initialize serial communication with ESP8266
  for (int i = 0; i < 4; i++) {
    pinMode(relayPins[i], OUTPUT);
    digitalWrite(relayPins[i], HIGH); // Turn off all relays initially
  }
  lcd.begin();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("Relay Status:");
  updateLCD();
}

void loop() {
  if (Serial.available()) {
    char command = Serial.read();
    int relayIndex = command - '1';
    if (relayIndex >= 0 && relayIndex < 4) {
      digitalWrite(relayPins[relayIndex], !digitalRead(relayPins[relayIndex]));
      updateLCD();
    }
  }
}

void updateLCD() {
  for (int i = 0; i < 4; i++) {
    lcd.setCursor(0, i + 1);
    lcd.print("Relay ");
    lcd.print(i + 1);
    lcd.print(": ");
    lcd.print(digitalRead(relayPins[i]) == LOW ? "ON " : "OFF");
  }
}

This code initializes the relays and the LCD display. It reads commands from the ESP8266 via serial communication to toggle the relays and updates the LCD display to show the status of each relay.