Hi guys ive got a problem I cant seem to solve I have a GPS module Ublox NEO-6M GPS connected to an arduino nano and a 24x4 LCD display via i2C everything is working fine but I cant seem to get it to display the latitude, longitude the way I want it to im using the TinyGPSPlus-0.94b library.
At the minute it displays:
Lat: 28.240047
Lon:-16.837272
Sh4d0w-M4ster:
At the minute it displays:
Lat: 28.240047
Lon:-16.837272
I need it to display the coordinates like:
28°14'24.1692" N
016°50'14.1792" W
Arduino 'float' and 'double' variables are only accurate to 6-7 significant digits and NOT 8 significant digits when using 8-bit controllers like UNO or MEGA. Only 32-bit controllers like DUE can use a higher accuracy with 'double' variables.
Taking somewhat inaccurate float values from your library and then doing some more float calculations you can get something like:
Most GPS devices are not more accurate than up to 5 meters. How much loss of accuracy due to conversion is acceptable? 1 centimeter or 1 meter?
If you want to keep full NMEA accuracy of your GPS module, DON'T MILL YOUR DATA THROUGH A LIBRARY THAT STRIPS THE ACCURACY DOWN TO 'float' ACCURACY, but get the data from the NMEA sentences directly!
made a first version of an angle class recently which might be useful. There is still some work in the backlog but it has the conversion in place. The conversion minimizes the use of floating point math to prevent precision loss. The code to look at is in the constructor of Angle(), you can extract it.
Please note that the Angle Class has 3 decimals for the seconds (thousands) where you seem to want 4. That needs a small refactor of the code to support (however the float format of Arduino UNO is limiting still).
Maybe it, or something like it, would be useful in your Angle library.
(The version I made could probably use a bit of polishing up, I admit, especially with angles whose sines are close to +1.0 or -1.0.)
I just noticed that, as you now have it, your Angle class has a serious bug.
How would you differentiate between, say, an angle of +0°30'00" and an angle of -0°30'00" ?
If it were me, I would (naturally) use odometer-style rollover of minutes and seconds, and convert for display. (Example: -0°10'20" would be internally stored as -1 degree, 49 minutes, 40 seconds.)
Lucky for us, this is the 21st century, and we have cheap electronics.
Video of an older solution to this problem: Mechanical Counter Video #1 - YouTube