Gps,sim800l send a sms with link

Hi guys, if I send a sms with link I cannot receive the link but is says SMS Sent and when I remove the link I can receive the sms I wonder what is the problem this is my code and I'm using arduino mega

#include <TinyGPS++.h>

// Define pins for GPS module
#define GPS_TX_PIN 17 // Connect GPS TX to Arduino TX2 (pin 17)
#define GPS_RX_PIN 16 // Connect GPS RX to Arduino RX2 (pin 16)

String phoneNumber = "xxxxxxxxx"; // Enter your phone number here
String url = "https://www.google.com/maps?q=";

// Create GPS object
TinyGPSPlus gps;

void setup() {
  // Initialize serial communication
  Serial.begin(9600); // USB serial
  Serial1.begin(9600); // GSM serial
  Serial2.begin(9600); // GPS serial

  Serial.println("System Initializing...");
  delay(10000); // Allow time for systems to stabilize

  // Initialize GSM module
  Serial1.println("AT");
  delay(1000);
  while (Serial1.available()) {
    Serial.write(Serial1.read());
  }
  Serial1.println("AT+CMGF=1"); // Set SMS mode to text
  delay(1000);
}

void loop() {
  // Read GPS data
  while (Serial2.available()) {
    if (gps.encode(Serial2.read())) {
      // Check if GPS data is valid
      if (gps.location.isValid()) {
        printGPSData(); // Print GPS data and send SMS
      }
    }
  }
}

void printGPSData() {
  // Check if GPS data is valid
  if (gps.location.isValid()) {
    // Get latitude and longitude
    float latitude = gps.location.lat();
    float longitude = gps.location.lng();

    // Print latitude and longitude
    Serial.print("Latitude: ");
    Serial.println(latitude, 6);
    Serial.print("Longitude: ");
    Serial.println(longitude, 6);

    // Send SMS with Google Maps link
    sendSMS(latitude, longitude);
  }
}

void sendSMS(float latitude, float longitude) {
  // Send SMS
  Serial1.println("AT+CMGF=1"); // Set SMS mode to text
  delay(1000);

  Serial1.print("AT+CMGS=\"");
  Serial1.print(phoneNumber);
  Serial1.println("\"");
  delay(1000);

  // Construct the message including latitude, longitude, and URL
  String message = "Latitude: " + String(latitude, 6) + "\nLongitude: " + String(longitude, 6) + "\nURL: " + url + latitude + "," + longitude;

  // Send the message
  Serial1.print(message);
  delay(1000);

  Serial1.write(0x1A); // End SMS
  delay(1000);

  // Print confirmation
  Serial.println("SMS Sent");
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.