Hi,
I want to use wired soil moisture sensors and valves for my garden irrigation with about about 10 to 15 zones. I thought it would be a good idea to use a bus system like Modbus RTU RS-485. My garden already has a number of conduits for powering my illumination. So no need for wireless stuff.
I got a professional soil moisture sensor, the SMT100 by Truebner configured for Modbus. My hardware is a Pi4 and a low cost USB to RS-485 converter with CH340 chip. I discovered a strange problem. The SMT100 is working perfectly with Modbus test software like Modpoll and test software from the manufacturer. With Home Assistant it did not work at the beginning. The sensor was not recognized (no response). After trying for hours I finally found the solution. In the Modbus configuration section I have to configure 2 stopbits instead of 1 stopbit. Home Assistant seems to use pymodbus so I tried pymodbus seperately and it only worked with 2 stopbits. So it looks like the problem is not related to Home Assistant but to pymodbus.
In the end I am happy that I found a stable solution and would like to share it with others.
This is my single sensor configuration:
modbus:
- name: hub1
type: serial
baudrate: 9600
bytesize: 8
method: rtu
parity: N
port: /dev/ttyUSB0
stopbits: 2
timeout: 1
sensors:
- name: Temperature Sensor 1
slave: 1
address: 0
scale: 0.01
offset: -100
precision: 2
scan_interval: 10
unit_of_measurement: °C
- name: Moisture Sensor 1
slave: 1
address: 1
scale: 0.01
offset: 0
precision: 2
scan_interval: 10
unit_of_measurement: '%'
Nevertheless I am still curious why I have to use 2 stopbits (maybe a USB to RS-485 CH340 driver problem or a pymodbus problem related to inter char timeout ?). I may be able to borrow an oscilloscope to further dig into the problem.
There is still room for improvement in my configuration. I would like to read multiple registers at the same time to speed up data acquisition, because in the end I plan for up to 15 sensors.
Any recommendations are highly appreciated.
Update: I found this great article about different kinds of soil moisture sensors. Seems like the SMT100 is the right choice after all