0

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?

Endre Tk
  • 81
  • 2
  • 5
  • Missing terminators (120 ohm maybe)? – J.J. Hakala Jul 28 '16 at 15:58
  • I have 120 ohm on both ends. – Endre Tk Jul 28 '16 at 19:08
  • What hardware-layout do you apply for the interface at side of Raspberry **and** at side of Arduino? RS485 is not a 'native' interface to either of them: at both sides you will need a transceiver. And RS485 is often linked to application of Modbus protocol. – Toulon7559 Dec 18 '16 at 20:02
  • "USB to UART - do you mean "USB<=> RS232" and you are connecting its RX directly to the non-differential side of the RS485 transceiver? If that works, then you definitely have the RS485 +/- wires crossed because the 0-3.3V level is invert of RS232: the RS232 idles -ve when the transceiver output is +3.3V, and RS232 is +ve when transceiver output is 0V. Also, you are only specify baud rate in the python code - make sure to assert the stop/parity settings you are using at arduino side. – DisappointedByUnaccountableMod Dec 20 '16 at 17:37

1 Answers1

0

try connect the boards directly uart to uart.it will give you indication if it uart configuration issue or rs485 issue.

also consider HW problem such as missing GND connection between the boards.

what is the length of cable between the boards?