Reputation: 3
First of all, I'm a noob. I'm doing my best here. I really do.
I have a pressure sensor called KITA KP70. This is it's manual: https://drive.google.com/file/d/1ED1kr3cW1mmgM_-hSxhoo-Cbr2zI3ZSo/view
I'm trying to read anything from it using python without any luck. All I get back is an empty response after the code times out.
This is the code I'm using:
import serial
port = serial.Serial("/dev/ttyUSB0", baudrate=9600, timeout=2)
while True:
port.write("30H30H31H32H".encode())
rcv = port.read(10)
print (rcv)
Now the thing is connected as this: The sensor itself is connected to UART to RS485 Converter. This is the device: https://www.amazon.com/HiLetgo-Reciprocal-Hardware-Automatic-Converter/dp/B082Y19KV9
The converter is connected to c232hm-ddhsl-0. This is the product: https://ftdichip.com/products/c232hm-ddhsl-0-2/
And the c232hm-ddhsl-0 is connected using USB to my PC.
I can see the device when checked using the terminal:
ahmad@Ahmad-PC:~/Desktop$ sudo dmesg | grep tty
[ 0.073387] printk: console [tty0] enabled
[ 13.131371] usb 3-1: FTDI USB Serial Device converter now attached to ttyUSB0
When I execute the command above, the write LED blinks, but nothing else happens. I've checked the cables and everything seems to be correctly connected and to the right color.
Can anyone help me read anything from this device? The list of codes this device accept are listed in the manual.
Thank you in advanced!
Upvotes: 0
Views: 691
Reputation: 54698
You have been fooled by poor documentation. When they say "30H30H31H32H", they are using an antique method of indicating hex digits. What they mean is the four-byte sequence 0x30 0x30 0x31 0x32, which happens to be the string "0012".
For what it's worth, that number style comes from Microsoft's MASM assembler.
Upvotes: 1