Issue with UART Communication from UnitV2 to Raspberry Pi
-
Hello,
I’ve been trying to send simple data from the UnitV2 to the Raspberry Pi using UART on the ttyAMA0 port.
import serial import time # M5Stack UnitV2 uart = serial.Serial('/dev/ttyAMA0', 115200) while True: uart.write(b'Hello from M5stack\n') time.sleep(1)
While the Pi itself can successfully utilize ttyAMA0, the UnitV2 is unable to communicate through this port. Despite updating the firmware as recommended, I still can’t establish communication between the UnitV2 and Pi via UART.
#pi import serial import time try: ser = serial.Serial('/dev/ttyAMA0', 115200, timeout=1) print("Serial port opened successfully") ser.write(b'Hello from Raspberry Pi!\n') while True: if ser.in_waiting > 0: data = ser.read(ser.in_waiting).decode('utf-8').strip() print(f'Received: {data}') time.sleep(1) except serial.SerialException as e: print(f'Error: {e}') finally: ser.close()
Any advice on how to resolve this?
Thank you for your help.