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

Arduino Nano-Based Smart Energy Monitoring and Control System with Automatic Shutoff

View and Edit Project In Cirkit DesignerImage of Arduino Nano-Based Smart Energy Monitoring and Control System with Automatic Shutoff

Circuit Documentation

Summary

The circuit is designed to monitor and control various parameters such as temperature, voltage, and current. It includes an Arduino Nano microcontroller interfaced with multiple sensors, a display module, pushbuttons, solid-state relays, MOSFETs, and other components. The system allows for setting thresholds and has features like alarm indication, automatic shutoff, and live monitoring displayed on an LCD.

Component List

Wiring Details

Arduino Nano

Power 220V

LM2596

Bridge Rectifier

MKE-M08 LCD2004 I2C Module

Pushbuttons

2 Channel G3MB-202P Solid-State Relay

Voltage Sensors

IRFZ44N MOSFETs

ACS712 Current Sensors

Sockets

NTCs

RGB LED

Resistors

Piezo Buzzer

Grounding Receptacle Outlet 15A 250V~

Electrolytic Capacitor

Documented Code

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

// Pin definitions
#define BUTTON_1_PIN 6
#define BUTTON_2_PIN 7
#define BUTTON_3_PIN 8
#define BUTTON_4_PIN 9
#define BUTTON_5_PIN 10

#define RELAY_PIN 3
#define BUZZER_PIN 5
#define MOSFET_PIN 4
#define MOSFET_PIN_2 12

#define RGB_RED_PIN 11
#define RGB_GREEN_PIN 10
#define RGB_BLUE_PIN 9

// LCD initialization
LiquidCrystal_I2C lcd(0x27, 20, 4);

// Threshold variables
float tempThreshold1 = 50.0;
float voltageThreshold1 = 240.0;
float currentThreshold1 = 5.0;

float tempThreshold2 = 50.0;
float voltageThreshold2 = 240.0;
float currentThreshold2 = 5.0;

// Desired current levels
float desiredCurrent1 = 2.0;
float desiredCurrent2 = 2.0;

// Sensor readings
float temperature1 = 0.0;
float voltage1 = 0.0;
float current1 = 0.0;

float temperature2 = 0.0;
float voltage2 = 0.0;
float current2 = 0.0;

bool isSetMode = false;
bool isAlarmOn = false;
bool isAutoShutOff = false;
bool isSystemOn = true;

enum ThresholdType { TEMPERATURE, VOLTAGE, CURRENT, CURRENT_SET1, CURRENT_SET2 };
ThresholdType selectedThreshold = TEMPERATURE;

unsigned long lastThresholdChangeTime = 0;
bool thresholdChanged = false;

unsigned long lastButton5PressTime = 0;
unsigned long button5PressCount = 0;
unsigned long alarmStartTime = 0;

void setup() {
    Serial.begin(9600);

    lcd.init();
    lcd.backlight();

    // Pin mode configuration
    pinMode(RELAY_PIN, OUTPUT);
    pinMode(BUZZER_PIN, OUTPUT);
    pinMode(MOSFET_PIN, OUTPUT);
    pinMode(MOSFET_PIN_2, OUTPUT);
    pinMode(BUTTON_1_PIN, INPUT_PULLUP);
    pinMode(BUTTON_2_PIN, INPUT_PULLUP);
    pinMode(BUTTON_3_PIN, INPUT_PULLUP);
    pinMode(BUTTON_4_PIN, INPUT_PULLUP);
    pinMode(BUTTON_5_PIN, INPUT_PULLUP);

    pinMode(RGB_RED_PIN, OUTPUT);
    pinMode(RGB_GREEN_PIN, OUTPUT);
    pinMode(RGB_BLUE_PIN, OUTPUT);

    // Initial state of outputs
    digitalWrite(RELAY_PIN, LOW);
    digitalWrite(BUZZER_PIN, LOW);
    analogWrite(MOSFET_PIN, 0);
    analogWrite(MOSFET_PIN_2, 0);

    setRGBColor(0, 0, 255); // Set initial color to blue (Set Mode)
}

void loop() {
    // Button handling
    if (digitalRead(BUTTON_4_PIN) == LOW) {
        isSetMode = !isSetMode;
        delay(200); // Debounce delay
    }

    if (digitalRead(BUTTON_1_PIN) == LOW) {
        increaseThreshold();
        delay(200); // Debounce delay
    }

    if (digitalRead(BUTTON_2_PIN) == LOW) {
        decreaseThreshold();
        delay(200); // Debounce delay
    }

    if (digitalRead(BUTTON_3_PIN) == LOW) {
        switchThresholdType();
        delay(200); // Debounce delay
    }

    if (digitalRead(BUTTON_5_PIN) == LOW) {
        handleButton5Press();
        delay(200); // Debounce delay
    }

    // Mode handling
    if (isSetMode) {
        setRGBColor(0, 0, 255); // Blue for Set Mode
        displaySetMode();
    } else {
        // Read sensors
        temperature1 = readTemperature(A0);
        voltage1 = readVoltage(A1);
        current1 = readCurrent(A2