indeed it is pin 0 and 1 and not 0 and 2. I fixed that.
The gps sends information exactly like the post I referred to. I copy that one here as I prefer not to share my gps location with "the big bad internet"
$GPRMC,150111.000,A, 4551.8988 ,N, 01211.8911 ,E,0.00,263.77,110612,,,D6B
$GPRMC,150112.000,A, 4551.8988 ,N, 01211.8911 ,E,0.00,263.77,110612,,,D68
$GPRMC,150113.000,A, 4551.8988 ,N, 01211.8911 ,E,0.00,263.77,110612,,,D69
$GPRMC,150114.000,A, 4551.8988 ,N, 01211.8911 ,E,0.00,263.77,110612,,,D6E
$GPRMC,150115.000,A, 4551.8988 ,N, 01211.8911 ,E,0.00,263.77,110612,,,D6F
$GPRMC,150116.000,A, 4551.8988 ,N, 01211.8911 ,E,0.00,263.77,110612,,,D6C
$GPRMC,150118.000,A, 4551.8988 ,N, 01211.8911 ,E,0.00,263.77,110612,,,D*62
For me also the time and the checksum change but the location remains the same -even going 100 meters away does not change the position-.
I stopped looking for the root cause and I ordered new gps breakout boards.
I'm still interested in a workaround and/or people having the same experience.
This is the cpp code of the basic gps class
#include "gps_Library.h"
GPSModule::GPSModule(long gpsRate, SERIALTYPE *serial)
: m_LastMessageTimeStamp(0)
{
m_LastMessageLocation.myLatitude = 0;
m_LastMessageLocation.myLongitude = 0;
m_LastMessageDirection = 0;
m_LastMessageSpeed = 0;
bufferidx = 0;
buffer[0] = 0;
LastFixMessage = 0;
m_LastMessageIsfix = false;
m_gpsSerial = serial;
m_gpsRate = gpsRate;
}
void GPSModule::setup()
{
(*m_gpsSerial).begin(m_gpsRate);
SHOW_DEBUG_INFO_LN(DEBUGLEVEL_GPS_BUSINESS, "GPS initialized");
}
// read a Hex value and return the decimal equivalent
uint8_t parseHex(char c)
{
if (c < '0') return 0;
if (c <= '9') return c - '0';
if (c < 'A') return 0;
if (c <= 'F') return (c - 'A') + 10;
return 0;
}
void GPSModule::loop()
{
char ReceivedChar;
uint8_t sum;
int InBuffer;
while ((InBuffer = (*m_gpsSerial).available()) > 0)
{
ReceivedChar = (*m_gpsSerial).read();
if (ReceivedChar=='\r') ReceivedChar=' ';
buffer[bufferidx++] = ReceivedChar;
buffer[bufferidx] = 0; //terminate with 0
if ((ReceivedChar == '
Best regards
Jantje) & (bufferidx != 1))
{
SHOW_DEBUG_INFO_VAR_LN(DEBUGLEVEL_GPS_TRACE, buffer);
SHOW_DEBUG_INFO_STRING_LN(DEBUGLEVEL_GPS_TRACE, "ERROR: start of new line received in message");
bufferidx = 0;
buffer[bufferidx++] = ReceivedChar;
buffer[bufferidx] = 0; //terminate with 0
}
if (ReceivedChar == '\n') // the message is complete
{
buffer[bufferidx - 1] = 0;
SHOW_DEBUG_INFO_VAR_LN(DEBUGLEVEL_GPS_TRACE, buffer);
if (buffer[bufferidx - 5] != '*')
{
// no checksum?
SHOW_DEBUG_INFO_STRING_LN(DEBUGLEVEL_GPS_TRACE, "ERROR: there is no checksum in the message");
bufferidx = 0;
return;
}
// get received checksum
sum = parseHex(buffer[bufferidx - 4]) * 16;
sum += parseHex(buffer[bufferidx - 3]);
// check checksum
for (int i = 1; i < (bufferidx - 5); i++)
{
sum ^= buffer[i];
}
if (sum != 0)
{
SHOW_DEBUG_INFO_STRING_LN(DEBUGLEVEL_GPS_TRACE, "ERROR: received checksum is wrong");
bufferidx = 0;
return;
}
// got good data!
if (strstr(buffer, "GPRMC"))
{
parseGPRCMessage();
if (m_LastMessageIsfix)
{
LastFixMessage = millis();
}
processGPRMCMessage();
}
bufferidx = 0;
}
if (bufferidx == BUFFSIZE - 1)
{
SHOW_DEBUG_INFO_STRING_LN(DEBUGLEVEL_GPS_TRACE, "ERROR: received message that is longer than the buffer");
bufferidx = 0;
}
}
}
GPSDIRECTION GPSModule::getLastMessageDirection() const
{
return m_LastMessageDirection;
}
GPSLocation GPSModule::getLastMessageLocation() const
{
return m_LastMessageLocation;
}
GPSSPEED GPSModule::getLastMessageSpeed() const
{
return m_LastMessageSpeed;
}
DateTime GPSModule::getLastMessageTimeStamp() const
{
return m_LastMessageTimeStamp;
}
boolean GPSModule::hasReception() const
{
unsigned long Curtime = millis();
return (((LastFixMessage + 5000) > Curtime) && ((m_LastMessageLocation.myLatitude + m_LastMessageLocation.myLongitude) != 0));
}
void GPSModule::parseGPRCMessage()
{
m_LastMessageLocation.myLatitude = 0;
m_LastMessageLocation.myLongitude = 0;
m_LastMessageSpeed = 0;
m_LastMessageDirection = 0;
//extract the time
const char *p = buffer;
p = strchr(p, ',') + 1;
uint8_t hour = (p[0] - '0') * 10 + (p[1] - '0');
p += 2;
uint8_t minutes = (p[0] - '0') * 10 + (p[1] - '0');
p += 2;
uint8_t seconds = (p[0] - '0') * 10 + (p[1] - '0');
// find out if we got a fix
p = strchr(p, ',') + 1;
if (p[0] != 'A')
{
m_LastMessageIsfix = false;
//DateTime dt(0, 0, 0, hour, minutes, seconds);
}
else
{
m_LastMessageIsfix = true;
//extract the latitude
p = strchr(p, ',') + 1;
m_LastMessageLocation.myLatitude = (p[0] - '0') * 10 + (p[1] - '0');
p += 2;
while (p[0] != ',')
{
if (p[0] != '.') m_LastMessageLocation.myLatitude = m_LastMessageLocation.myLatitude * 10 + (p[0] - '0');
p++;
}
p++;
if (p[0] == 'S') m_LastMessageLocation.myLatitude *= -1;
//extract the longitude
p += 2;
m_LastMessageLocation.myLongitude = (p[0] - '0') * 100 + (p[1] - '0') * 10 + (p[2] - '0');
p += 3;
while (p[0] != ',')
{
if (p[0] != '.') m_LastMessageLocation.myLongitude = m_LastMessageLocation.myLongitude * 10 + (p[0] - '0');
p++;
}
p += 2;
if (p[0] == 'W') m_LastMessageLocation.myLongitude *= -1;
p += 1;
//extract speed
int Power = 1000;
int Count = 1;
while (p[0] != ',')
{
if (p[0] != '.')
{
m_LastMessageSpeed = m_LastMessageSpeed * 10 + (p[0] - '0');
Power /= (Count);
} else
{
Count = 10;
}
p++;
}
//The speed is in knots (1.852 km per hour = 1852 m per hour) so calculate to m/hour
m_LastMessageSpeed = m_LastMessageSpeed * 1852 * Power;
p += 1;
Power = 1000;
Count = 1;
while (p[0] != ',')
{
if (p[0] != '.')
{
m_LastMessageDirection = m_LastMessageDirection * 10 + (p[0] - '0');
Power /= Count;
} else
{
Count = 10;
}
p++;
}
m_LastMessageDirection = m_LastMessageDirection * Power;
p += 1;
uint8_t m_day = (p[0] - '0') * 10 + (p[1] - '0');
uint8_t m_month = (p[2] - '0') * 10 + (p[3] - '0');
uint8_t m_year = (p[4] - '0') * 10 + (p[5] - '0');
DateTime dt(m_year, m_month, m_day, hour, minutes, seconds);
m_LastMessageTimeStamp = dt;
}
}
Best regards
Jantje