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.
5V
pin is connected to the Vcc pins of both Voltage Sensors.GND
pin is connected to the common ground network.A0
pin is connected to the output of one Voltage Sensor.A1
pin is connected to the output of the other Voltage Sensor.D2
pin is connected to a 2000 Ohm Resistor.D3
pin is connected to the RXD pin of the SIM800L module.Vcc
pins are connected to the 5V output from the Arduino UNO.Ground
pins are connected to the neutral wire of the 240V Power Sources.Phase
pins are connected to the live wire of the 240V Power Sources.Out
pins are connected to the A0 and A1 pins on the Arduino UNO for voltage sensing.Gnd
pins are part of the common ground network.VCC
pin is connected to the VCC pin of the Polymer Lithium Ion Battery.GND
pin is part of the common ground network.RXD
pin is connected to the D3 pin on the Arduino UNO.TXD
pin is connected to a 1000 Ohm Resistor.Live
pins are connected to the Phase
pins of the Voltage Sensors.Neutral
pins are connected to the Ground
pins of the Voltage Sensors.VCC
pin is connected to the VCC pin of the SIM800L module.GND
pin is part of the common ground network./*
* 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.