Garbage on UART via Serial1

Hello,

i am using the Seeeduino XIAO and i need some help. My application is not that complicated:

void setup(void) {
Serial1.begin(9600);
while(!Serial1);
}

void loop(void) {
Serial1.print(“Hello World!\r\n”);
Serial1.flush();
delay(5000);
}

I tried a couple of options to receive data on the other site, but the only thing i am receiving is garbage. I made sure, that RX, TX and Ground are connected in the right manner (otherwise i would not receive anything at all)

The output of the device:
▒▒▒R▒▒▒:
▒+▒▒▒▒R▒▒▒:
▒+▒

Any help would be appriciated. Best regards!
Michael

Set your serial terminal monitor also to 9600 baud. If not possible to change this, then adjust the baud rate in the program to match the baud rate of the terminal monitor.

I found the problem to this. The two devices did not have a common signal ground, hence the garbage while communicating.

I found two other strange behaviours:
I am using the Stream class to communicate via UART. Everytime i send a string via:
serial->print(“something”), i receive the same string in my receiving routine which in turn uses:
serial->readStringUntil(’\n’)

The other ‘Problem’ is that the timeout for serial->readStringUntil is completly ignored. I set the timeout to 5000 (5 secs) and the call always returns immediately with an empty string.