Sending a GPS location by SMS
Now that we have the location part working correctly, we can start building our GPS tracking projects for secret agents. The first project will simply use the location and send it via SMS to the phone number of your choice.
As the sketch is quite similar to previous one, I'll only show which parts changed compared to the location test sketch. We first need to define the phone number where you want to send the tracking data to:
char * sendToNumber = "123456789";
After getting the location just as in the previous section, we can now build the message that we will send via SMS:
char messageToSend[140]; String message = "Current GPS location: " + latitude + "," + longitude; message.toCharArray(messageToSend, message.length());
Using the FONA instance, it's very easy to actually send the SMS to the number we defined earlier:
if (!fona.sendSMS(sendToNumber, messageToSend)) { Serial.println(F("Failed to send SMS")); } else { Serial.println(F("Sent location data!"));...