shhavel
Published © GPL3+

GSM Alarm

Sending SMS every time the door was opened.

BeginnerFull instructions provided8,394
GSM Alarm

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Arduino GSM shield V2
Arduino GSM shield V2
×1
SIM card
×1
Reed switch
×1
Resistor 10k ohm
Resistor 10k ohm
×1
Jumper wires (generic)
Jumper wires (generic)
×1
9V battery (generic)
9V battery (generic)
×1
9V to Barrel Jack Connector
9V to Barrel Jack Connector
×1

Story

Read more

Schematics

GSM Alarm Prototype

Prototype on actual board.

Code

GSM Alert Sketch

Arduino
// Sending an SMS every time when the garage door was opened.
// Use reed switch to monitor door state (open/closed).
#include <GSM.h>
#define REED_SWITCH_PIN 6
#define PINNUMBER "" // SIM card PIN
#define RECIPIENT_NUMBER "+380987654321" // Replace with your telephone number.

GSM gsmAccess; 
GSM_SMS sms;
bool notConnected = true;
bool opened = false;

void setup() {
  pinMode(REED_SWITCH_PIN, INPUT);

  // Start GSM shield.
  // If your SIM has PIN, pass it as a parameter of begin() in quote.
  while(notConnected) {
    if (gsmAccess.begin(PINNUMBER) == GSM_READY) {
      notConnected = false;
    } else {
      delay(1000);
    }
  }
}

void loop() {
  // There are two types of reed switches: NO (normally open) and NC (normally closed).
  // Normal state means the state when the switch is not under the influence of a magnet.
  // Closed - conducts current. Open - does not conduct current.
  // So for NO switch HIGH means the door is closed (switch is near the magnet).
  // For NC switch HIGH means the door is opened (switch is far from the magnet).
  // You can use both types of reed switches, but update the check accordingly.
  // NO reed switch consumes more energy in this circuit,
  // but when someone maliciously cuts the wires, an SMS will be sent.

  // This check is for NO (normally open) reed switch.
  if (digitalRead(REED_SWITCH_PIN) == HIGH) { // the door is closed
    opened = false;
  } else if (!opened) { // the door was just opened (the door is open and previously it was closed)
    opened = true;
    // send SMS
    sms.beginSMS(RECIPIENT_NUMBER);
    sms.print("Garage door was open.");
    sms.endSMS();
    // 15 minutes break
    delay(900000);
  }
}

Credits

shhavel

shhavel

1 project • 3 followers

Comments