Junk data received from UART

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
PierreDeQuebec
 
Posts: 96
Joined: Sun Jul 25, 2021 3:26 pm

Junk data received from UART

Post by PierreDeQuebec »

Hi,

I have a setup with an Ultimate GPS Logging Shield board mounted on a Metro M4 AirLift Lite board. The assembly works well with a baud rate of 9600 bauds for the UART. The UART is connected in 'Hardware Serial' mode as it should be. But for other possible baud rate values, I get 'Unicode Error' error messages with garbage data similar to this:

Code: Select all

UnicodeError
b'\x10\x0c\x92\x90\x92l\x12bp\x82\x0cb\x1cl\x8c\x8e\x82rl\x10\xec\x90\x92\x90\x90\x80pl\x0c\x8ell\x0c\x8cb\x0c\x0c\x0cb\x8e\x8e\x8er|\x8c\x8e\x1c\x82\xec\x0cblb\xec\x8ep\x80\x0c\x8cbl\x8c\x8e\x0cb\x92bpp\x0c\xec\x8ebp|\x8c\x0c\x8eb\x8ep|\xec\x0cb\x8eplb\x1c\xe0\x8cb\x8eb\x8ep\x0cb\x12\x9c\xecl`\x02\x10\xec\x90\x12lrr\x82bp\x90\x0cll\x0c\x8cb\x0c\x0c\x0cb\x80p\x0c\x8e\x8e\x8er|\x8c\x8e\x1c\x82\xec\x0cblb\xec\x8ep\x80\x0c\x8cbl\x8c\x8e\x0cb\x92b\x8cbp\x80\x0cb\x1c\x9c\xec\x8cb\x8e\x8eb\x0c\x0cl\x8c\xec\x0cbbb\x80l\xec\x8e\x80rl'
I traced the origin of the error message in the adafruit _gps library to the _read_sentence method.

Can you help me figure out what's wrong?

Thank you

Pierre

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: Junk data received from UART

Post by mikeysklar »

Pierre,

Are you using the Arduino libraries?

Can you post the code you are using to set the baudrate for the Ultimate GPS and serial speed on the Metro M4?

Was the next baudrate you tried 57,600?

User avatar
PierreDeQuebec
 
Posts: 96
Joined: Sun Jul 25, 2021 3:26 pm

Re: Junk data received from UART

Post by PierreDeQuebec »

Hi mikeysklar,

The command used is the following.

Code: Select all

def _setup_gps(self):
        if self.gps:
            self.uart.deinit()
            self.gps = None

        _actual_uart_baudrate = self.uart_baudrate
        _actual_timout = self.uart_timeout

        if self.gps is None or self.uart_baudrate != _actual_uart_baudrate or self.uart_timeout != _actual_timout:
            # Restart the UART and the GPS chip.
            self.uart = busio.UART(self.gs_board.TX,
                                   self.gs_board.RX,
                                   baudrate=self.uart_baudrate,
                                   timeout=self.uart_timeout)
            self.gps = gps_mod.GPS(self.uart, debug=self.debug)  # Use UART/pyserial

            self.gps.send_command(self.sentences['PMTK314'])
            # Initial sentences requirement (like RMC, GGA, GSA sentences).
            ...
gps_mod is an instance of the adafruit_gps CircuitPython library.
self.sentences is a dictionary of my own.

I just tried initializing the GPS with a baud rate of 56700 baud. The result follows.

Code: Select all

UnicodeError
b'\x00\x00\x00\x00\xe0\xe0\xe0\x00\xe0\x00\xe0\xe0\xe0\xe0\x00\xe0\x00\xe0\xe0\x00\xe0\x00\xe0\x00\x00\xe0\x00\x00\x00\xe0\x00\x00\x00\x00\x00\xe0\xe0\x00\x00\xe0\x00\xe0\xe0\x00\xe0\xe0\xe0\x00\x00\xe0\x00\x00\x00\x00\xe0\x00\xe0\x00\xe0\xe0\xe0\x00\xe0\xe0\x00\xe0\xe0\x00\xe0\x00\xe0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xe0\x00\x00\xe0\x00\x00\x00\x00\x00\x00\x00\x00\xe0\x00\x00\xe0\x00\x00\xe0\x00\x00\xe0\x00\xe0\xe0\xe0\x00\x00\xe0\x00\x00\xe0\x00\xe0\x00\x00\x00\x00\x00\x00\x00\x00\xe0\x00\x00\x00\xe0\x00\xe0\x00\x00\x00\xe0\xe0\x00\xe0\x00\x00\x00\x00\x00\x00\x00\xe0\x00\x00\x00\x00\x00\x00\xe0\x00\x00\x00\x00\x00\xe0\x00\xe0\xe0\xe0\xe0\x00\xe0\x00\xe0\x00\x00\x00\xe0\x00\x00\x00\x00\x00\x00\xe0\x00\xe0\x00\x00\x00\xe0\x00\xe0\x00\x00\xe0\xe0\x00\x00\xe0\x00\x00\xe0\x00\xe0\x00\x00\x00\xe0\x00\xe0\xe0\x00\x00\xe0\x00\xe0\xe0\x00\xe0\x00\xe0\x00\xe0\xe0\xe0\x00\x00\x00\x00\x00\x00\x00\xe0\x00\x00\xe0\x00\x00\xe0\x00\xe0\xe0\x00\xe0\x00\xe0\x00\x00\xe0\x00\x00\xe0\xe0\x00\x00\xe0\x00\xe0\xe0\x00\xe0\xe0\x00\x00\xe0\x00\x00\x00\x00\xe0\x00\xe0\x00\xe0\xe0\x00\x00\xe0\xe0\xe0\xe0\x00\xe0\xe0\x00\xe0\x00\xe0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xe0\x00\x00\xe0\x00\x00\x00\x00\x00\x00\x00\x00\xe0\x00\xe0\x00\xe0\x00\xe0\x00\x00\xe0\x00\x00\xe0\x00\x00\xe0\x00\xe0\xe0\xe0\x00\x00\xe0\x00\x00\xe0\x00\xe0\x00\x00\x00\x00\x00\x00\x00\x00\xe0\x00\x00\x00\xe0\x00\xe0\x00\x00\x00\xe0\xe0\x00\xe0\x00\x00\x00\x00\x00\x00\x00\xe0\x00\x00\x00\x00\x00\x00\xe0\x00\x00\x00\x00\x00\xe0\x00\xe0\xe0\xe0\xe0\x00\xe0\x00\x00\x00\x00\xe0\x00\x00\x00\x00\x00\x00\xe0\x00\xe0\x00\x00\xe0\xe0\xe0\x00\x00\xe0\x00\x00\xe0\x00\xe0\xe0\xe0\x00\xe0\xe0\xe0\x00\x00\xe0\x00\x00\x00\xe0\x00\x00\x00\x00\xe0\x00\x00\x00\x00\x00\xe0\x00\x00\x00\xe0\x00\x00\xe0\x00\x00\xe0\x00\xe0\x00\xe0\x00\xe0\xe0\x00\xe0\xe0\x00\x00\x00\xe0\xe0\x00\x00\xe0\x00'

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: Junk data received from UART

Post by mikeysklar »

Can you post the code you are calling setup_gps() with and the printed NMEA string being sent?

It looks to me like you are only setting up the Metro for the correct baudrate, but not sending the necessary NMEA string to the Ultimate GPS to set it to 57600. The Ultimate GPS would be running at its default of 9600).

Code: Select all

gps.send_command(b"PMTK251,57600")

Locked
Please be positive and constructive with your questions and comments.

Return to “Metro, Metro Express, and Grand Central Boards”