question marks on serial monitor raspberry pi and arduino Serial communication problem.
-
wrote on 20 Apr 2025, 17:41 last edited by
I'm trying to set up communication between an Arduino and a Raspberry Pi 5 using RX and TX pins. Both devices appear to be sending and receiving messages, but the messages (which are strings) show up as question marks (?) in the serial monitor.
When I run the same code using USB communication instead, everything works fine — the strings are displayed correctly. I've double-checked the wiring (at least 20 times), and it seems solid.
Could the issue be with my level shifter? I'm using the bidirectional Pololu 2595. Has anyone had similar issues with this model, or have any suggestions on what might be going wrong?
Arduino code:void setup() { Serial.begin(9600); // Let's use a standard baudrate delay(1000); } void loop() { if (Serial.available() > 0) { // Simple echo functionality String message = Serial.readString(); Serial.print("Arduino received: "); Serial.print(message); Serial.flush(); } }
and the raspberry pi code:
#!/usr/bin/env python3 import serial import time if __name__ == '__main__': ser = serial.Serial('/dev/ttyAMA0', 9600, timeout=1) ser.reset_input_buffer() while True: ser.write("Hello from Raspberry Pi!\n".encode('utf-8')) line = ser.readline().decode('utf-8').rstrip() print(line) time.sleep(1)
-
Hi and welcome to devnet,
Where are you using Qt in your system ?
As per your code, I would say never so it would be better if you explained exactly what runs where and what exactly are you using.
2/2