FONA 808 GPS Tracker

Hi,
I am making a GPS tracker using Arduino Uno and a Adafruit FONA808 shield.

I want it to text me the GPS latitude and longitude, however it sends the the text ‘webaddress,latitude,longitude’ instead of the values.

Please Help.

Kindest Regards,
Denis

Here is my code below.

#include "Adafruit_FONA.h"

// standard pins for the shield, adjust as necessary
#define FONA_RX 2
#define FONA_TX 3
#define FONA_RST 4

// We default to using software serial. If you want to use hardware serial
// (because softserial isnt supported) comment out the following three lines 
// and uncomment the HardwareSerial line
#include <SoftwareSerial.h>
SoftwareSerial fonaSS = SoftwareSerial(FONA_TX, FONA_RX);
SoftwareSerial *fonaSerial = &fonaSS;

// Hardware serial is also possible!
//  HardwareSerial *fonaSerial = &Serial1;

Adafruit_FONA fona = Adafruit_FONA(FONA_RST);

// Have a FONA 3G? use this object type instead
//Adafruit_FONA_3G fona = Adafruit_FONA_3G(FONA_RST);


void setup() {

  while (! Serial);

  Serial.begin(115200);
  Serial.println(F("Adafruit FONA 808 & 3G GPS demo"));
  Serial.println(F("Initializing FONA... (May take a few seconds)"));

  fonaSerial->begin(4800);
  if (! fona.begin(*fonaSerial)) {
    Serial.println(F("Couldn't find FONA"));
    while(1);
  }
  Serial.println(F("FONA is OK"));
  // Try to enable GPRS
  

  Serial.println(F("Enabling GPS..."));
  fona.enableGPS(true);
}

void loop() {
  delay(2000);

  float latitude, longitude, speed_kph, heading, speed_mph, altitude;

  // if you ask for an altitude reading, getGPS will return false if there isn't a 3D fix
  boolean gps_success = fona.getGPS(&latitude, &longitude, &speed_kph, &heading, &altitude);

  char webaddress [] = ("https://www.google.com/maps/place/");
  char sendto[21] = "my phone number";
  char message[141] = "webaddress,latitude,longitude";
  if (gps_success) {

    Serial.print("GPS lat:");
    Serial.println(latitude, 6);
    Serial.print("GPS long:");
    Serial.println(longitude, 6);
    Serial.print("GPS speed KPH:");
    Serial.println(speed_kph);
    Serial.print("GPS speed MPH:");
    speed_mph = speed_kph * 0.621371192;
    Serial.println(speed_mph);
    Serial.print("GPS heading:");
    Serial.println(heading);
    Serial.print("GPS altitude:");
    Serial.println(altitude);
    Serial.println(message);
    Serial.println();
            if (!fona.sendSMS(sendto,message)) {
          Serial.println(F("Failed"));
        } else {
          Serial.println(F("Sent!"));
        }
        delay(600000);

  } else {
    Serial.println("Waiting for FONA GPS 3D fix...");
  }

  // Fona 3G doesnt have GPRSlocation :/
  if ((fona.type() == FONA3G_A) || (fona.type() == FONA3G_E))
    return;
  // Check for network, then GPRS 
  Serial.println(F("Checking for Cell network..."));
  if (fona.getNetworkStatus() == 1) {
    // network & GPRS? Great! Print out the GSM location to compare
    boolean gsmloc_success = fona.getGSMLoc(&latitude, &longitude);

    if (gsmloc_success) {
      Serial.print("GSMLoc lat:");
      Serial.println(latitude, 6);
      Serial.print("GSMLoc long:");
      Serial.println(longitude, 6);
    } else {
      Serial.println("GSM location failed...");
      Serial.println(F("Disabling GPRS"));
      fona.enableGPRS(false);
      Serial.println(F("Enabling GPRS"));
      if (!fona.enableGPRS(true)) {
        Serial.println(F("Failed to turn GPRS on"));  
      }
    }
  }

}

I am making a GPS tracker using Arduino Uno and a Adafruit FONA808 shield.

You and millions of others. Surely someone has actually gotten the project to work.

void loop() {
  delay(2000);

Well, that's silly.

  char message[141] = "webaddress,latitude,longitude";

            if (!fona.sendSMS(sendto,message)) {

Personally, I'd be tempted to use sprintf() to formulate the message to send, instead of expecting some genie with a rusty lamp to make some magic happen.

Hi,
Thankyou for your quick reply.
I am still unsure as to which bit I need to edit from your comment.

Apologies, this is my first time coding (aside from a little matlab).
I have put this together from stuff I found online.

Kind Regards,
Denis

I am still unsure as to which bit I need to edit from your comment.

Do you really want to send the message you have defined, containing the constant string “webaddress,latitude,longitude”? Or, do you want to use something like sprintf() to construct the data to send, from some variables named webaddress, latitude, and longitude?

Be warned that sprintf() doesn’t support the %f format specifier, so getting floats into you message is a two step process. First, you convert the float to a string using dtostrf(), then you get the string into your message using sprintf() and the %s format specifier.