[Python] Unable to Receive Data via Serial Communication on Raspberry Pi/PC with ACC220 Module

Discussão em 'Python' iniciado por Stack, Março 28, 2025.

  1. Stack

    Stack Membro Participativo

    I’m working on a project where I need to send and receive data via a serial connection using the ACC220 USB-to-serial module. I have a simple sender-receiver setup using Python and PySerial to transmit data from one device (Raspberry Pi/PC) to another, but I can’t get the receiver to work.

    The sender successfully prints "Sent: Hello from sender" every second, indicating that data is being sent. The receiver is not receiving any data, even though the sender is printing the "Sent" message every second. Wiring:

    TX (sender) → RX (receiver)

    RX (sender) → TX (receiver)

    GND → GND between devices.


    Receiver (Laptop)

    import serial

    PORT = "COM5"
    BAUDRATE = 9600

    ser = serial.Serial(PORT, BAUDRATE, timeout=1)
    print(f"Listening on {PORT} at {BAUDRATE} baud...")

    while True:
    data = ser.readline().decode().strip()
    if data:
    print(f"Received: {data}")
    else:
    print("No data received.")


    Sender (Pi5)

    import serial
    import time

    PORT = "/dev/serial0"
    BAUDRATE = 9600

    ser = serial.Serial(PORT, BAUDRATE)
    print(f"Sending data on {PORT} at {BAUDRATE} baud...")

    try:
    while True:
    ser.write(b"Hello from sender\n")
    print("Sent: Hello from sender")
    time.sleep(1)
    except KeyboardInterrupt:
    print("\nStopping sender.")
    ser.close()


    I’ve tried using a serial monitor (PuTTY) to test if data is coming through COM5, but still no luck.

    I have alredy checked wiring: TX to RX and RX to TX. Ensured baud rate, parity, and other serial settings match. Verified that the serial port is not being blocked by any other application.

    I’ve tried everything I can think of and still can’t get the receiver to work. Any help on what I’m missing?

    Continue reading...

Compartilhe esta Página