Integrating GSM 900A and GPS NEO-6M with Arduino to Send SMS Location URLs
In this blog post, we’ll walk you through how to integrate the GSM 900A module and the GPS NEO-6M module with an Arduino to send SMS messages containing map location URLs. By the end of this project, your system will be capable of sending the real-time GPS location of your device to a predefined phone number.
Components Required
- Arduino Uno (or any compatible board)
- GSM 900A module
- GPS NEO-6M module
- SIM card (with SMS plan activated)
- Jumper wires
- Breadboard (optional)
- Power supply for GSM and Arduino
Wiring Diagram
Before proceeding, let’s connect the components:
GSM 900A Connections:
- VCC→ 5V (External power supply preferred)
- GND→ GND
- RX→ Arduino Pin 2
- TX→ Arduino Pin 3
GPS NEO-6M Connections:
- VCC→ 3.3V or 5V
- GND→ GND
- TX→ Arduino Pin 4
- RX→ Arduino Pin 5
Ensure to use a common ground for all modules.
Arduino Code
Here’s the Arduino code for integrating both modules. This script will:
- Fetch GPS coordinates.
- Create a Google Maps URL.
- Send the URL via SMS using the GSM 900A module.
#include <SoftwareSerial.h>
// GSM and GPS pins
SoftwareSerial gsm(2, 3); // GSM RX, TX
SoftwareSerial gps(4, 5); // GPS RX, TX
String latitude = "";
String longitude = "";
void setup() {
  Serial.begin(9600);
  gsm.begin(9600);
  gps.begin(9600);
  Serial.println("Initializing...");
  // Initialize GSM module
  gsm.println("AT");
  delay(1000);
  gsm.println("AT+CMGF=1"); // Set SMS mode to text
  delay(1000);
  
  Serial.println("Initialization complete.");
}
void loop() {
  if (gps.available()) {
    String gpsData = gps.readStringUntil('\n');
    
    if (gpsData.startsWith("$GPGGA")) {
      parseGPSData(gpsData);
      sendLocationSMS();
      delay(30000); // Wait 30 seconds before next SMS
    }
  }
}
void parseGPSData(String data) {
  int latIndex = data.indexOf(",", 18) + 1;
  int latEndIndex = data.indexOf(",", latIndex);
  int longIndex = data.indexOf(",", latEndIndex + 1) + 1;
  int longEndIndex = data.indexOf(",", longIndex);
  latitude = convertToDecimalDegrees(data.substring(latIndex, latEndIndex));
  longitude = convertToDecimalDegrees(data.substring(longIndex, longEndIndex));
  Serial.print("Latitude: ");
  Serial.println(latitude);
  Serial.print("Longitude: ");
  Serial.println(longitude);
}
String convertToDecimalDegrees(String coord) {
  if (coord.length() < 10) return "0.0";
  
  String degrees = coord.substring(0, 2);
  String minutes = coord.substring(2);
  float decimalDegrees = degrees.toFloat() + (minutes.toFloat() / 60);
  return String(decimalDegrees, 6);
}
void sendLocationSMS() {
  if (latitude != "" && longitude != "") {
    String message = "Location: https://www.google.com/maps?q=" + latitude + "," + longitude;
    
    gsm.println("AT+CMGS=\"+1234567890\""); // Replace with your phone number
    delay(1000);
    gsm.print(message);
    delay(1000);
    gsm.write(26); // ASCII code for CTRL+Z
    delay(5000);
    Serial.println("SMS Sent: " + message);
  }
}
Working Principle
- The GPS module continuously sends NMEA sentences to the Arduino.
- The script extracts the latitude and longitude from the $GPGGAsentence.
- The extracted coordinates are converted into decimal degrees format.
- A Google Maps URL is generated.
- The GSM module sends the URL as an SMS to the specified phone number.
Sample Output
Serial Monitor:
Initializing...
Latitude: 37.774929
Longitude: -122.419416
SMS Sent: Location: https://www.google.com/maps?q=37.774929,-122.419416
SMS Received:
Location: https://www.google.com/maps?q=37.774929,-122.419416
Images
- Wiring Diagram
- The sms comes in phone looks like this
Troubleshooting Tips
- GPS Module Not Responding: Ensure the GPS module has a clear view of the sky.
- GSM Module Not Sending SMS: Verify SIM card functionality and ensure sufficient balance.
- Data Parsing Issues: Double-check the $GPGGAformat for your GPS module.
With this project, you can now track the location of your device and receive real-time updates via SMS. Feel free to customize and expand this project based on your requirements. Happy coding!



 
0 Comments