I'm trying to read data coming off of the primary uart /dev/ttyAMA0 on a raspberry pi which is sent from Arduino Nano.
Library on the arduino side https://gitlab.com/creator-makerspace/rs485-nodeproto
So I use a simple python script to verify the data coming from the arduino:
import serial
sp = serial.Serial(
port="/dev/ttyAMA0",
baudrate=9600,
timeout=0.1
)
while True:
i = sp.read()
print i.encode("hex")
But the data coming out is corrupt / wrong about x times out of n times.
A good packet looks like A0 2 1 4F 50 45 4E B7 1B 80
Bad packets which is most of the time: 13 0a 7a 41 15 39 dd 1b 80 00
Also the test script works fine when using a USB to UART connected to the rs485 tranceiver instead of the internal uart.
Suggestions on what I am doing wrong?