Hello,
I'm not a newbie, but I'm capable of doing silly mistakes. If so, please forgive me.
First of all, I'm trying to get information from neo6mv2 gps with TinyGPS library with reading other sensors. I'm using Mega, so GPS is on Serial1. If I print whatever I get from Serial1 to Serial, I can get raw data from GPS without errors. However, when I use TinyGPS in the main program, I can't get latitude, longtitude and altitude. Time and date is correct (after fix, of course), but location data is always 0.
Therefore, data is never updated after first correct read.
I searched a lot but if this is a repost, it is because I couldn't find it, not because I didn't look.
I found one possible explanation that Serial1 may be overflowed. I tried to flush it after every correct read but it didn't change anything.
What could be the problem? Please help.
The relevant code is below.
I used a library and the instance is gps.
In the .ino file:
if (gps.gpsReady){
if (Serial1.available()){
gps.readGPS(Serial1.read());
}
}
In my library (I used structs, the gps... are, I beleive, correct):
void gpsSensor::readGPS(unsigned char input) {
if (gpsParser.encode(input)){
gps.altitude = gpsParser.altitude.meters();
gps.latitude = gpsParser.location.lat();
gps.longtitude = gpsParser.location.lng();
gps.speed = gpsParser.speed.kmph();
gps.date.day = gpsParser.date.day();
gps.date.month = gpsParser.date.month();
gps.date.year = gpsParser.date.year();
gps.time.hour = gpsParser.time.hour();
gps.time.minute = gpsParser.time.minute();
gps.time.second = gpsParser.time.second();
Serial1.flush();
}
}
The output from serial window is:
GPS Altitude: 0.00
GPS Latitude: 0.00
GPS Longtitude: 0.00
GPS Speed: 0.00
GPS Day: 6
GPS Month: 10
GPS Year: 2014
GPS Hour: 1
GPS Minute: 12
GPS Second: 0
Thanks in advance.