Components and supplies
1
9V battery (generic)
1
Reed switch
1
Jumper wires (generic)
1
9V to Barrel Jack Connector
1
SIM card
1
Arduino GSM shield V2
1
Resistor 10k ohm
1
Arduino UNO
Project description
Code
GSM Alert Sketch
arduino
1// Sending an SMS every time when the garage door was opened. 2// Use reed switch to monitor door state (open/closed). 3#include <GSM.h> 4#define REED_SWITCH_PIN 6 5#define PINNUMBER "" // SIM card PIN 6#define RECIPIENT_NUMBER "+380987654321" // Replace with your telephone number. 7 8GSM gsmAccess; 9GSM_SMS sms; 10bool notConnected = true; 11bool opened = false; 12 13void setup() { 14 pinMode(REED_SWITCH_PIN, INPUT); 15 16 // Start GSM shield. 17 // If your SIM has PIN, pass it as a parameter of begin() in quote. 18 while(notConnected) { 19 if (gsmAccess.begin(PINNUMBER) == GSM_READY) { 20 notConnected = false; 21 } else { 22 delay(1000); 23 } 24 } 25} 26 27void loop() { 28 // There are two types of reed switches: NO (normally open) and NC (normally closed). 29 // Normal state means the state when the switch is not under the influence of a magnet. 30 // Closed - conducts current. Open - does not conduct current. 31 // So for NO switch HIGH means the door is closed (switch is near the magnet). 32 // For NC switch HIGH means the door is opened (switch is far from the magnet). 33 // You can use both types of reed switches, but update the check accordingly. 34 // NO reed switch consumes more energy in this circuit, 35 // but when someone maliciously cuts the wires, an SMS will be sent. 36 37 // This check is for NO (normally open) reed switch. 38 if (digitalRead(REED_SWITCH_PIN) == HIGH) { // the door is closed 39 opened = false; 40 } else if (!opened) { // the door was just opened (the door is open and previously it was closed) 41 opened = true; 42 // send SMS 43 sms.beginSMS(RECIPIENT_NUMBER); 44 sms.print("Garage door was open."); 45 sms.endSMS(); 46 // 15 minutes break 47 delay(900000); 48 } 49} 50
GSM Alert Sketch
arduino
1// Sending an SMS every time when the garage door was opened. 2// Use 3 reed switch to monitor door state (open/closed). 4#include <GSM.h> 5#define 6 REED_SWITCH_PIN 6 7#define PINNUMBER "" // SIM card PIN 8#define RECIPIENT_NUMBER 9 "+380987654321" // Replace with your telephone number. 10 11GSM gsmAccess; 12GSM_SMS 13 sms; 14bool notConnected = true; 15bool opened = false; 16 17void setup() { 18 19 pinMode(REED_SWITCH_PIN, INPUT); 20 21 // Start GSM shield. 22 // If your 23 SIM has PIN, pass it as a parameter of begin() in quote. 24 while(notConnected) 25 { 26 if (gsmAccess.begin(PINNUMBER) == GSM_READY) { 27 notConnected = 28 false; 29 } else { 30 delay(1000); 31 } 32 } 33} 34 35void loop() 36 { 37 // There are two types of reed switches: NO (normally open) and NC (normally 38 closed). 39 // Normal state means the state when the switch is not under the influence 40 of a magnet. 41 // Closed - conducts current. Open - does not conduct current. 42 43 // So for NO switch HIGH means the door is closed (switch is near the magnet). 44 45 // For NC switch HIGH means the door is opened (switch is far from the magnet). 46 47 // You can use both types of reed switches, but update the check accordingly. 48 49 // NO reed switch consumes more energy in this circuit, 50 // but when someone 51 maliciously cuts the wires, an SMS will be sent. 52 53 // This check is for NO 54 (normally open) reed switch. 55 if (digitalRead(REED_SWITCH_PIN) == HIGH) { // 56 the door is closed 57 opened = false; 58 } else if (!opened) { // the door 59 was just opened (the door is open and previously it was closed) 60 opened = 61 true; 62 // send SMS 63 sms.beginSMS(RECIPIENT_NUMBER); 64 sms.print("Garage 65 door was open."); 66 sms.endSMS(); 67 // 15 minutes break 68 delay(900000); 69 70 } 71} 72
Downloadable files
Prototype on actual board.
Prototype on actual board.

GSM Alarm Prototype
GSM Alarm Prototype

GSM Alarm Prototype
GSM Alarm Prototype

Comments
Only logged in users can leave comments