How to receive sms text message when CCTV camera system detects Intruder activity.
CCTV Camera system send SMS Message notification using Arduino and Sim800L GSM Module
Arduino Uno : https://amzn.to/310xVCa
SIM800L GPRS GSM Module : https://amzn.to/3HgLvB6
LM2596 DC to DC Buck Converter : https://amzn.to/3quyzRi
DC 5V 2Amp Power Supply : https://amzn.to/32nb1Wz
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); // RX,TX for Arduino and for the module it's TXD RXD, they should be inverted
const int buttonPin = 7; // the number of the pushbutton pin
int buttonState = 0; // variable for reading the pushbutton status
int state = 0;
void setup()
{
mySerial.begin(9600); //Module baude rate, this is on max, it depends on the version
Serial.begin(9600);
Serial.println("Initializing...");
delay(1000);
mySerial.println("AT"); // Sends an ATTENTION command, reply should be OK
Serial.println("AT"); // Sends an ATTENTION command, reply should be OK
mySerial.println("AT+CMGF=1"); // Configuration for sending SMS
Serial.println("AT+CMGF=1");
delay(500);
while (Serial.available()) {
mySerial.write(Serial.read());//Forward what Serial received to Software Serial Port
}
while (mySerial.available()) {
Serial.write(mySerial.read());//Forward what Software Serial received to Serial Port
}
}
void loop()
{
pinMode(buttonPin, INPUT);
buttonState = digitalRead(buttonPin);
delay(1000); // Delay time to Arm the SMS
if (buttonState == HIGH && state == 0) {
SendSMS();
delay(60000); // Delay time for next SMS
}
if (buttonState == LOW && state == 1) {
state = 0;
}
}
void SendSMS()
{
Serial.println("Sending SMS..."); //Show this message on serial monitor
mySerial.print("AT+CMGF=1\r"); //Set the module to SMS mode
delay(100);
mySerial.print("AT+CMGS=\"+917598111110\"\r"); //Your phone number don't forget to include your country code, example +917598111110"
delay(500);
mySerial.print("CCTV ALARM"); //This is the text to send to the phone number, don't make it too long or you have to modify the SoftwareSerial buffer
delay(500);
mySerial.print((char)26); // (required according to the datasheet)
delay(500);
mySerial.println();
Serial.println("Text Sent.");
delay(1000);
state = 1;
}