Hardware Serial returning gibberish.

Post here first, or if you can't find a relevant section!
Post Reply
smudge_smiff
Posts: 2
Joined: Sun Jul 16, 2023 1:52 pm

Hardware Serial returning gibberish.

Post by smudge_smiff »

I have a GPS connected to my STM32F401CC.

The hardware Serial is returning nonsense into the program.

I know the GPS is working at 57600 Baud as I have a USB-Serial adapter and it is producing the NEMA strings as expected. However, when I read the serial using the STM32, I get nothing but gibberish forwarded to the PC.

Code for Reference:

Code: Select all

void position_task(void* args)
{
    HardwareSerial gpsSerial(UART2_RX, UART2_TX);
    gpsSerial.begin(57600);
    for(;;)
	{
		while(gpsSerial.available() > 0){
            Serial.print(gpsSerial.read());
        }
	}
}

Any help is much appreciated!
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Hardware Serial returning gibberish.

Post by ag123 »

many GPS device initialize at 9600 baud, not 57600 baud. and various of them offer commands to set the baud rates after initially connecting at 9600 bps

if you do not know the actual GPS bauds, to avoid getting gibberish, you would need to practically test every practical known baud, till one that doesn't return gibberish
Post Reply

Return to “General discussion”