Skip to content

Plugin tank monitor

Martin Pihrt edited this page Oct 13, 2026 · 1 revision

Water Tank Monitor

Measures ultrasonic tank level and volume, blocks irrigation on low water and exposes tank provider actions.

At a glance

Item Value
Version 1.1.1
Category Irrigation and water management
Author Martin Pihrt
License GPL-3.0
OSPy 3.0.211 or newer
Python 3.8 or newer
Permissions files, i2c, email, system
Hardware platforms: raspberry_pi; interfaces: i2c
Dependencies Database Connector (optional)
Python/OS packages smbus / python3-smbus (required)
Interfaces provider ospy.provider.v1, Mobile API v1
Source Open the plug-in directory

What it is for

Measures ultrasonic tank level and volume, blocks irrigation on low water and exposes tank provider actions.

How it works and how to configure it

Tested in Python 3+

The plug-in includes a plugin.json manifest and reports its worker, configured I²C address, water level, fill, sensor distance, volume, regulation, watering block, latest reading and errors through the OSPy system health interface.

Version 1.1.1 adds explicit Automation Rules provider actions for safely stopping the active tank-regulation output and resetting the recorded minimum and maximum to the latest available level. Version 1.1.0 implements the read-only ospy.provider.v1 contract for the single ultrasonic tank. Cached level, fill, distance and volume are available in stable units without triggering an I²C measurement.

This plugin measures the water level in the tank. If water level is small, this plugin stop irigation system (stop runing stations in scheduler) and sends E-mail with error Safety for master station pump if no water.

Plugin setup

  • Check Use ultrasonic measuring the water level in the tank: If checked measures the water level in the tank is active.

  • The distance from the sensor to the minimum water level in the tank: Enter the distance from the sensor to the minimum water level in the tank (the tank bottom).

  • The distance from the sensor to the maximum water level in the tank: Enter the distance from the sensor to the maximu water level in the tank (maximum to sensor - 2cm).

  • The water level from the bottom to the minimum water level in the tank: Enter the level for the minimum water level in the tank.

  • Stop stations if minimum water level: Stoping these stations if is minimum water level in the tank. Selector for stop stations in scheduler.

  • Stop stations if sonic probe has fault: If the level sensor fails, the above selected stations in the scheduler will stop.

  • Cylinder diameter for volume calculation: Enter the diameter for volume calculation.

  • Display as liters or m3: Show measured water as liters or m3.

  • Use averaging for samples: If checked, averaging of measured values will be performed (this option affects the speed of response to the measured value

  • Number of samples for average: Enter the number count for samples

  • Send an E-mail with an error that there is minimum water in the tank: For this function required E-mail plugin.

  • Send an E-mail with an error if sonic probe has fault: For this function required E-mail plugin.

  • Regulate the maximum water level: If checked, regulation have the maximal water level active.

  • Maximum maintained water level: If the measured water level exceeds this set value, the output is activated.

  • Maximum run time in activate: Maximum duration when activating the output (in minutes and seconds). After this time, the output will turn off regardless of other events (conditions).

  • Minimum maintained water level: If the measured water level falls below this set value, the output is deactivated.

  • Select Output for regulation: Select Output for regulation zones.

  • Enable local logging: Enable logging and graphing.

  • Check Enable SQL logging: If checked enabled logging save measure value to SQL database. This option requires the Database Connector extension to be installed and configured. The button will delete the tankmonitor table from the database, thus deleting all saved data from this extension! This promotion is non-refundable!

  • Maximum number of log records: Maximum number of log records (only for csv file).

  • Interval for logging: Logging interval (minimum 1 minute).

  • Enable bus logging: Logging for advanced user (save debug data from I2C bus).

  • Only if data changed: Logging of data only when this data changes, otherwise still logging.

  • Select filter for graph history From - To selector (date time)

  • Status: Status window from the plugin.

The hardware should be connected as follows:

Visit Martin Pihrt's blog. for more information.

In-app help and settings notes

The following notes are generated from the help page shipped with this plug-in. Field names are also explained directly in the OSPy settings page.

This plugin check water level in water tank via ultrasonic sensor on address 0x04

If water level is small, this plugin stop irigation system (stop runing stations in scheduler) and sends E-mail with error. Safety for master station pump if no water.

Delay Duration (hours)

If there is no water in the tank and the stations stop, then we set the rain delay for this time for blocking. if the level in the tank rises above the minimum + 5 cm, the delay is deactivated

If logging is enabled, a graph with measured data will be displayed at the bottom of the screen

Automation Rules can explicitly stop the active tank-regulation output or reset the recorded minimum and maximum to the current available level.

Visit for more information

The PCB board for water tank monitor (board by pihrt.com)

How to installing in tank

Principle (demonstration with and without obstacle)

HW CPU Firmware version

FW 1.4: added CRC8 checksum in to byte 3. Added sending FW version in processor in to byte 2 (example of version 1.4 will be 0x0E). Increased ping time from 35ms to 50ms.

FW 1.3: added back watchdog reset. Added library for I2C with timeout. The LED on the board flashes until the averaging is complete, then the LED is lit.

FW 1.2: added support for "parallax" sensor (has trig and echo on one wire). Canceled: if no request is received from i2c, a cpu reset will be performed.

Tested ultrasonic probes

4 wire

Ultrasonic waterproof module for distance measurement JSN-SR04T or HCSR04

Example JSN-SR04T on dratek.cz

Example HCSR04 on dratek.cz

Measuring range: 25-400 cm, measuring angle: 45-75 degrees, mounting hole: 18 mm.

A small disadvantage can then be taken to be a minimum detectable distance of 25 cm or a relatively large detection angle.

I have tested the connection using a 15m cable, which is not shielded (there is a sensor and a JSN board in the well, the signal goes to the my hw board with the processor using 4 wires).

3 wire

non-waterproof parallax module. Measuring range: 3-300 cm.

Example parallax.com

Related links and diagrams

schematics2

top

bot

pcb

jsn

schematics

echo1

echo2

Support

Check OSPy → Diagnostics first and remove passwords, tokens, private addresses and other secrets before sharing logs. Report reproducible plug-in problems in the OSPy-plugins issue tracker.

Back to the plug-in catalog

Clone this wiki locally