Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 3456

Python • UART communication between sensor and RPI zero 2W with python

$
0
0
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:

Code:

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)
and it returns an empty byte string

Code:

b''
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?

Thanks in advance

Statistics: Posted by Boorhin — Tue Oct 29, 2024 6:02 pm — Replies 2 — Views 43



Viewing all articles
Browse latest Browse all 3456

Trending Articles