TIMOTHY MWALA
Published © GPL3+

Build Your own SIM800L-GSM security "πŸ•" SMS ALERT!!

Transforming security! Get instant alerts on intruders with motion detection and SMS alerts. Secure your space today. πŸ‘β€πŸ—¨πŸ”

BeginnerProtip2 hours129
Build Your own SIM800L-GSM security "πŸ•" SMS ALERT!!

Things used in this project

Story

Read more

Schematics

Scheme

Code

PIR_D1-mini_GSM SMS alerts

C/C++
replace the phone number you would wish to receive the messages
#include <Wire.h>
#include <SoftwareSerial.h>

SoftwareSerial sim800l(D7, D6);

const int PIR = D3;
int PIRState = 0;

void setup()
{
  Serial.begin(9600);
  sim800l.begin(9600);

  Serial.println("Initializing...");
  delay(1000);

  pinMode(PIR, INPUT);

  sim800l.println("AT");
  updateSerial();

  sim800l.println("AT+CMGF=1");
  updateSerial();
}

void loop()
{
  PIRState = digitalRead(PIR);

  if (PIRState == HIGH) {
    Serial.println("Sensor detects motion");
    SendSMS(); // Send SMS every time motion is detected
    delay(2000); // Delay for stability
  } else {
    Serial.println("No motion detected");
  }

  while (sim800l.available()) {
    Serial.write(sim800l.read());
  }
}

void SendSMS()
{
  sim800l.println("AT+CMGS=\"+codexxxxxxxxxx\""); //replace with your country code and your phone digits
  delay(500);
  sim800l.print("Security alert | Intruder detected!");
  sim800l.write(26); // Send Ctrl+Z to indicate end of SMS
  delay(500); // Give time for the module to process
  while (sim800l.available()) {
    Serial.write(sim800l.read());
  }
}

void updateSerial()
{
  while (sim800l.available()) {
    char c = sim800l.read();
    Serial.write(c);
  }
}

Credits

TIMOTHY MWALA

TIMOTHY MWALA

5 projects β€’ 4 followers
SmartHome Nerd

Comments