🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Issue with UART Communication from UnitV2 to Raspberry Pi

    General
    1
    1
    270
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      paramza029
      last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • First post
        Last post