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

Arduino UNO-Based Voltage Monitoring System with SMS Alerts via SIM800L

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Voltage Monitoring System with SMS Alerts via SIM800L

Circuit Documentation

Summary

This circuit is designed to monitor voltage levels using two voltage sensors and an Arduino UNO microcontroller. When a voltage level exceeding a predefined threshold is detected, the Arduino UNO sends an SMS alert via the SIM800L GSM module. The circuit is powered by a Polymer Lithium Ion Battery and interfaces with a 240V AC power source through the voltage sensors.

Component List

Arduino UNO

Voltage Sensor (x2)

SIM800L

240V Power Source (x2)

Resistor (x2)

Polymer Lithium Ion Battery - 850mAh

Wiring Details

Arduino UNO

Voltage Sensors

SIM800L

240V Power Sources

Resistors

Polymer Lithium Ion Battery - 850mAh

Documented Code

/*
 * This Arduino Sketch reads voltage levels from two voltage sensors connected to
 * analog pins A0 and A1. If the voltage level exceeds 10V, it sends an SMS
 * message indicating which sensor detected the voltage using the SIM800L module.
 */

#include <SoftwareSerial.h>

// Define pins
const int sensor1Pin = A0;
const int sensor2Pin = A1;
const int sim800lTxPin = 2;
const int sim800lRxPin = 3;

// Threshold voltage in analogRead units (10V / 5V * 1023)
const int threshold = 204;

// Phone number to send SMS
const char phoneNumber[] = "+237671693917";

// Create a SoftwareSerial object for SIM800L
SoftwareSerial sim800l(sim800lRxPin, sim800lTxPin);

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

  // Wait for SIM800L to initialize
  delay(1000);

  // Send initial AT command to check communication
  sim800l.println("AT");
  delay(1000);
}

void loop() {
  // Read voltage levels from sensors
  int sensor1Value = analogRead(sensor1Pin);
  int sensor2Value = analogRead(sensor2Pin);

  // Check if sensor1 detects voltage above threshold
  bool sensor1Active = sensor1Value > threshold;
  bool sensor2Active = sensor2Value > threshold;

  if (sensor1Active && sensor2Active) {
    sendSMS("ACTIVE 1 and ACTIVE 2");
  } else {
    if (sensor1Active) {
      sendSMS("ACTIVE 1");
    }
    if (sensor2Active) {
      sendSMS("ACTIVE 2");
    }
  }

  // Wait for a while before next reading
  delay(5000);
}

void sendSMS(const char* message) {
  // Send AT command to set SMS mode to text
  sim800l.println("AT+CMGF=1");
  delay(1000);

  // Send AT command to set recipient phone number
  sim800l.print("AT+CMGS=\"");
  sim800l.print(phoneNumber);
  sim800l.println("\"");
  delay(1000);

  // Send the message
  sim800l.println(message);
  delay(1000);

  // Send Ctrl+Z to indicate end of message
  sim800l.write(26);
  delay(1000);
}

This code is responsible for reading the voltage levels from the sensors and sending an SMS alert when the voltage exceeds the threshold. It uses the SoftwareSerial library to communicate with the SIM800L module. The sendSMS function handles the process of sending an SMS message to a predefined phone number.