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

ESP32C3 Smart Home Energy Monitor with Wi-Fi Control and LED Indicators

View and Edit Project In Cirkit DesignerImage of ESP32C3 Smart Home Energy Monitor with Wi-Fi Control and LED Indicators

Circuit Documentation

Summary

This circuit is designed to monitor and control electrical appliances using an ESP32C3 microcontroller. It reads wattages using an ACS712 current sensor and a voltage sensor, controls appliances using a relay, and indicates WiFi connection status using LEDs. The relay is controlled via a web interface, and the red LED indicates WiFi disconnection status.

Component List

  1. LED: Two Pin (green)

    • Pins: cathode, anode
    • Description: Green LED used to indicate WiFi connection status.
  2. LED: Two Pin (red)

    • Pins: cathode, anode
    • Description: Red LED used to indicate WiFi disconnection status.
  3. Resistor

    • Pins: pin1, pin2
    • Description: 200 Ohms resistor used in series with the green LED.
    • Properties:
      • Resistance: 200 Ohms
  4. Resistor

    • Pins: pin1, pin2
    • Description: 200 Ohms resistor used in series with the red LED.
    • Properties:
      • Resistance: 200 Ohms
  5. Voltage Sensor

    • Pins: Ground, Phase, Vcc, Out, Gnd
    • Description: Sensor used to measure voltage.
  6. 1 Channel Relay 5V

    • Pins: VCC, GND, IN, NC, COM, NO
    • Description: Relay used to control appliances.
  7. Mini AC-DC 110V-230V to 5V 700mA Module

    • Pins: GND, 5v, Neutral, Life
    • Description: Power supply module to convert AC to 5V DC.
  8. SIM 800L V2.0 GSM

    • Pins: SIM_TXD, VDD, SIM.RXD, 5V/4V, GND, RST
    • Description: GSM module for communication.
  9. ACS712 Current Sensor 5A 20A 30A

    • Pins: 1, 2, GND, OUT, VCC
    • Description: Current sensor used to measure current.
  10. OUTLET

    • Pins: AC
    • Description: AC outlet.
  11. 5V Adapter

    • Pins: AC In 1, AC In 2, 5V, GND
    • Description: Adapter to provide 5V power.
  12. ESP32C3 Supermini

    • Pins: GPIO05, GPIO06, GPIO07, GPIO08, GPIO09, GPIO10, GPIO20, GPIO21, GPIO00, GPIO01, GPIO02, GPIO03, GPIO04, 3.3V, GND, +5V
    • Description: Microcontroller used to control the circuit.

Wiring Details

LED: Two Pin (green)

LED: Two Pin (red)

Resistor (200 Ohms)

Resistor (200 Ohms)

Voltage Sensor

1 Channel Relay 5V

Mini AC-DC 110V-230V to 5V 700mA Module

SIM 800L V2.0 GSM

ACS712 Current Sensor 5A 20A 30A

OUTLET

5V Adapter

ESP32C3 Supermini

Code Documentation

/*
 * This Arduino Sketch is for an ESP32C3 microcontroller.
 * It reads wattages using an ACS712 current sensor and a voltage sensor,
 * controls appliances using a relay, and indicates WiFi connection status
 * using LEDs. The relay is controlled via a web interface.
 * The red LED indicates WiFi disconnection status.
 */

#include <WiFi.h>

// Pin definitions
#define GREEN_LED_PIN 6
#define RED_LED_PIN 5
#define RELAY_PIN 4
#define CURRENT_SENSOR_PIN 3
#define VOLTAGE_SENSOR_PIN 2

// WiFi credentials
const char* ssid = "your_SSID";
const char* password = "your_PASSWORD";

// Web server on port 80
WiFiServer server(80);

void setup() {
  // Initialize serial communication
  Serial.begin(115200);

  // Initialize pins
  pinMode(GREEN_LED_PIN, OUTPUT);
  pinMode(RED_LED_PIN, OUTPUT);
  pinMode(RELAY_PIN, OUTPUT);
  pinMode(CURRENT_SENSOR_PIN, INPUT);
  pinMode(VOLTAGE_SENSOR_PIN, INPUT);

  // Connect to WiFi
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
    digitalWrite(RED_LED_PIN, HIGH); // Turn on red LED
  }
  Serial.println("\nWiFi connected");
  digitalWrite(GREEN_LED_PIN, HIGH); // Turn on green LED
  digitalWrite(RED_LED_PIN, LOW); // Turn off red LED

  // Start the server
  server.begin();
}

void loop() {
  // Check for client connection
  WiFiClient client = server.available();
  if (client) {
    Serial.println("New Client.");
    String currentLine = "";
    while (client.connected()) {
      if (client.available()) {
        char c