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

ESP32-Based Current Monitoring System with LCD Display and Relay Control

View and Edit Project In Cirkit DesignerImage of ESP32-Based Current Monitoring System with LCD Display and Relay Control

Circuit Documentation

Summary

This circuit is designed to monitor the current using an ACS712 current sensor and display the readings on a 20x4 I2C LCD. Additionally, it controls a solid-state relay (SSR-40A) based on the current readings. The ESP32 Wroom Dev Kit is used as the microcontroller to interface with the current sensor, LCD, and relay.

Component List

  1. ESP32 Wroom Dev Kit

    • Description: A powerful microcontroller with Wi-Fi and Bluetooth capabilities.
    • Pins: 3V3, EN, VP, VN, GPIO 34, GPIO 35, GPIO 32, GPIO 33, GPIO 25, GPIO 26, GPIO 27, GPIO 14, GND, GPIO 13, SD2, SD3, CMD, V5, GPIO 23, GPIO 22, TXD, RXD, GPIO 21, GPIO 19, GPIO 18, GPIO 5, GPIO 17, GPIO 16, GPIO 4, GPIO 0, GPIO 2, GPIO 15, SD1, SD0, CLK
  2. SSR-40A

    • Description: A solid-state relay used to control high-power devices.
    • Pins: -, +, Lin, Lout
  3. Lcd 20x4 I2C

    • Description: A 20x4 character LCD with I2C interface.
    • Pins: GND, 5V, SCA, SCL
  4. ACS712 Current Sensor 5A 20A 30A

    • Description: A current sensor capable of measuring up to 30A.
    • Pins: 1, 2, GND, OUT, VCC

Wiring Details

ESP32 Wroom Dev Kit

SSR-40A

Lcd 20x4 I2C

ACS712 Current Sensor 5A 20A 30A

Code Documentation

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

#define RELAY_PIN 5
#define CURRENT_SENSOR_PIN 34
#define CURRENT_THRESHOLD 13.0

ACS712 currentSensor(ACS712_30A, CURRENT_SENSOR_PIN);
LiquidCrystal_I2C lcd(0x27, 20, 4);

void setup() {
  pinMode(RELAY_PIN, OUTPUT);
  digitalWrite(RELAY_PIN, LOW); // Initially turn off the relay

  lcd.begin();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("Current Monitor");

  currentSensor.calibrate();
}

void loop() {
  float current = currentSensor.getCurrentAC();

  lcd.setCursor(0, 1);
  lcd.print("Current: ");
  lcd.print(current);
  lcd.print(" A");

  if (current > CURRENT_THRESHOLD) {
    digitalWrite(RELAY_PIN, LOW); // Turn off the relay
    lcd.setCursor(0, 2);
    lcd.print("Relay: OFF");
  } else {
    digitalWrite(RELAY_PIN, HIGH); // Turn on the relay
    lcd.setCursor(0, 2);
    lcd.print("Relay: ON ");
  }

  delay(1000); // Update every second
}

This code initializes the current sensor and LCD, and continuously monitors the current. If the current exceeds the threshold, the relay is turned off; otherwise, it is turned on. The current readings and relay status are displayed on the LCD.