1

I want to connect a pressure sensor that use a RS485 communication to raspberry pi, when I connected it to RS485 to UART converter to the raspberry but when I ran the code the output is b'' with no numbers from the sensor can anybody know how I can read from the sensor ? 'KITA' is the sensor I use.

import serial
import time
ser = serial.Serial('/dev/serial0', 9600, timeout=0.1)'
ser.write(b'$PF,200\r\n')
ser.write(b'$PO,20\r\n')
x = ser.read()
print (x)
  • What driver(s) did you install for this **/dev/serial0** device node? How exactly are you connecting this converter to your RPi? How have you verified that this connection is functional? Or are you testing with multiple unknowns at once? – sawdust Jul 31 '22 at 22:39
  • did you test this device with any other program? Did you try to `sleep()` before `read()` - so device and raspberry will have time to send/receive data? – furas Aug 01 '22 at 01:29
  • I installed PYSERIAL, and I connecting the converter to the GPIO 14 and 15 (TXD AND RXD), I verified it via terminal and I can tell that the TXD,RXD LED was blinking every time I ran the code . no I do not tested with any thing ales. – Yuosef Dakhlallah Aug 01 '22 at 08:18
  • 1
    Does the RS-485 adapter require a half-duplex control line (e.g. RTS), or is it automatic? Your read timeout is somewhat short for a rather slow baudrate. For a WAG try the opposite, and use a blocking read, i.e. wait forever until something is received. – sawdust Aug 02 '22 at 21:11

0 Answers0