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

ESP32 and SIM800L-Based Smart Power Monitor with Voltage Sensors

View and Edit Project In Cirkit DesignerImage of ESP32 and SIM800L-Based Smart Power Monitor with Voltage Sensors

Circuit Documentation

Summary

This circuit is designed to monitor voltage and current using multiple sensors, control lights via a relay module, and send notifications through a GSM module. The core of the circuit is an ESP32 microcontroller, which reads data from voltage sensors, calculates power, and communicates with the GSM module to send alerts based on predefined conditions. The circuit also includes a power supply module to convert AC to DC, a battery management system, and a step-up boost converter.

Component List

  1. Voltage Sensor

    • Description: Measures voltage levels.
    • Pins: Ground, Phase, Vcc, Out, Gnd
  2. Mini AC-DC 110V-230V to 5V 700mA Module

    • Description: Converts AC voltage to 5V DC.
    • Pins: GND, 5v, Neutral, Life
  3. TP4056

    • Description: Battery charging and protection module.
    • Pins: OUT-, B-, B+, OUT+, IN-, IN+
  4. Ac Supply

    • Description: Provides AC voltage.
    • Pins: +ve, -ve
  5. Step Up Boost 3v-5v

    • Description: Boosts voltage from 3V to 5V.
    • Pins: Vi, GND, Vo
  6. 3.7v Battery

    • Description: Provides 3.7V power supply.
    • Pins: +, -
  7. ESP32 - 38 pins

    • Description: Microcontroller with Wi-Fi and Bluetooth capabilities.
    • Pins: 3V3, EN, SP, SN, G34, G35, G32, G33, G25, G26, G27, G14, G12, GND, G13, SD2, SD3, CMD, 5V, G23, G22, TXD, RXD, G21, G19, G18, G5, G17, G16, G4, G0, G2, G15, SD1, SD0, CLK
  8. Sim800l

    • Description: GSM module for sending and receiving SMS.
    • Pins: NET, RST, VCC, RXD, TXD, GND

Wiring Details

Voltage Sensor

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

TP4056

Ac Supply

Step Up Boost 3v-5v

3.7v Battery

ESP32 - 38 pins

Sim800l

Code Documentation

Power Monitor (Power monitor.ino)

/*
 * This Arduino Sketch is for an ESP32 microcontroller connected to two sets of
 * voltage and current sensors, a GSM 800L module, and a 5V 2-channel relay.
 * The code reads voltage and current values, calculates power, and sends
 * notifications via GSM based on predefined conditions. It also controls
 * two sets of lights via the relay module based on received SMS commands.
 */

#include <SoftwareSerial.h>

// Pin definitions
#define VOLTAGE_SENSOR_1_PIN 33
#define CURRENT_SENSOR_1_PIN 34
#define VOLTAGE_SENSOR_2_PIN 32
#define CURRENT_SENSOR_2_PIN 35
#define RELAY_IN1_PIN 22
#define RELAY_IN2_PIN 23
#define GSM_TX_PIN 17
#define GSM_RX_PIN 16

// Predefined power thresholds
const float power_calc_1 = 1000.0; // 1000W for set 1
const float power_calc_2 = 1000.0; // 1000W for set 2

// Variables to store sensor readings
float voltage1 = 0.0;
float current1 = 0.0;
float power1 = 0.0;
float voltage2 = 0.0;
float current2 = 0.0;
float power2 = 0.0;

// GSM module setup
SoftwareSerial gsm(GSM_RX_PIN, GSM_TX_PIN);

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

  pinMode(RELAY_IN1_PIN, OUTPUT);
  pinMode(RELAY_IN2_PIN, OUTPUT);

  digitalWrite(RELAY_IN1_PIN, LOW);
  digitalWrite(RELAY_IN2_PIN, LOW);
}

void loop() {
  // Read sensors and calculate power
  voltage1 = analogRead(VOLTAGE_SENSOR_1_PIN) * (5.0 / 1023.0);
  current1 = analogRead(CURRENT_SENSOR_1_PIN) * (5.0 / 1023.0);
  power1 = voltage1 * current1;

  voltage2 = analogRead(VOLTAGE_SENSOR_2_PIN) * (5.0 / 1023.0);
  current2 = analogRead(CURRENT_SENSOR_2_PIN) * (5.0 / 1023.0);
  power2 = voltage2 * current2;

  // Check for incoming SMS
  if (gsm.available()) {
    String message = gsm.readString();
    if (message.indexOf("Status") >= 0) {
      sendStatus();
    } else if (message.indexOf("Light 1") >= 0) {
      digitalWrite(RELAY_IN1_PIN, HIGH);
    } else if (message.indexOf("Light 2") >= 0) {
      digitalWrite(RELAY_IN2_PIN, HIGH);
    }
  }

  // Check power thresholds and send notifications
  if (power1 < power_calc_1) {
    sendNotification("Power 1 below threshold");
  }
  if (power2 < power_calc_2) {
    sendNotification("Power 2 below threshold");
  }

  delay(1000); // Delay for 1 second
}

void sendStatus() {
  gsm.print("AT+CMGF=1\r");
  delay(100);
  gsm.print("AT+CMGS=\"+237671693917\"\r");
  delay(100);
  gsm.print("Voltage 1: ");
  gsm.print(voltage1);
  gsm.print("V, Current 1: ");
  gsm.print(current1);
  gsm.print("