I'm trying to develop a program to capture coordinates through the GPS module and send the information to a concatenated url server, which will handle the information and display my location through the Google Maps API, but at first I'm testing the sending the coordinates by SMS to a specific number, but I'm having a problem receiving the GPS signal, where the coordinates are coming down, and it's not capturing my real location. It is worth mentioning that I have already done individual tests in both the GPS module and the GSM Shield, and all the two work independently, the problem appears when trying to join the two components. Here is the code below:
void setup()
{
// Serial PC <-> Arduino
Serial.begin(19200);
// GsM Arduino <-> GSM
GsM.begin(19200);
// GpS Arduino <-> GPS
GpS.begin(9600);
}
void loop()
{
envia_sms_gps();
}// end loop
// Funções Gerais
// Envia SMS com link google maps de localização e avisa a tentativa de furto
void envia_sms_gps()
{
displayGPSInfo();
// Envia SMS https://maps.google.com.br/maps?q=(LAT),(LON)
delay(300);
GsM.print("AT+CMGF=1"); //mandando SMS em modo texto
delay(1000);
GsM.print("AT + CMGS = \"" + num +"\""); // numero que vamos mandar o SMS
delay(1000);
GsM.println(data);
Serial.println(data);
delay(1000);
GsM.write(0x1A);
data="";
delay(300);
}
// Faz leitura do GPS e pega as coordenadas lat e long, converte os valores float para string e concatena com link do google maps
void displayGPSInfo()
{
if(gps.location.isValid())
{
dado_lat=gps.location.lat();
dado_lng=gps.location.lng();
dtostrf(dado_lat,4,4,lat_aux);
latParaString = String(lat_aux);
dtostrf(dado_lng,4,4,lng_aux);
lngParaString = String(lng_aux);
data+=(server);
data+=(latParaString);
data+=",";
data+=(lngParaString);
}
delay(300);
}
Below is the output of the program in Serial Monitor: