Hello all,
I have a question about sending GPS data via SMS. I am using the SIM800l module and the NEO-6m and I am trying to send an SMS with the GPS data. However, this does not work somehow. Although an SMS is sent, it does not contain any GPS data, but "0.000000" is displayed in the SMS.
This below is my code. Maybe you have an idea what exactly is wrong. Thank you!
#include "SoftwareSerial.h"
#include <TinyGPS++.h>
#define PIN_RESET 3
#define PIN_TX 5
#define PIN_RX 6
#define PIN_RXD 7
#define PIN_TXD 8
const char TELEFONE_NUMBER[] = "XXxxxxxxxxxx";
SoftwareSerial mySerial(PIN_TX, PIN_RX);
SoftwareSerial gpsSerial(PIN_RXD, PIN_TXD);
TinyGPSPlus tinyGps;
void setup()
{
pinMode(PIN_RESET, OUTPUT);
digitalWrite(PIN_RESET, HIGH);
Serial.begin(9600);
mySerial.begin(9600);
gpsSerial.begin(9600);
Serial.println("Initializing...");
delay(1000);
// Once the handshake test is successful, it will back to OK
mySerial.println("AT");
updateSerial();
// Configuring TEXT mode
mySerial.println("AT+CMGF=1");
updateSerial();
mySerial.println("AT+CMGS=\""+String(TELEFONE_NUMBER)+"\"");
updateSerial();
// SMS text content
mySerial.print("latitude: ");
mySerial.println(tinyGps.location.lat(), 6);
mySerial.print("longitude: ");
mySerial.println(tinyGps.location.lng(), 6);
updateSerial();
mySerial.write(26);
}
void loop() {}
void updateSerial()
{
delay(200);
while (Serial.available()) {
// Forward what Serial received to Software Serial Port
mySerial.write(Serial.read());
}
while(mySerial.available()) {
// Forward what Software Serial received to Serial Port
Serial.write(mySerial.read());
}
}