CAR POWER LOCK BY GSM

In this project we try to combine several modules to make a power lock for the car. This application is useful when our car is robbed by people, so just leave the car and all passengers are released. When the car is taken away by the robber, when the distance of the car is safe (if the robber returns to the crime scene we are not there and have fled to the nearest police station or ask for resident help), then we miss call to the number installed on GSM module, the car will turn off automatically. When the car turn off because we miss a call it cannot be turned on again, to turn on again it must use RFID.

Power lock GSM

const int ledPin = 5;//this signal go to relay or mosfet or for drive triac
#include <EEPROM.h>
int addr = 0;
byte value;

#include <SoftwareSerial.h>
char inchar; // Will hold the incoming character from the GSM shield
//SoftwareSerial SIM900(7, 8);//RX,TX
const int pinRxNano = 7;
// Rx of A6 linked to pin 8
const int pinTxNano = 8;
const String phoneNumber= “+97433187702”;
const String messageInit = “A6 ready”;
SoftwareSerial A6GSM(pinRxNano, pinTxNano);
int numring=0;
int comring=1;
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();
}

#include <SPI.h>
#include <MFRC522.h>

#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
MFRC522::MIFARE_Key key;

void setup() {
Serial.begin(9600);
SPI.begin(); // Initiate SPI bus
mfrc522.PCD_Init(); // Initiate MFRC522
//RFID.begin(9600);
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, HIGH);
A6GSM.begin(9600);
Serial.begin(9600);
delay(200);
Serial.println(“Init”);
//AT
startAT();
//envoieSMS(phoneNumber,messageInit);
}
void(* resetFunc) (void) = 0;
void doSomething()
{
value = EEPROM.read(addr);
if (value==0)
{
digitalWrite(ledPin, HIGH);
delay(10000); //delay 10 minutes
EEPROM.write(addr, 1);
}
//resetFunc();
}
void loop(){
value = EEPROM.read(addr);
if(A6GSM.available() >0)
{
inchar=A6GSM.read();
if (inchar==’R’)
{
delay(10);
inchar=A6GSM.read();
if (inchar==’I’)
{
delay(10);
inchar=A6GSM.read();
if (inchar==’N’)
{
delay(10);
inchar=A6GSM.read();
if (inchar==’G’)
{
delay(10);
numring++;
Serial.println(“ring!”);
if (numring==comring)
{
numring=0; // reset ring counter
doSomething();
}
}
}
}
}
}
else {
value = EEPROM.read(addr);
if (value==1){
digitalWrite(ledPin, LOW);
}
Serial.println(value);
}
//===========================================================

if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
//Show UID on serial monitor
Serial.print(“UID tag :”);
String content= “”;
byte letter;
for (byte i = 0; i < mfrc522.uid.size; i++)
{
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? ” 0″ : ” “);
Serial.print(mfrc522.uid.uidByte[i], HEX);
content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? ” 0″ : ” “));
content.concat(String(mfrc522.uid.uidByte[i], HEX));
}
Serial.println();
Serial.print(“Message : “);
content.toUpperCase();
//if ((content.substring(1) == “76 5C A8 BB”) || (content.substring(1) == “A0 D1 39 83” )) //change here the UID of the card/cards that you want to give access
if (content.substring(1) == “76 5C A8 BB”)// single card
{
Serial.println(“Authorized access”);
EEPROM.write(addr, 0);
//Stored_Tag_ID=””;
//Parsed_Tag_ID=””;
resetFunc(); //call reset
}

}

3 thoughts on “CAR POWER LOCK BY GSM

      1. Your idea is great, but I cannot compile the code. Can you help me improve this project?

        Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s