CONTENTS GSM and GPS based Vehicle Tracking system using Arduino - Working WORKING Circuit Diagram
GSM and GPS based Vehicle Tracking system using Arduino - Working
WORKING Hardware Components: Arduino microcontroller, GPS Receiver (SKG13BL), GSM module (SIM900A), optional 16x2 LCD. Functionality Overview: GPS Receiver detects vehicle coordinates, while GSM module sends coordinates to the user via SMS. Initiating Tracking: Send a specific SMS message (e.g., "Track Vehicle") to the system installed in the vehicle. Message Processing: GSM module receives the SMS and forwards it to Arduino. Arduino extracts the main message and compares it with predefined triggers. Response Generation: Upon match, Arduino extracts coordinates from GPS data and sends them to the user via GSM module. By following these steps, the system enables real-time tracking of the vehicle's location, providing users with accurate coordinates upon request via SMS.
Circuit Diagram
Software Implementation Software Tool Used: Arduino Ide The Arduino Integrated Development Environment is a programming software that will be your interface between your Arduino board and the program. The Arduino IDE software has a compiler that will transform your program into a machine language understandable by the Arduino board.
CODE: #include < SoftwareSerial.h > #include < TinyGPS.h > TinyGPS gps ; //Creates a new instance of the TinyGPS object float lat = -1.6848579,lon = 37.1690756; SoftwareSerial mySerial (9, 10); //RX and TX pins respectively. void setup() { mySerial.begin (9600); // Setting the baud rate of GSM Module Serial.begin (9600); // Setting the baud rate of Serial Monitor (Arduino) Serial.println ("Welcome."); Serial.println ("......................"); Serial.println (); delay(100); }
void loop() { if (Serial.available()>0) switch(Serial.read()) { case 's': case 'S': mySerial.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode delay(1000); // Delay of 1 second mySerial.println("AT+CMGS=\"+2547********\"\r"); //mobile number to send a text to
delay(1000); Serial.println(); Serial.println("Name: Jane Katelembo"); Serial.println("......................"); Serial.println("Your location...."); Serial.println(gps_connect()); Serial.println("......................"); Serial.println("Total Quantity Consumed."); Serial.println("Water: 75m3"); Serial.println("......................"); Serial.println("The water flow rate is 45m/s");// The SMS text you want to send
Serial.println("......................"); Serial.println("Total Monthly Charges"); Serial.println("Ksh 456.79"); Serial.println(); delay(100); mySerial.println((char)26);// ASCII code of CTRL+Z for saying the end of sms to the module delay(1000); break; case 'r': case 'R': mySerial.println("AT+CNMI=2,2,0,0,0"); // AT Command to receive a live SMS delay(1000); break;
} if (mySerial.available()>0) Serial.write(mySerial.read()); } float gps_connect() { while (Serial.available()) { // check for gps data if (gps.encode(Serial.read())) // encode gps data { gps.f_get_position(&lat, &lon); // get latitude and longitude // display position } } String latitude = String(lat, 6); String longitude = String(lon, 6); Serial.println("Latitude: " + latitude + "," "Longitude: " + longitude); delay(1000); } void loop() { if (Serial.available() > 0) { switch (Serial.read()) { case 's': case 'S': sendSMS(); break; } }
if (mySerial.available() > 0) { Serial.write(mySerial.read()); } } void sendSMS() { mySerial.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode delay(1000); // Delay of 1 second mySerial.println("AT+CMGS=\"+2547********\"\r"); //mobile number to send a text to delay(1000); Serial.println(); Serial.println("Name: Jane Katelembo");
Serial.println ("......................"); Serial.println ("Your location...."); String location = getGPSLocation (); Serial.println (location); Serial.println ("......................"); Serial.println ("Total Quantity Consumed."); Serial.println ("Water: 75m3"); Serial.println ("......................"); Serial.println ("The water flow rate is 45m/s");// The SMS text you want to send Serial.println ("......................"); Serial.println ("Total Monthly Charges"); Serial.println (" Ksh 456.79");
Serial.println(); delay(100); mySerial.println((char)26);// ASCII code of CTRL+Z for saying the end of sms to the module delay(1000); } String getGPSLocation() { float lat = -1.6848579, lon = 37.1690756; // Default coordinates while (Serial.available()) { // check for gps data if (gps.encode(Serial.read())) // encode gps data { gps.f_get_position(&lat, &lon); // get latitude and longitude // display position } } String latitude = String(lat, 6); String longitude = String(lon, 6); return "Latitude: " + latitude + ", Longitude: " + longitude; }