Rainfall water tank with level measurement by DomBus moduleThe following application note shows how to measure the level of rainwater (or other liquid) inside a tank, using a waterproof ultrasonic distance sensor JSN-SR04T.

This solution works perfectly with Domoticz home automation system, a complete, free and open source software for domotic applications, using DomBus modules programmed with DomBus firmware.

Also, using the DomBus modules with Modbus firmware, works also with Home Assistant, Node_RED, OpenHAB and other domotic systems supporting the standard Modbus protocol.

      

The following graph displays the measured level of rainwater inside a tank: level decreases when water is used (during garden irrigation, for example) and increases during rains; below the connection diagrams of the ultrasonic distance sensor to the DomBus1 module, a domotic module that includes 6 inputs, 1 230Vac input and 3 relay outputs, and the configuration of the domoticz device using the linear equation displayed_value=A*sensor_value+B so when the distance sensor measures 0mm (rainwater full), the distance from the tank bottom is 165cm. Parameter "A" is used to convert from mm to cm, and parameter "B" to get the tank level instead of distance from sensor to water level.

The following DomBus modules support the ultrasonic distance sensor:

  • DomBus12, with DomBus or Modbus firmware: 9 I/Os module, supporting up to 6 distance sensors + 1 trigger output (IO7) common controlling all sensors
  • DomBusTH, with DomBus or Modbus firmware: 6 I/Os module with RGB leds, touch sensor and temperature/humidity sensors, supporting up to 5 distance sensors + 1 trigger output (IO4) controlling all sensors

Water tank level measured using a waterproof ultrasonic distance sensor

Connection schema for the ultrasonic distance sensor used to measure and monitor the rainwater tank level

Domoticz tank level device configuration

Documentation for JSN-SR04T waterproof distance sensor

Click to get the JSN-SR04T distance sensor datasheet

Operating voltage 5 V (it works at 3.3V too)
Operating current 30 mA
Quiescent current 4-5 mA
Frequency 40 kHz
Measuring range 25-450 cm
Resolution 2 mm
Measuring angle 30 degrees
Sensor dimensions 23.5 x 20 mm with 2.5 m long cable
PCB dimensions 41 x 28.5 mm (to be protected by humidity!)

 

Using DomBusTH module to control up to 5 distance sensors

  • Connect the 5V power supply and GND to the distance sensor boards (they works also with 3.3V).
  • Connect IO1, IO2, IO3, IO5 or IO6 to the "echo" sensor output. In case of IO5 (that is factory configured to works as open-drain output), to use it as input port connected to the "echo" output, you have to open R05 (with a cutter) and short the RO5 (with a solder iron) PCB jumpers. The same for IO6.
  • Connect IO4 to the "trigger" sensor input. Also, short the "O4" pcb jumper to use this I/O port as output.
  • Configure (by software) IO4 (trigger) and IOx (echo) as DISTANCE (normally these ports are factory configured as digital inputs or outputs). Using Domoticz, just write in the description field of the sensor devices (both trigger and echo ports) the string ",DISTANCE" to set the port as distance sensor. In case of Modbus, program the address 255+portnumber to the value 13, corresponding to the DISTANCE sensor type.

The module returns the distance in millimiters, and is updated every 15s.

Using DomBus12 module to control up to 6 distance sensors

  • Connect the 5V power supply and GND to the distance sensor boards (they works also with 3.3V).
  • Connect IO1, IO2, IO3, IO4, IO5 or IO6 to the "echo" sensor output. In case of IO5 (that is factory configured to works as open-drain output), to use it as input port connected to the "echo" output, you have to open R05 (with a cutter) and short the RO5 (with a solder iron) PCB jumpers. The same for IO6.
  • Connect IO7 to the "trigger" sensor input. Also, short the "RO7" pcb jumper to use this I/O as output.
  • Configure (by software) IO7 (trigger) and IOx (echo) as DISTANCE (normally these ports are factory configured as digital inputs or outputs). Using Domoticz, just write in the description field of the sensor devices (both trigger and echo ports) the string ",DISTANCE" to set the port as distance sensor. In case of Modbus, program the address 255+portnumber to the value 13, corresponding to the DISTANCE sensor type.

The module returns the distance in mm, and is updated every 15s.

Using DomBus12 module in a greenhouse / tunnel to measure temperature and water tank level