I have enabled uart serial port /dev/ttyAMA0 on my raspberry pi zero W. I was able to successfully connect the rpi uart rx and tx pins and check if i'm able send and receive data between these rpi port. But when i connect to an external source of serial data, my program does not receive anything.
My goal is to receive and process async serial data which looks like this -.
Here's my code
import serial
test_string = "Test serial port ...".encode('utf-8')
try:
port="/dev/serial0" # maps to "/dev/ttyAMA0"
serialPort = serial.Serial(port, 9600, timeout=None)
print ("Serial port", port, " ready for test :")
while True:
loopback = serialPort.read(4)
print ("Received ",len(loopback), "bytes. Port", port,"is OK ! \n")
serialPort.close()
except Exception as e:
print ("Error on", port, e, "\n")
Setup - Connected the TX of the external source to the RX of RPI (physical PIN 10/GPIO 15).
What am i missing?