Hackster is hosting Hackster Holidays, Ep. 7: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 7 on Friday!
akssil-ga
Published

GSM based security system

Using the GSM module to build a security system capable of making calls in case of detection of danger ( using ultrasonic)

IntermediateFull instructions provided5 hours1,485
GSM based security system

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Arduino GSM shield V2
Arduino GSM shield V2
×1
LED (generic)
LED (generic)
×2
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×1
AA Batteries
AA Batteries
×1
JS Series Switch
C&K Switches JS Series Switch
×1
Resistor 100 ohm
Resistor 100 ohm
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Extraction Tool, Souriau Trim Trio Contacts
Extraction Tool, Souriau Trim Trio Contacts

Story

Read more

Schematics

The circuit diagram

Code

The code of this project is shown below

C/C++
#include <SoftwareSerial.h>
#include <Arduino.h>
SoftwareSerial mySerial(2, 3);

int RedLedPin=11;
int GreenLedPin=12;
float distance;
int tpin=7;
int epin=8;
float ptt;

void setup() {

Serial.begin(115200);
mySerial.begin(115200);
Serial.println("initializing..");
delay(10);
mySerial.println("AT");
delay(1000);
pinMode(tpin,OUTPUT);
pinMode(epin,INPUT);
pinMode(11,OUTPUT);
pinMode(12,OUTPUT);


}



void loop() { // put your main code here, to run repeatedly://updateSerial();
    measuringDistance();
    Serial.println(distance);
   if((distance<=10) && (distance!=0))
   {
     
     digitalWrite(RedLedPin,1);
    digitalWrite(GreenLedPin,0);
    
    

    TopFunction();

   }
   else{
     digitalWrite(11,0);
     digitalWrite(12,1);
    
   }
  
 

void measuringDistance()
{
   
digitalWrite(tpin,LOW);
delay(2);
digitalWrite(tpin,HIGH);
delay(10);
digitalWrite(tpin,LOW);
ptt=pulseIn(epin,HIGH);
distance= 0.034*ptt/2;
delay(100);
return distance;
}

void TopFunction()
{
readSerial();
}
 String readSerial()
{
  delay(10);
  if( mySerial.available())
  {
    return  mySerial.readString();
  } CallNumber();
  
}
void CallNumber()
{
  delay(100);
 mySerial.println("ATD+xxxxxxxxxx;");   // your phone number 
 Serial.println(readSerial());
 delay(20000);
 mySerial.println("ATH");
 delay(200);
 Serial.println(readSerial());
}

Credits

akssil-ga
5 projects • 5 followers
wameedh scientific club

Comments