I had the YW801R probe available.
Connection:
- red (24V +), blue (24V-), white RSA, black RSB
Parametry připojení:
- speed: 1200 b/s, 8 data bits, 1 stop bit, none parity
- device address (modbus): 192
- reading the value: read_registers(1, 1, 3) –> read_register(registeraddress: int, number_of_decimals: int = 0, functioncode: int = 3, signed: bool = False)
- the sensor returns the height of the water level in cm
After plugging in the device you need to wait for the values to stabilize, which according to my tests always took about 5 minutes.
Personally, I used a Raspberry 3 with WaveShare RS485 CAN HAT for Raspberry Pi, using a Python script:
#!/usr/bin/env python3
import minimalmodbus
import time
import RPi.GPIO as GPIO
import serial
EN_485 = 4
GPIO.setmode(GPIO.BCM)
GPIO.setup(EN_485,GPIO.OUT)
GPIO.output(EN_485,GPIO.HIGH)
instrument = minimalmodbus.Instrument('/dev/ttyS0', 192, debug = False)
instrument.serial.baudrate = 1200
instrument.serial.bytesize = 8
instrument.serial.parity = serial.PARITY_NONE
instrument.serial.stopbits = 1
instrument.serial.timeout = 2
instrument.mode = minimalmodbus.MODE_RTU
instrument.clear_buffers_before_each_transaction = True
instrument.debug = False
digit_count = instrument.read_registers(1, 1, 3)
print(digit_count[0])
The answer is a number (integer) that shows the height of the surface in cm.
P.S.: For the testing I used software CAS Modbus Scanner and hardware Industrial USB To RS485 .