Introduction: Car Tracking Device

About: Ahmed Abd El-Moniem is an aerospace engineer at CUFE, fond of aeronautical space technology and satellites, a project leader at space system technology laboratory, cooperator at a home automation company and …

There is always a need to protect your belongings specially your car, put your things are safe in some place, on the other hand your car is left in the streets. Consequently, this project will help you to track your car and know its location by only calling a specific number ( actually your car number ) and you will recieve an email and SMS on your mobile phone that tell you where your car is. There are some simple features that may be helpful for your such as:

- watching who is inside your car by sending a message with one word (camera).

- If you park your car you can activate "park-mode", so if the car moves you will recieve a message and an email that tell you that your car is moving.

- Sometimes the driver wants to save the route, for this sake "save-route" feature has been implemented. By sending a simple message the trip will be saved in a .CSV file format, moreover by utilizing Google fusion tables the user will be able to plot the trip on the map. In my opinion this feature will be of a great value for transport companies.

- One of the amazing features is "HELP" function, which provides the driver with some built-in help instructuions, this option can be initialized when the user states 'help' and the device will recognize the help word and starts to call the emergancy number, sends SMS and updates your Facebook status to ask for help.

Step 1: Project Components

Step 2: Connection Scheme and Software

2. Open Arduino IDE

3. Download arduino sketch code then press upload

/*
* Car tracking device project * This project shows an application on 1Sheeld. *

* Created on: August 20, 2016 * Author: Ahmed Abd el Moniem * Email: ahmed_abd_el_moniem@yahoo.com *

* ================================================================== */ /* Macros & Typedefs & defines */ /* ================================================================== */

#define CUSTOM_SETTINGS #define INCLUDE_GPS_SHIELD #define INCLUDE_SMS_SHIELD #define INCLUDE_EMAIL_SHIELD #define INCLUDE_PHONE_SHIELD #define INCLUDE_CAMERA_SHIELD #define INCLUDE_ACCELEROMETER_SENSOR_SHIELD #define INCLUDE_DATA_LOGGER_SHIELD #define INCLUDE_FACEBOOK_SHIELD #define INCLUDE_VOICE_RECOGNIZER_SHIELD

/* =================================================================== */ /* Include Files */ /* =================================================================== */ #include

/* =================================================================== */ /* Global Variables Declarations */ /* =================================================================== */ /*define variable for Gps latitude data*/ float latitude; /*define variable for GPS longitude data*/ float longitude; /*array of char to save latitude in string form*/ char stringLatitude[12]; /*array of char to save longitude in string form*/ char stringLongitude[12]; /*array of char to concatinate the final sending message*/ char message[80]; /*counter to control logging data every specified time*/ char counter=0; /*a string to compare if the user send sms that includes (location word)*/ char* recievedMessage1= "location"; /*a string to compare if the user send sms that includes (camera word)*/ char* recievedMessage2= "camera"; /*a string to compare if the user send sms that includes (parkMode word)*/ char* recievedMessage3= "parkMode"; /*a string to compare if the user send sms that includes (stopParking word)*/ char* recievedMessage4= "stopParking"; /*a string to compare if the user send sms that includes (saveRoad word)*/ char* recievedMessage5= "saveRoad"; /*a string to compare if the user send sms that includes (stopSaving word)*/ char* recievedMessage6= "stopSaving"; /*a string to compare if the user uses the voice recognizer to say (help word)*/ const char helpCommand[] = "help"; /*your country emergancy number (the number to call when you are in the car and need help)*/ char emergencyNumber[]= "01116301164"; /*a flag to be sure the message was sent for one time only*/ boolean phoneFlag= true; /*a flag to be sure the message was sent for one time only*/ boolean smsFlag= true; /*a flag to be sure the message was sent for one time only*/ boolean cameraFlag= true; /*a flag to be sure that the user run the parking mode*/ boolean parkingModeFlag= false; /*a flag to be sure the message was sent for one time only*/ boolean movingFlag= true; /*a flag to be sure that the user run the (save-road mode)*/ boolean saveRoadFlag= false;

void setup() { /*start communication with one sheeld*/ OneSheeld.begin(); /*save and close the old logger file*/ Logger.stop(); /*start the voice recognition*/ VoiceRecognition.start(); }//setup

