Hello friends,
I am trying to make a GPS locator with a GSM module, if you sent ”Location?” To the arduino you’ll get a response like this: http://maps.google.com/place/3.38,5.39
But as you might noticed there are only 2 decimals by the coordinates. Can I make this 6 decimals?
Yours sincerely,
Arjan Pals
My code:
# include <NeoSWSerial.h>
#include "TinyGPS++.h"// include GPS library
NeoSWSerial serial_connection(3, 4); //RX=pin 10, TX=pin 11
TinyGPSPlus gps;
String totalString;
String GoogleMaps= "HTTP://maps.google.com/place/"
double Lat = 3.38493856;//some test coordinates, so i don't have to connect my gps module for trying
double Lon = 5.39374758;
String receivedSMS;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
SENDSMS(); //this is for testing the string.
// put your main code here, to run repeatedly:
while (Serial.available() == 0){
}
receivedSMS=(Serial.readString());
if (receivedSMS=="Location?"){
GETGPS();
SENDSMS();
}
else{
//do nothing and wait for another sms
}
}
void GETGPS(){
uint8_t GPSchar;
while (1)
{
if (serial_connection.available() > 0)
{
GPSchar = serial_connection.read();
gps.encode(GPSchar);
// Serial.write(GPSchar);
}
if (gps.location.isUpdated() && gps.altitude.isUpdated())
{
break;
}
}
Lat = (gps.location.lat(),6);
Lon = (gps.location.lng(),6);
}
void SENDSMS() {
totalString = GoogleMaps+(Lat,6)+","+(Lon,6);// when i print this one there are only 2 decimals
Serial.print("AT+CMGS=\"+316********\"");
delay(200);
Serial.print(totalString);
// Serial.println(Lat, 6); //when i print this one, there are 6 decimals
}