I know that @mohit and @Dave have both done a bunch of Asset Tracker projects with mapping onto Google Maps and might be able to clear this up.
That does not qualify as a proper test, since the search engines might do some "translation" for you - they are quite good in guessing what you meant even if you didn't spell it absolutely correct, but APIs are less forgiving
Sometimes libraries will give you “degrees minutes seconds” style outputs, but what you really want is decimal degrees. There are ways to convert this, but I think you can just ask TinyGPS for float / decimal degree coordinates:
#
# from: http://arduiniana.org/libraries/tinygps/
#
// returns +/- latitude/longitude in degrees
gps.f_get_position(&flat, &flon, &fix_age);
float falt = gps.f_altitude(); // +/- altitude in meters
float fc = gps.f_course(); // course in degrees
float fk = gps.f_speed_knots(); // speed in knots
float fmph = gps.f_speed_mph(); // speed in miles/hr
float fmps = gps.f_speed_mps(); // speed in m/sec
float fkmph = gps.f_speed_kmph(); // speed in km/hr
I hope that helps!
Thanks,
David
The format that I’m getting is DD MM.SSSS, is there a way to convert that to decimal?
I googled the formula, but it doesn’t work.See the pictures below its about 10 miles off.
Decimal value = Degrees + (Minutes/60) + (Seconds/3600)
If you put +28 38.5417’,-81 56.3664’ in to google you get the following decimal:
28.6483,-819435
The correct formula is DD + (MM.SSSS/60), If DD is negative then multiply by -1.
I believe you have a sign issue. The formula is DD + (MM.SSSS/60)
but for all positive values, with the sign corrected afterwards. So 81 + (56.3664 / 60) = 81 + 0.93944 = 81.939944, then make it negative.
28.64236,-81.93994
Oh…yeah…I always forget the darn sign! Thanks for the catching that!
Hi
I have, like some others, a problem with TinyGPS giving me only 0,0,0,0 return.
For information, I use a Ublox M8N ( with only NMEA output done in U-center) and try to use TinyGPS on my Particle Photon 0.5.3.
As you could see, I very slighlty change the Gps.ino in the Web IDE, inorder to debug .( see my gps.ino)
I also found a good NMEA sentences ( I think ) , but I have still 0,0,0,0 for the “szInfo” ( see “putty.log” serial results )
I suspect a problem in the gps.encode in the TinyGPS.cpp that only return a gps.encode©= False, but I can’t find the solution .
Thanks, if you could help me .
I want to thank whomever got the tinyGPS.h include file and library working on the Photon / Spark Core. Probably @peekay123. I was having a terrible time getting the Grove Seeedstudio GPS working. There main information page was not very useful.
http://wiki.seeed.cc/Grove-GPS/
The only thing I learnt was to switch the board TX to Photon RX and vice versa.
TinyGPS library worked out of the box. I made a few changes to add altitude, km per hour, and direction (North = 0 East=90)
Here is my (not very pretty) code:
// This #include statement was automatically added by the Particle IDE.
#include <TinyGPS.h>
TinyGPS gps;
float lat, lon;
unsigned long age;
char szInfo[64];
// Every 15 minutes
//int sleep = 15 * 60 * 1000;
void setup(){
Serial1.begin(9600);
Particle.publish("Startup may take a few minutes", " Try going outside ");
}
void loop(){
bool isValidGPS = false;
for (unsigned long start = millis(); millis() - start < 1000;){
// Check GPS data is available
while (Serial1.available()){
char c = Serial1.read();
// parse GPS data
if (gps.encode(c))
isValidGPS = true;
}
}
// If we have a valid GPS location then publish it
if (isValidGPS){
gps.f_get_position(&lat, &lon, &age);
Particle.publish("altitude in meters =", String(gps.f_altitude(), 0));
Particle.publish("Direction N=0 E=90", String(gps.f_course(), 0));
Particle.publish("Km per hour", String(gps.f_speed_kmph(), 2));
delay(1000);
lat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : lat;
lon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : lon;
Particle.publish("Longitude =", String(lon));
delay(10);
Particle.publish("Lattiude =", String(lat));
delay(10);
// sprintf(szInfo, "%.6f,%.6f", (lat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : lat), (lon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : lon));
}
else{
// Not a vlid GPS location, jsut pass 0.0,0.0
// This is not correct because 0.0,0.0 is a valid GPS location, we have to pass a invalid GPS location
// and check it at the client side
// sprintf(szInfo, "0.0,0.0");
}
//Spark.publish("gpsloc", szInfo);
delay(1000);
Particle.publish("Put into Google Maps", String(String(lat) + ", " + String(lon)) );
Particle.publish("- ", "- ");
// Sleep for some time
delay(5000);
}
So I then drove around with my photon using my cell phone hotspot and got live driving data that in the console looks sort of like:
If you like TinyGPS, you may like TinyGPS++ library even more
https://build.particle.io/libs/TinyGPS++/0.9.4
Anyone know what the default altitude is with TinyGPS. I just assumed meters but my values don’t make a lot of sense. Anyone have any idea? The TinyGPS.cpp file shows this code. Which divides the unknown measurement by 100
float TinyGPS::f_altitude()
{
return _altitude == GPS_INVALID_ALTITUDE ? GPS_INVALID_F_ALTITUDE : _altitude / 100.0;
}
…
I just tried google maps altitude and it looks like meters is the correct value (with about ±5m of error) So I guess the raw value is cm.
Just found out that
Particle.publish("Hi","Goodbye");
defaults to PUBLIC so for testing purposes probably better to use
Particle.publish("hi","Goodbye", 60, PRIVATE);
for all Particle.publish commands unlike the code I pasted above.