A sump pump is one of those devices you normally ignore until the day it fails. Unfortunately, the first visible sign of failure can be a flooded basement, plant room, garage or lift pit.
An ESP32 running ESPHome can turn a basic sump installation into a much more useful monitoring system by watching water level, pump operation, runtime, high-water alarms, floor leaks and power availability.
Normal float / level sensor ─┐
High-water float ──────────────┤
Pump-running feedback ─────────┤
Floor leak sensor ─────────────┤
Pump mains available ──────────┤
▼
ESP32
│
ESPHome
│
▼
Home Assistant
│
┌────────────────┼────────────────┐
▼ ▼ ▼
Alerts History Failure logic
The most valuable feature is not remote pump switching. It is knowing when the system is behaving abnormally: the water is rising but the pump never starts, the pump has been running far longer than normal, the high-water switch has triggered, or mains power to the pump has disappeared.
Monitoring Is Usually More Important Than Remote Control
For a primary flood-protection pump, leave the normal pump controller, float switch and motor protection independent of the ESP32.
- The existing float switch should still start the pump if Wi-Fi is down.
- The pump should still stop correctly if Home Assistant is unavailable.
- Motor overload and thermal protection should remain in the pump/control equipment.
- The ESP32 should observe the system rather than become the only thing preventing flooding.
- If you need automatic backup-pump control, use suitable pump-control hardware and independent high-level protection rather than a hobby relay board.
That makes the ESP32 an extra layer of visibility and alarm logic rather than a new single point of failure.
The Four Signals Worth Monitoring
| Signal | What it tells you | Why it matters |
|---|---|---|
| Pump running | Motor is actually operating or an auxiliary contact is active | Confirms real pump operation rather than only a command |
| Normal water level / float | Water has reached the normal pump-start region | Lets you compare demand with pump response |
| High-water float | Water has risen above the normal operating range | Immediate flood-risk alarm |
| Floor leak sensor | Water has escaped the sump/pit | Confirms an actual leak or overflow |
A fifth signal—pump mains available—is extremely useful if the monitoring electronics remain powered from a UPS.
Recommended Hardware
- ESP32 DevKit or another ESPHome-compatible ESP32 board.
- High-water float switch mounted above the normal pump-on level.
- Optional normal-level float switch if the existing pump float cannot be safely monitored.
- Isolated pump-running feedback, ideally a current-operated switch with dry contacts or a contactor auxiliary contact.
- Floor leak sensor or simple dry-contact water probe interface.
- Isolated mains-presence relay/contact if you want to distinguish pump power failure from a normal idle pump.
- Small UPS for the ESP32 and preferably the local network equipment if outage alerts must continue during a blackout.
For a permanently installed system, dry-contact inputs are ideal because the ESP32 only sees low-voltage switch states. The pump’s mains wiring stays inside appropriately rated equipment.
Do Not Put 230 V on ESP32 Inputs
The ESP32 is a 3.3 V microcontroller. Never connect mains voltage, a pump motor lead or an unknown pump-controller output directly to a GPIO.
- Use voltage-free/dry contacts where possible.
- Use optically isolated or properly rated interface modules when a dry contact is not available.
- A current switch with an isolated relay output is much simpler and safer than measuring pump current directly with an unisolated DIY circuit.
- If the pump is driven by a contactor, an auxiliary contact can provide excellent running feedback.
- Keep mains and SELV wiring physically separated inside the enclosure.
A Good Sensor Layout
Top of pit
HIGH WATER FLOAT ← emergency alarm level
│
│
NORMAL FLOAT ← optional monitoring point
│
│
PUMP / PRIMARY FLOAT
│
▼
Bottom of pit
Floor leak probe outside pit → detects overflow/escape
The high-water float should be physically independent of the normal pump-control float. If the normal float sticks, jams or fails, a second switch at a higher level can still report the problem.
Example ESP32 GPIO Allocation
| Function | GPIO | Input type |
|---|---|---|
| High-water float | GPIO25 | Dry contact to GND |
| Normal-level float | GPIO26 | Dry contact to GND |
| Pump-running feedback | GPIO27 | Dry contact to GND |
| Floor leak alarm | GPIO32 | Dry contact / isolated leak interface |
| Pump mains available | GPIO33 | Isolated dry contact |
These pins are examples for a common ESP32-WROOM DevKit. Check the exact board you are using and avoid boot-sensitive GPIOs for alarm inputs where possible.
Basic ESPHome Configuration
esphome:
name: sump-monitor
friendly_name: Sump Pump Monitor
esp32:
board: esp32dev
framework:
type: esp-idf
logger:
api:
ota:
- platform: esphome
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
ssid: "Sump Monitor Fallback"
password: !secret fallback_password
captive_portal:
Float Switches and Alarm Inputs
A simple float switch connected between GPIO and GND works well with the ESP32 internal pull-up. The example below assumes the contact closes when the alarm condition is present.
binary_sensor:
- platform: gpio
id: high_water
name: "Sump High Water"
device_class: moisture
pin:
number: GPIO25
mode:
input: true
pullup: true
inverted: true
filters:
- delayed_on: 500ms
- delayed_off: 2s
- platform: gpio
id: normal_level
name: "Sump Normal Level"
device_class: moisture
pin:
number: GPIO26
mode:
input: true
pullup: true
inverted: true
filters:
- delayed_on: 500ms
- delayed_off: 2s
- platform: gpio
id: floor_leak
name: "Sump Room Flood"
device_class: moisture
pin:
number: GPIO32
mode:
input: true
pullup: true
inverted: true
filters:
- delayed_on: 1s
- delayed_off: 5s
The short delay filters prevent contact bounce and splashing from producing a stream of rapid state changes. For an emergency high-water switch, do not use a long delay that could hide a real rising-water condition.
Detect Whether the Pump Is Really Running
The best monitoring signal is independent of the pump command. If the pump controller says ‘run’ but the motor has failed, monitoring only the command tells Home Assistant that everything is fine.
A current-operated switch around one pump conductor or an auxiliary contact from the motor contactor confirms actual operation.
- platform: gpio
id: pump_running
name: "Sump Pump Running"
device_class: running
pin:
number: GPIO27
mode:
input: true
pullup: true
inverted: true
filters:
- delayed_on: 300ms
- delayed_off: 1s
If the current switch output logic is opposite, remove or change inverted: true. Test the sensor while manually exercising the pump before relying on it.
Monitor Pump Mains Availability
If the ESP32 is powered from the same circuit as the pump, a power failure simply takes the monitor offline. Home Assistant may eventually report the device unavailable, but that is not the same as a clean ‘pump power lost’ alarm.
A better arrangement for critical sites is:
UPS / backed-up supply
│
├── ESP32
├── router / access point if practical
│
└── monitoring interface
Pump mains ── isolated voltage relay ── dry contact ── ESP32
- platform: gpio
id: pump_power
name: "Sump Pump Mains Available"
device_class: power
pin:
number: GPIO33
mode:
input: true
pullup: true
inverted: true
filters:
- delayed_on: 1s
- delayed_off: 2s
The exact logic depends on the isolated relay you use. The key point is that the ESP32 must stay alive long enough to report that pump power disappeared.
Expose a Local Failure State
You can combine several signals into one ESPHome problem sensor so Home Assistant has an immediate high-level status.
- platform: template
name: "Sump System Problem"
id: sump_problem
device_class: problem
lambda: |-
if (id(high_water).state) return true;
if (id(floor_leak).state) return true;
if (!id(pump_power).state) return true;
return false;
Keep the raw inputs visible as well so you can see exactly why the problem sensor is active.
Detect the Worst Failure: Water Rising but Pump Not Running
One of the most valuable rules is a mismatch alarm:
High water detected
AND
pump not running
for several seconds
=
possible pump failure
The appropriate delay depends on the physical system. Allow enough time to avoid false alarms while still reacting well before overflow.
- platform: template
name: "Pump Failed to Start"
id: pump_failed_to_start
device_class: problem
lambda: |-
return id(high_water).state && !id(pump_running).state;
filters:
- delayed_on: 5s
- delayed_off: 2s
Using the high-water switch for this logic is intentionally conservative. By that point the pump should normally already be running.
Detect a Pump That Runs Too Long
A pump that runs continuously can indicate unusually heavy inflow, a blocked discharge, failed check valve, worn pump or a level switch stuck in the run position.
The simplest robust method is to let Home Assistant time the pump-running binary sensor and trigger an alert if it remains ON longer than your known normal maximum cycle.
alias: Sump pump long runtime
triggers:
- trigger: state
entity_id: binary_sensor.sump_pump_running
to: "on"
for: "00:05:00"
actions:
- action: notify.send_message
target:
entity_id: notify.my_device
data:
message: "Sump pump has been running continuously for 5 minutes."
Do not blindly use five minutes. First observe real cycles during heavy rain and choose a threshold comfortably above the normal maximum.
Count Pump Cycles
Cycle frequency is often more informative than a single alarm. A sump that normally runs twice per day but suddenly runs every ten minutes is telling you that something changed.
- Cycles per hour during storms.
- Cycles per day in normal weather.
- Average runtime per cycle.
- Total daily runtime.
- Time since last pump run.
These trends can reveal increasing groundwater inflow, a leaking check valve or a pump losing capacity before the high-water alarm ever triggers.
Total Daily Runtime in Home Assistant
The Home Assistant history_stats integration can calculate how long the pump-running binary sensor has been ON during a defined period.
sensor:
- platform: history_stats
name: Sump Pump Runtime Today
entity_id: binary_sensor.sump_pump_running
state: "on"
type: time
start: "{{ today_at() }}"
end: "{{ now() }}"
That gives a daily runtime trend without adding timing logic to the ESP32.
High-Water Alerts Should Repeat Until Resolved
A one-time phone push is easy to miss. Home Assistant’s Alert integration is designed for conditions that should keep reminding you until the problem clears or is acknowledged.
alert:
sump_high_water:
name: Sump High Water
entity_id: binary_sensor.sump_high_water
state: "on"
repeat:
- 1
- 5
- 15
can_acknowledge: true
skip_first: false
notifiers:
- my_device
Repeating alerts are much better suited to a flood-risk event than a single disposable notification.
Add a Separate Floor Leak Alarm
The high-water float tells you the pit is too full. A floor leak sensor tells you that water has already escaped or is arriving from somewhere else.
alias: Sump room flood detected
triggers:
- trigger: state
entity_id: binary_sensor.sump_room_flood
to: "on"
actions:
- action: notify.send_message
target:
entity_id: notify.my_device
data:
message: "Water detected on the floor near the sump."
For a serious installation, combine mobile notification with something local such as a buzzer, siren or hardwired building alarm input.
Why an Ultrasonic Sensor Is Optional
You can add continuous water-level measurement using a waterproof ultrasonic or pressure sensor, but it should supplement rather than replace the simple high-water float.
| Sensor | Strength | Weakness |
|---|---|---|
| Float switch | Simple, binary, robust | No continuous level trend |
| Waterproof ultrasonic | Non-contact continuous level | Condensation, foam, geometry and blind-zone issues |
| Hydrostatic pressure | Excellent continuous level in deep pits | Needs suitable transducer and analog/current interface |
For flood protection, a dedicated high-level float remains valuable even when you have continuous level sensing because it provides an independent physical alarm point.
Optional Continuous Level Monitoring
If the sump geometry allows it, a waterproof ultrasonic sensor mounted at the top can measure the air gap to the water surface. Our existing water-tank guide covers the distance-to-level calculation in detail.
ESP32 Water Tank Level Monitor with Home Assistant & ESPHome covers waterproof ultrasonic sensors, filtering and calibration.
Detect Pump Performance from Water-Level Slope
Continuous level sensing enables a useful higher-level test: when the pump starts, the water level should begin falling.
Pump ON
+
water level still rising
=
possible blocked discharge / failed pump
Pump ON
+
water level falling slowly
=
reduced pump capacity or very high inflow
This is a better diagnostic than current sensing alone. A blocked pipe or damaged impeller can still produce electrical activity without moving water properly.
Power Failure Is a Special Case
Power outages are particularly dangerous for mains sump pumps because bad weather can cause both high groundwater and utility interruptions at the same time.
- Back up the monitoring electronics if you need outage alerts.
- Consider a battery-backed secondary pump for sites where flooding risk is high.
- If the Wi-Fi router loses power too, an ESP32 UPS alone cannot deliver a remote alert.
- For critical sites, consider a cellular alarm path independent of the local internet connection.
- Test the entire alert chain by actually switching off the pump circuit.
Home Assistant Dashboard
A useful dashboard does not need to be complicated. Put the failure signals at the top and trends below them.
- Pump mains available.
- Pump running.
- High-water alarm.
- Floor leak alarm.
- Pump failed-to-start alarm.
- Pump runtime today.
- Pump cycles today.
- Optional sump water-level graph.
A Better Alarm Matrix
| Water state | Pump state | Power | Likely interpretation |
|---|---|---|---|
| Low/normal | Off | Available | Normal idle |
| Normal float active | Running | Available | Normal pumping cycle |
| High water | Running | Available | Pump cannot keep up / discharge problem |
| High water | Off | Available | Pump/float/controller failure |
| Any | Off | Not available | Pump cannot run: power failure |
| Floor leak | Any | Any | Overflow or unrelated water leak |
This combination of states is far more informative than simply knowing whether one float switch is wet.
Common Problem: Float Switch State Is Backwards
Float switches can be normally open or normally closed depending on orientation and construction. Some reversible floats change behaviour when physically inverted.
Check the contact with a multimeter before final installation. If Home Assistant shows wet when the pit is dry, change inverted: rather than mentally reversing the meaning forever.
Common Problem: High-Water Alarm Flickers
- Water turbulence is moving the float around the trip point.
- The cable run is picking up electrical noise.
- The float contact is bouncing.
- The switch is mounted too close to the pump discharge flow.
Use a short ESPHome delayed-on/off filter and reposition the float away from violent water movement. Do not mask a real alarm with an excessively long software delay.
Common Problem: Pump Shows Running When It Is Off
- Current-switch threshold is set too low.
- Pump wiring creates induced current through adjacent conductors.
- The contactor auxiliary contact is wired to the wrong pole.
- The input inversion is wrong.
- The current sensor is installed around the wrong conductors.
For a current-operated switch, follow the sensor manufacturer’s installation instructions and keep mains work inside appropriate electrical equipment.
Common Problem: ESP32 Goes Offline During Pump Starts
A pump motor creates a substantial starting transient. If the ESP32 power supply or wiring is poor, the controller may brown out exactly when the pump starts.
- Use a quality isolated power supply.
- Do not power the ESP32 from an unknown low-voltage output in the pump controller unless it is properly rated.
- Keep ESP32 wiring away from motor and contactor wiring.
- Use suppression appropriate to the relay/contactor coil.
- Check Wi-Fi signal if the metal pump cabinet shields the antenna.
- If needed, mount the ESP32 outside the metal enclosure and bring only low-voltage dry-contact wiring to it.
Test the Failure Modes, Not Just the Normal Mode
A flood monitor is only useful if you know the alarms actually work. Commission it by deliberately creating the conditions it is supposed to detect.
- Lift the normal float and confirm the pump-running sensor changes.
- Lift the high-water float and confirm the urgent alert is delivered.
- Disconnect or disable pump power and confirm the power-loss alarm.
- Trigger the floor leak input with a safe test method.
- Run the pump longer than the long-runtime threshold.
- Simulate pump-running failure while the high-water input is active.
- Reboot the ESP32 and verify all alarms recover to the correct state.
- Test after an ESPHome OTA update.
Recommended Architecture
Primary pump control:
mechanical float / proper pump controller
│
└── controls pump independently
Monitoring:
high-water float ──────┐
pump-current contact ──┤
mains-present contact ─┤
floor leak sensor ─────┤
optional level sensor ─┤
▼
ESP32
│
ESPHome
│
▼
Home Assistant
│
alerts + history
Optional:
ESP32 + network on UPS
This arrangement keeps the primary flood-protection function independent while still giving Home Assistant enough information to detect abnormal behaviour quickly.
Final Recommendation
For a sump-pump installation, start with three independent signals: high water, pump actually running, and pump power available. Add a floor leak sensor if water outside the pit would cause damage.
Do not make the ESP32 the only controller for the primary pump. Let proven float/pump hardware keep doing the basic job, and use ESPHome to watch it, time it, trend it and raise alarms when reality no longer matches what should be happening.
If you want to go further, continuous level sensing turns the project from a simple alarm into a diagnostic system: Home Assistant can see whether water rises faster than normal, whether the pump is losing capacity and whether pump runtime is increasing over months.
Related ESP32 Guides
- ESP32 Water Leak Sensor with Home Assistant
- ESP32 Water Tank Level Monitor with Home Assistant & ESPHome
- ESP32 Multi-Sensor Node for Home Assistant
Official Documentation
- ESPHome GPIO Binary Sensor — dry-contact and digital input configuration.
- Home Assistant Alert Integration — repeating alerts for persistent fault conditions.
- Home Assistant Notifications — notification actions and leak-alert examples.
- Home Assistant History Stats — calculate pump runtime over a selected period.
- ESPHome Pulse Meter Sensor — useful when a flow meter is added to a discharge line.