
K dispozici jsem měl sondu YW801R.
Zapojení:


- červená (24V +), modrá (24V-), bílá RSA, černá RSB

Parametry připojení:
- rychlost připojení: 1200 b/s, 8 datových bitů, 1 stop bit, bez parity
- adresa zařízení (modbus): 192
- vyčítání hodnoty: read_registers(1, 1, 3) –> read_register(registeraddress: int, number_of_decimals: int = 0, functioncode: int = 3, signed: bool = False)
- senzor vrátí výšku vodní hladiny v cm

Po zapojení zařízení je potřeba počkat na ustálení hodnot, které dle mých testů trvalo vždy kolem 5 minut.
Osobně jsem na vyčítání použil Raspberry 3 s WaveShare RS485 CAN HAT for Raspberry Pi, kde jsem použil Python skript:
#!/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])
Odpovědí mi je číslo (integer), které ukazuje výšku hladiny v cm.
P.S.: Pro testování jsem použil software CAS Modbus Scanner a jako hardware Industrial USB To RS485 .