Brijesh Singh
Published © GPL3+

Door Security System Using Gboard Pro

Build your own easy GSM-based SMS door security project using the Arduino Mega Clone, Gboard Pro (GSM cum Arduino Mega).

BeginnerFull instructions provided3 hours696
Door Security System Using Gboard Pro

Things used in this project

Hardware components

Itead Gboard Pro SIM900 GSM / GPRS ATMega2560
×1
MC-38 Wired Magnetic Switch sensor
×1
Resistor 1k ohm
Resistor 1k ohm
×1
Resistor 330 ohm
Resistor 330 ohm
×1
5 mm LED: Red
5 mm LED: Red
×1
12V DC Adatper
×1
SIM card
supported Quad-band 850/900/1800/1900 Mhz (in project 2G SIM used)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Project Circuit Diagram

Code

DoorSecurityProject_Code

Arduino
/*************************************************************
 * Equivalent arduino pins of GboardPro
 * EB0 - A0    for magnetic sensor
 * TX1 - 18    for status led
 * more details of Gboard: https://www.itead.cc/wiki/Gboard_Pro
 ************************************************************/
 
#include <GSM_Shield.h>

char number[]="+91xxxxxxxxxx";  //Destination number 

GSM gsm;

int error;

int doorSwitch_sensor = A0;
byte cnt = 1;

#define statusled 18
#define simpwr 46
#define simrst 47

void setup() 
{
  pinMode(statusled, OUTPUT);
  digitalWrite(statusled, LOW); //logic low means ON
  delay(500);
  
  Serial.begin(9600);
  pinMode(doorSwitch_sensor, INPUT);
  pinMode(simpwr, OUTPUT);
  pinMode(simrst, OUTPUT);

  Serial.println("sim Power ON"); 
  digitalWrite(simpwr,HIGH);
  delay(1000);
  
  digitalWrite(statusled, HIGH); //logic low means ON
  delay(1000);
  digitalWrite(statusled, LOW); //logic low means ON
  delay(500);
  digitalWrite(statusled, HIGH); //logic low means ON
  delay(1000);
  digitalWrite(statusled, LOW); //logic low means ON
  delay(500);
  
  //digitalWrite(simrst,HIGH);
  //delay(2000);
  Serial.println("system startup"); 
  gsm.TurnOn(9600);          //module power on
  gsm.InitParam(PARAM_SET_1);//configure the module  
  gsm.Echo(0);               //enable AT echo 
  digitalWrite(statusled, LOW); //logic low means ON
  delay(1);
  sendSMSFunction("Device ON!");
  Serial.println("Device Ready");
}


void loop()
{  
  int i=0;
  
  int buttonState = digitalRead(doorSwitch_sensor);
  if((buttonState==1) && (cnt==1)){
      //Serial.println("Door Opened!");
      sendSMSFunction("Door Opened!");
      cnt = 0;
    }

  if((buttonState == 0) && (cnt==0)){
      //Serial.println("Door Closed!");
      sendSMSFunction("Door Closed!");
      cnt = 1;    
    }
  // print out the state of the button:
  Serial.println(buttonState);
  delay(1000);        // delay in between reads for stability     
}  

void sendSMSFunction(char msg[]){
      digitalWrite(statusled, HIGH); //logic low means ON
      delay(500);
      digitalWrite(statusled, LOW); //logic low means ON
      delay(100);
      digitalWrite(statusled, HIGH); //logic low means ON
      delay(500);
      digitalWrite(statusled, LOW); //logic low means ON
      delay(100);
      digitalWrite(statusled, HIGH); //logic low means ON
      delay(500);
      
      strcpy(text, msg);
      Serial.print("Send SMS to ");
      Serial.print(number);
      Serial.print("   ");
      Serial.println(text);
      error=gsm.SendSMS(number,text);  
      if (error==0)  //Check status
      {
         Serial.println("SMS ERROR \n");
      }
      else
      {
         Serial.println("SMS OK \n");             
      }
  
  }
  

Credits

Brijesh Singh
23 projects • 38 followers
Utilizing the spare time to Make and Share DIY Electronics and IoT projects with the online maker community.
Contact

Comments

Please log in or sign up to comment.