Last active
March 5, 2025 14:42
-
-
Save morsine/809c381d3c0750f5f4e4d5d389163e7e to your computer and use it in GitHub Desktop.
digispark_sim800l_motionsensor.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This code uses an Attiny85 chipset on a Digispark board with a SIM800L module and a generic radar motion sensor | |
#include <Wire.h> | |
#include <SoftSerial.h> | |
#define RX_PIN 1 // P1 as RX | |
#define TX_PIN 2 // P2 as TX | |
#define DATA 3 | |
SoftSerial sim800l(RX_PIN, TX_PIN); | |
int PIRState = 0; // whatever sensor you want to use | |
void setup() | |
{ | |
sim800l.begin(9600); | |
delay(1000); | |
pinMode(DATA, INPUT); | |
sim800l.println("AT"); | |
delay(50); | |
sim800l.println("ATH"); //hang up | |
delay(8000); | |
} | |
void loop() | |
{ | |
PIRState = digitalRead(DATA); | |
if (PIRState == HIGH) { | |
//Serial.println("Sensor detects motion"); | |
Call(); // call every time motion is detected | |
delay(1000); // Delay for stability | |
} else { | |
//Serial.println("No motion detected"); | |
delay(50); | |
} | |
} | |
void Call() | |
{ | |
sim800l.println("ATD+ 989300000000;"); //replace with your countrycode and phone number to be called | |
delay(5000); | |
// sim800l.print("Security alert | Intruder detected!"); | |
sim800l.write(26); // Send Ctrl+Z to indicate end of call | |
delay(500); // Give time for the module to process | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment