Components and supplies
PIR Sensor
Jumper wires (generic)
Arduino UNO
DC Voltage Boster
GSM SIM800l
Project description
Code
Code
arduino
1/* This code works with motion sensor, when motion detects it will automatic call on number which is in code. 2 * For more videos please visit our youtube channel. https://www.youtube.com/channel/UCsn5KGbvt5Se7MaLsfNYthA 3 */ 4 5#include <SoftwareSerial.h> 6 7SoftwareSerial sim800l(2, 3); // RX,TX for Arduino and for the module it's TXD RXD, they should be inverted 8 9#define Motion_Sensor A0 //Button pin, on the other pin it's wired with GND 10bool Sensor_State; //Sensor_State 11 12 13void setup() 14{ 15 16 pinMode(Motion_Sensor, INPUT); //The button is always on HIGH level, when pressed it goes LOW 17 sim800l.begin(9600); //Module baude rate, this is on max, it depends on the version 18 Serial.begin(9600); 19 delay(1000); 20} 21 22void loop() 23{ 24 25//SendSMS(); 26 Sensor_State = digitalRead(Motion_Sensor); //We are constantly reading the button State 27 28 if (Sensor_State == HIGH) { //And if it's pressed 29 Serial.println("Sensor detect motion"); //Shows this message on the serial monitor 30 delay(200); //Small delay to avoid detecting the button press many times 31 32 SendSMS(); //And this function is called 33delay(4000); 34 35 } 36 else{ 37 Serial.println("."); 38 } 39 40 if (sim800l.available()){ //Displays on the serial monitor if there's a communication from the module 41 Serial.write(sim800l.read()); 42 } 43} 44 45void SendSMS() 46{ 47 Serial.println("Sending SMS..."); //Show this message on serial monitor 48 sim800l.print("AT+CMGF=1\ "); //Set the module to SMS mode 49 delay(100); 50 sim800l.print("AT+CMGS=\\"+###############\\"\ "); //Your phone number don't forget to include your country code, example +212123456789" 51 delay(500); 52 sim800l.print("Security Alert.....!!!!!!! Some one entered in the house "); //This is the text to send to the phone number, don't make it too long or you have to modify the SoftwareSerial buffer 53 delay(500); 54 sim800l.print((char)26);// (required according to the datasheet) 55 delay(500); 56 sim800l.println(); 57 Serial.println("Text Sent."); 58 delay(500); 59 60}
Code
arduino
1/* This code works with motion sensor, when motion detects it will automatic 2 call on number which is in code. 3 * For more videos please visit our youtube 4 channel. https://www.youtube.com/channel/UCsn5KGbvt5Se7MaLsfNYthA 5 */ 6 7#include 8 <SoftwareSerial.h> 9 10SoftwareSerial sim800l(2, 3); // RX,TX for Arduino and 11 for the module it's TXD RXD, they should be inverted 12 13#define Motion_Sensor 14 A0 //Button pin, on the other pin it's wired with GND 15bool Sensor_State; //Sensor_State 16 17 18void 19 setup() 20{ 21 22 pinMode(Motion_Sensor, INPUT); //The button is always on 23 HIGH level, when pressed it goes LOW 24 sim800l.begin(9600); //Module baude 25 rate, this is on max, it depends on the version 26 Serial.begin(9600); 27 28 delay(1000); 29} 30 31void loop() 32{ 33 34//SendSMS(); 35 Sensor_State 36 = digitalRead(Motion_Sensor); //We are constantly reading the button State 37 38 39 if (Sensor_State == HIGH) { //And if it's pressed 40 Serial.println("Sensor 41 detect motion"); //Shows this message on the serial monitor 42 delay(200); 43 //Small delay to avoid detecting the button press many 44 times 45 46 SendSMS(); //And this function is 47 called 48delay(4000); 49 50 } 51 else{ 52 Serial.println("."); 53 } 54 55 56 if (sim800l.available()){ //Displays on the serial monitor if there's 57 a communication from the module 58 Serial.write(sim800l.read()); 59 } 60} 61 62 63void SendSMS() 64{ 65 Serial.println("Sending SMS..."); //Show 66 this message on serial monitor 67 sim800l.print("AT+CMGF=1\ "); //Set 68 the module to SMS mode 69 delay(100); 70 sim800l.print("AT+CMGS=\\"+###############\\"\ "); 71 //Your phone number don't forget to include your country code, example +212123456789" 72 73 delay(500); 74 sim800l.print("Security Alert.....!!!!!!! Some one entered in 75 the house "); //This is the text to send to the phone number, don't make 76 it too long or you have to modify the SoftwareSerial buffer 77 delay(500); 78 79 sim800l.print((char)26);// (required according to the datasheet) 80 delay(500); 81 82 sim800l.println(); 83 Serial.println("Text Sent."); 84 delay(500); 85 86}
Downloadable files
home_security_i3i9fBiUtw.jpg
home_security_i3i9fBiUtw.jpg
Comments
Only logged in users can leave comments
munir03125344286
0 Followers
•0 Projects
2
0