By Abdul Rehman
In this article we are going to implement a real time location tracking system with NEO GPS and a SIM800 GSM module. This is for the intention to track location of your vehicle or any other thing that you want to track and want to know the position on your mobile phone. There are many other possibilities to do the same, one of which is by using some IoT platform like ESP8266 or ESP32 to implement the same tracker with the live Firebase based location coordinates update. But in today’s tutorial all we going to do is to send the GPS coordinates via GSM module and to a specific number.
Note: If you are in Pakistan, you may need to register your GSM module with the PTA.
Here is the complete code for the Arduino GPS Tracker with the above mentioned parts. You can compile this code after installing the required libraries which are mentioned in the above list. Once you downloaded and installed the libraries of SoftwareSerial and TinyGPS++ you are ready to upload the code after compiling into the Arduino Board. You can use Arduino UNO or Arduino Nano or even Arduino micro pro etc. Here is the complete code
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
TinyGPSPlus gps;
SoftwareSerial gpsSerial(4, 3);
SoftwareSerial gsmSerial(6, 7);
void setup() {
Serial.begin(9600);
gpsSerial.begin(9600);
gsmSerial.begin(9600);
delay(3000);
gsmSerial.print("AT+CGNSPWR=1\r\n");
delay(100);
}
void loop() {
while (gpsSerial.available()) {
gps.encode(gpsSerial.read());
}
if (gps.location.isUpdated()) {
String lat = String(gps.location.lat(), 6);
String lng = String(gps.location.lng(), 6);
sendLocation(lat, lng);
delay(30000);
}
}
void sendLocation(String lat, String lng) {
String command = "AT+HTTPPARA=\"URL\",\"http://yourserver.com/location.php?lat=" + lat + "&lng=" + lng + "\"\r\n";
gsmSerial.print(command);
delay(100);
}
Code language: PHP (php)
Key Functions:
setup()
: Initializes GPS and GSM modulesloop()
: Reads GPS data and sends locationsendLocation()
: Sends latitude and longitude to the serverTips:
This code-centric guide demonstrates how to build an Arduino GPS tracker with real-time location tracking using NEO-6M GPS and SIM800L GSM modules. By following the provided code and connections, you can create a functional GPS tracker for various applications.
19 April 2023
07 April 2023
07 April 2023
FYP Solutions Powered By Impressive Business WordPress Theme