Smart Water Management System (DIY)
Table of Contents
(The full ESPHome config and wiring live in lejmr/dyi-ha-water-management.)
I have a 16m³ underground concrete rain water tank, a well, and a cellar that sits uncomfortably close to both. When the groundwater rises, it finds its way through the concrete and into the cellar — so I wanted a system that watches both water levels and runs the pump before the water starts redecorating. And since it irrigates the lawn anyway, the water doesn’t even go to waste.
The requirements I set myself: DIN rail mount (three positions max, power supply included), reliability, minimal maintenance — and everything visible in Home Assistant, because a water level I can’t chart might as well not exist.
Off-the-shelf first
I did try to buy my way out of it. Lovato LVM40A127 and Elko HRH-6 both do the job functionally — but neither speaks Home Assistant, and a dumb relay was exactly what I didn’t want. So: DIY.
The build
ESPHome was the obvious software choice — native Home Assistant integration, config in one YAML file. For sensing I picked RS-485 water level transmitters (the 24V DC version), on the strength of recommendations from various DIY forums.
The rest of the hardware follows from that decision: a Wemos S2 mini ESP32 board, a MAX485 converter because ESP boards don’t speak RS-485, a 24V→5V step-down to power the logic, all soldered onto a universal prototyping board and packed into a SZOMK DIN rail enclosure.

Prototype ready for deployment:

The ESP board’s configuration lives in wemos.yml and gets flashed like this:
esphome run --device /dev/tty.usbmodem01 wemos.yml
The final deployment ended up in two places: the wiring cabinet and the well itself.

The pump itself is powered through a Shelly 1PM gen4, driven by a Home Assistant automation: when the well level climbs above 190 cm, switch on; wait until it drops below 140 cm, switch off.
alias: Reduce level in the well
triggers:
- trigger: device
type: value
entity_id: sensor.well_level
above: 190
actions:
- type: turn_on
entity_id: switch.well_pump
- wait_for_trigger:
- trigger: device
type: value
entity_id: sensor.well_level
below: 140
- type: turn_off
entity_id: switch.well_pump
mode: single
How it holds up
- The water level sensor is very accurate — genuinely surprised for the price.
- The whole setup (2x RS-485 converter, 1x level sensor) consumes about 1 W while reading every 5 seconds.

Challenges
One mystery remains: with both RS-485 converters connected, the ESP refuses to join Wi-Fi. Remove one and everything works. So the second measuring point waits until I figure that one out.
Future work
- Shrink the device to a single DIN position in the wiring cabinet
- Support two measuring locations (see above)
- Upgrade to ESP32-S3-Zero, which should lower consumption and save space in the box
- Let the device control the Shelly directly — the goal is to set the water levels from Home Assistant and have the device drive the pump on its own, even when Home Assistant is down
- A Home Assistant blueprint for device configuration