PIR SENSOR HC-SR501 THIEF ALARM WITH A6 GSM MODULE

PIR alarm A6

//remove RX and TX jumper from arduino when uploading sketch
int pirPin = 5;
int statePir = 0;
char phone_no[]=”+97433188802″;
void setup()
{
pinMode(pirPin,INPUT);
Serial.begin(9600);

}

void loop()
{
statePir = digitalRead(pirPin);
if (statePir == HIGH)
{
call();
}
if (statePir == LOW)
{

}
}

void call(){
Serial.println(“AT”);
delay(1000);
Serial.print(“ATD”);
Serial.println(phone_no);
delay(10000);
Serial.println(“ATH”);
}

 

OTHER CONFIGURATION

PIR alarm A6 serial

int pirPin = 5;
int statePir = 0;
//char phone_no[]=”+97433188802″;
#include <SoftwareSerial.h>
char inchar; // Will hold the incoming character from the GSM shield
// Tx of A6 linked to pin 7
const int pinRxNano = 7;
// Rx of A6 linked to pin 8
const int pinTxNano = 8;
const String phoneNumber= “+97433188802”;
const String messageInit = “A6 ready”;
SoftwareSerial A6GSM(pinRxNano, pinTxNano);
int numring=0;
int comring=3;
int onoff=0; // 0 = off, 1 = on
void Response(){
int a = 0;
Serial.println();
while(1){
if(A6GSM.available()){
String dataFromA6 =A6GSM.readString();
dataFromA6.trim();
Serial.println(dataFromA6);
a++;
if(dataFromA6.indexOf(“OK”)>0){break;}
}
if(a>500){a=0;break;}
delay(200);
}
}
void startAT(){
int nbAT = 0;
while(1){
if (nbAT==0){A6GSM.println(“AT”);Serial.print(“.”);}
if(A6GSM.available()){
String dataFromA6 =A6GSM.readString();
dataFromA6.trim();
Serial.println(dataFromA6);
if(dataFromA6.indexOf(“OK”)>0){break;}
}
delay(200);
nbAT++;
if(nbAT++>10){nbAT=0;}
}
}
void envoieSMS(String numeroEnvoi, String messageEnvoi) {
delay(200);
Serial.println(“Selection format message SMS”);
A6GSM.println(“AT+CMGF=1”);
Response();
delay(200);
Serial.println(“Envoi message SMS”);
A6GSM.print(“AT+CMGS=\””);
A6GSM.print(numeroEnvoi);
A6GSM.println(“\””);
delay(200);
A6GSM.print(messageEnvoi);
delay(200);
A6GSM.println (char(26));
Response();
}
void setup()
{
pinMode(pirPin,INPUT);
//Serial.begin(9600);
A6GSM.begin(9600);
Serial.begin(9600);
delay(200);
Serial.println(“Init”);
//AT
startAT();
//envoieSMS(phoneNumber,messageInit);

}

void loop()
{
statePir = digitalRead(pirPin);
if (statePir == HIGH)
{
call();
}
if (statePir == LOW)
{

}
}

void call(){
A6GSM.println(“AT”);
delay(1000);
A6GSM.print(“ATD”);
A6GSM.println(phoneNumber);
delay(10000);
A6GSM.println(“ATH”);
}