This circuit integrates an Arduino UNO microcontroller with a SIM900A GSM module and a GPS NEO 6M module to create a GPS tracking system that can send location data via SMS. The Arduino UNO serves as the central processing unit, interfacing with the GPS module to receive location coordinates and with the GSM module to send the coordinates as an SMS message. The GPS module provides the location data, while the GSM module enables cellular communication.
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
TinyGPSPlus gps;
SoftwareSerial gpsSerial(4, 3); // GPS Module RX, TX
SoftwareSerial gsmSerial(7, 8); // GSM Module RX, TX
void setup() {
Serial.begin(9600);
gpsSerial.begin(9600);
gsmSerial.begin(9600);
}
void loop() {
while (gpsSerial.available()) {
gps.encode(gpsSerial.read());
if (gps.location.isUpdated()) {
String latitude = String(gps.location.lat(), 6);
String longitude = String(gps.location.lng(), 6);
String locationMessage = "Latitude: " + latitude + ", Longitude: " + longitude;
Serial.println(locationMessage);
sendSMS(locationMessage);
delay(10000);
}
}
}
void sendSMS(String message) {
gsmSerial.print("AT+CMGS=\"+21650751921\"\r");
delay(1000);
gsmSerial.print(message);
delay(1000);
gsmSerial.write(26); // ASCII code for Ctrl+Z
delay(1000);
Serial.println("SMS Sent");
}
Note: The code provided is for the Arduino UNO microcontroller. It initializes two software serial ports for communication with the GPS and GSM modules, reads GPS data, constructs a location message, and sends it via SMS. The phone number in the sendSMS
function is hardcoded and should be replaced with the desired recipient's number.