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

Arduino-Based AC Voltage Monitoring and Relay Control System

View and Edit Project In Cirkit DesignerImage of Arduino-Based AC Voltage Monitoring and Relay Control System

Circuit Documentation

Summary

The circuit is designed to monitor the voltage of an AC source and control an AC bulb accordingly. It uses an Arduino UNO microcontroller to read the voltage level from a voltage sensor and display the voltage on a 16x2 LCD. The Arduino controls a 5V relay to turn the AC bulb on or off based on the voltage level. If the voltage is outside the safe range (200V to 250V), the relay disconnects the bulb to prevent damage.

Component List

Voltage Sensor

AC Bulb

Arduino UNO

5V Relay

AC Source

16X2 LCD

Voltage Regulator - Variable

Wiring Details

Voltage Sensor

AC Bulb

Arduino UNO

5V Relay

AC Source

16X2 LCD

Voltage Regulator - Variable

Documented Code

#include <LiquidCrystal.h>

// Initialize the LCD (RS, E, D4, D5, D6, D7)
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

const int voltagePin = A0;     // Analog pin for voltage sensor
const int relayPin = 2;        // Relay control pin

float minVoltage = 200.0;      // Minimum safe voltage
float maxVoltage = 250.0;      // Maximum safe voltage

void setup() {
  lcd.begin(16, 2);            // Initialize LCD
  pinMode(relayPin, OUTPUT);   // Relay control pin
  digitalWrite(relayPin, HIGH); // Ensure relay is off initially
  
  lcd.print("Voltage Monitor");
  delay(2000);
  lcd.clear();
}

void loop() {
  int sensorValue = analogRead(voltagePin);      // Read from AC sensor
  float voltage = sensorValue * (5.0 / 1023.0);  // Convert to 0-5V range
  voltage = voltage * (330.0 / 5.0);             // Scale to actual AC voltage
  
  lcd.setCursor(0, 0);
  lcd.print("Voltage: ");
  lcd.print(voltage);

  if (voltage < minVoltage) {
    lcd.setCursor(0, 1);
    lcd.print("Under Voltage! ");
    digitalWrite(relayPin, HIGH); // Turn off relay, disconnect load
  }
  else if (voltage > maxVoltage) {
    lcd.setCursor(0, 1);
    lcd.print("Over Voltage! ");
    digitalWrite(relayPin, HIGH); // Turn off relay, disconnect load
  }
  else {
    lcd.setCursor(0, 1);
    lcd.print("Voltage Normal ");
    digitalWrite(relayPin, LOW);  // Turn on relay, connect load
  }

  delay(500);
}

This code is designed to run on an Arduino UNO microcontroller. It initializes the LCD and sets up the relay and voltage sensor pins. In the main loop, it reads the voltage from the sensor, scales it to the AC voltage range, and displays it on the LCD. Depending on the voltage level, it controls the relay to protect the load from under or over-voltage conditions.