I'm using python to read data from a u-blox NEO-M9N chip via i2c on my raspberry Pi.
For the moment, I haven't built the rest of the script but I'm a little confused by the output of the chip as it seems to include characters that don't belong there, such as °,¬, or Á. Sometimes those seem to be replacements for characters that look alike: 021120 is correct for a few lines and then is replaced by 0²1±20, which is not too far away.
The sentences might be correct for anything between 5 to 50 lines and then I'll get something like this (I've replaced part of the GPS coordinates with X but you get it):
$GNRMC,204107.00,A,XX.20¶46,N,XX.47371,E,0.844,,021±20,,,A,V*17
$GNRMC,204108.00¬A,XX.20603,N,XX.47454,E,0.921,,021120,,,A,V*1B
Any idea to what this could be due? I'm very sure this will mess up what I want to with the data afterwards...
Here the code I'm using to read the data:
import time
import json
import smbus
import logging
BUS = None
address = 0x42
gpsReadInterval = 0.1
LOG = logging.getLogger()
# taken and (poorly) adapted from
# http://ava.upuaut.net/?p=768
def connectBus():
global BUS
BUS = smbus.SMBus(1)
def parseResponse(gpsLine):
gpsChars = ''.join(chr(c) for c in gpsLine)
if "GNRMC" not in gpsChars:
return False
print(gpsChars)
def readGPS():
c = None
response = []
try:
while True: # Newline, or bad char.
c = BUS.read_byte(address)
if c == 255:
return False
elif c == 10:
break
else:
response.append(c)
parseResponse(response)
except IOError:
time.sleep(0.5)
connectBus()
connectBus()
while True:
readGPS()
time.sleep(gpsReadInterval)
For posterity, someone has solved it for me: Fix special characters with closest equivalent without map
It is indeed a hardware issue but it can be fixed via software using this guy's answer