void loop() { /**************** Accessing the car location data *****************/

/*there are two ways to get the car information, either call the car or send * sms with location word as a message content*/ /*check if the phone is ringing*/ if(Phone.isRinging()) { /*check if the message was sent before or not*/ if(phoneFlag) { /*call the function that send the car location to the user*/ SendingDataToUser(); /*prevent the message to be sent two times*/ phoneFlag= false; }//second if }//first if else { /*active calling the sendingDataToUser function again*/ phoneFlag= true; }//else /*check if the recieved message content is location word*/ if(strcmp(SMS.getSms(),recievedMessage1)==0) { /*check if the message was sent before or not*/ if(smsFlag) { /*call the function that send the car location to the user*/ SendingDataToUser(); /*prevent the message to be sent two times*/ smsFlag= false; }//second if }//first if else { /*active calling the sendingDataToUser function again*/ smsFlag= true; }//else

/*************************** camera feature ************************/

/* here the user will send sms with a camera word as a message content then the code will take a photo * to the inside view of the car and send an email to you with the photo*/

/*check if the recieved message content is camera word*/ if(strcmp(SMS.getSms(),recievedMessage2)==0) { /*check if the email was sent before or not*/ if(cameraFlag) { /*Turn on the camera flash.*/ Camera.setFlash(ON); /*Take the picture.*/ Camera.rearCapture(); /*Wait for 10 seconds.*/ OneSheeld.delay(10000); /*send photo*/ Email.attachLastPicture("ahmedtarad9@gmail.com","Who in the car!" ,"the view inside your car" , 0 ); /*prevent the email to be sent two times*/ cameraFlag= false; }//second if }//first if else { /*active the camera feature again*/ cameraFlag= true; }//else

/************************ parking feature ************************/

/* Parking Mode is a feature to help the car owner to know if the car moves when it should be in the parking ** which means someone stole your car. ** when the user send sms with word parkMode as a message content the code will check the accelerometer ** reading in y direction and if the car moves the user will recieve a message.*/

/*check if the recieved message content is parkMode word*/ if(strcmp(SMS.getSms(),recievedMessage3)==0) { /*active parking mode*/ parkingModeFlag= true; }//if

/*check if the recieved message content is stopParking word*/ if(strcmp(SMS.getSms(),recievedMessage4)==0) { /*deactive parking mode*/ parkingModeFlag= false; }//if

/*check the mode status*/ if(parkingModeFlag) { /*check the acceleration value in y direction*/ if(abs(AccelerometerSensor.getY()) > 1.5 ) { /*check if the message was sent before or not*/ if(movingFlag) { /*send sms*/ SMS.send("01116301164","your car is moving!"); /*send email*/ Email.send("ahmedtarad9@gmail.com","parking Mode" ,"your car is moving!"); /*prevent the email and sms to be sent two times*/ movingFlag= false; }//third if }//second if else { /*active parking mode*/ movingFlag= true; }//else }//first if /************************ logging road data ***********************/

/* sometimes the driver wants to save the road in an csv file and use it after to plot the road ** on google maps. ** so here if the user send a message to active blogging GPS data the code will save the location until ** recieving another message to stop blogging*/

/*check if the recieved message content is saveRoad word*/ if(strcmp(SMS.getSms(),recievedMessage5)==0) { /*run logging data mode*/ saveRoadFlag= true; }//if /*check if the recieved message content is stopSaving word*/ if(strcmp(SMS.getSms(),recievedMessage6)==0) { /*stop blogging data mode*/ saveRoadFlag= false; }//if

/*check if the mode is active*/ if(saveRoadFlag) { /*using counter to save one point every 20 code loop*/ if(counter==20) { /*create file with name RoadMap*/ Logger.start("RoadMap"); /*log GPS data*/ Logger.add("Latitude", GPS.getLatitude()); /*log GPS data*/ Logger.add("Longitude", GPS.getLongitude()); /*move to the new line*/ Logger.log(); /*wait for one second*/ OneSheeld.delay(1000); /*reset the counter*/ counter=0; }//second if /*increment the counter*/ counter++; }//first if else { /*stop and save the file*/ Logger.stop();

}//else

/************************ help feature *************************/ /* here if the user say help at any emergancy time, the code will call the police number, ** send a message and post on Facebook to ask for help*/

/*Check if new command received.*/ if(VoiceRecognition.isNewCommandReceived()) { /*check if the recoginzed word is help*/ if(!strcmp(helpCommand,VoiceRecognition.getLastCommand())) { /*call the emergency number*/ Phone.call(emergencyNumber); /*send sms*/ SMS.send("01116301164","help me!"); /*update Facebook status*/ Facebook.post("help me!"); }//second if }//first if

}//void loop

/* =================================================================== */ /* Function Declarations */ /* =================================================================== *

** * \brief This function gets the gps coordinates and send them the user using email * and sms. * * \param void * * \return none * * \note Here we get the pgs coordinates as a float numbers then convert them to * string and concatinate our message then send this message by Email and sms */ void SendingDataToUser(void) { /*get latitude from GPS*/ latitude= GPS.getLatitude(); /*get longitude from GPS*/ longitude= GPS.getLongitude(); /*convert latitude from float to string*/ dtostrf(latitude, 7, 5, stringLatitude); /*convert longitude from float to string*/ dtostrf(longitude, 7, 5, stringLongitude); /*start to concatinate the final message in string type*/ strcat(message,"Car Location: \n"); strcat(message,"Latitude is: "); strcat (message,stringLatitude); strcat(message,"\nLongitude is: "); strcat (message,stringLongitude); /*send email with car location*/ Email.send("ahmedtarad9@gmail.com","car location" ,message); /*send sms with car location*/ SMS.send("01116301164",message);

}//SendingDataToUser

Step 3: Get Your Smartphone Ready

1. Get 1 sheeld app from google play or Apple store

2. Open 1 sheeld app

3. Scan for 1 sheeld

4. Select GPS, SMS, Email, Phone, Camera, Accelerometer,Data logger, Facebook and Voice recognizer

5. Wait for call or SMS

Step 4: the Expected Output

Phone SMS and The recieved Emails

Step 5: Get Your Car Location

Once you recieve your car coordinates you can see your car location using

http://www.gps-coordinates.net/

Step 6: Instructions to Using the Logging Data

If you log the GPS data, you will be able to plot it on map using Google fusion tables as you can see in the following steps.

First select Google Fusion Table from google drive

Step 7: Upload Your CSV File

pick the saved CSV file from your mobile phone and upload it on google fusion

Step 8: Show Your Route on the Map

Click on "Map of latitude" tab and click on the point to see its own coordinates