Hi,
I have set up a connection between a sensor and a RPI zero 2 W with GPIO 14 and 15
Here is the spec sheet of the sensor.
This is the basic script I tried:and it returns an empty byte stringCode:
import serialser=serial.Serial(port='/dev/serial0', baudrate=9600, timeout=1, parity= serial.PARITY_NONE)ser.flushInput()ser.flushOutput()ser.write(bytearray([0xD1]) # get information instructionser.read(9)
In the end I don't know if the sensor is working or the communication is working. Is there anyway to troubleshoot what is going on?Code:
b''
Thanks in advance
"Is there anyway to troubleshoot what is going on?"
Disconnect the sensor.
Install a simple loopback wire jumper between GPIO 14 and GPIO 15.
Rerun your test script.
Does the ser.read() call report seeing the 0xD1 you transmitted?
Maybe the sensor uses a true UART with 'balanced' or NRZI signalling which will not be compatible with the 0-3.3v GPIO pins on your RPi board.
Statistics: Posted by B.Goode — Tue Oct 29, 2024 6:25 pm