- Nov 22, 2026
- 4 min read
Controlling a Pump Without Flooding the House
A wrong temperature reading costs nothing. A pump that keeps running costs a wet floor. The moment the system could act, not just measure, the design question changed from “is the data right?” to “what’s the worst thing this can do, and who stops it?”
My answer: the device protects itself. The dashboard is a convenience, not a safety system.
A deliberately tiny command set
command topic: esp32/pump/cmd
state (retained): esp32/pump/state
availability: esp32/pump/availability
commands: status | off | pulse:<milliseconds>
There is no on. Every run is a pulse with an end. Nothing can leave the pump
running because a message got lost.
The rules live in firmware
- Maximum pulse: 10 seconds. Anything longer is rejected by the board.
- On boot: pump off, before anything else runs.
- Wi-Fi drops: pump off.
- Going to sleep: pump off, and the pin is held LOW through deep sleep
with
gpio_hold_en, so it can’t float high while the chip is off. - Never fall asleep mid-pulse. Sleep waits for the pulse to finish.
Every one of these works with the dashboard switched off, the broker down or the network gone.
The dashboard adds its own, stricter layer
- Pulses are capped again, at 5 seconds, with a 0.5–5 s range in the UI.
- A manual run or schedule asks for confirmation.
- No pulse is sent unless the device says it’s online. The firmware
publishes retained
onlineon connect and sets an MQTT Last Will ofoffline, so if the board disappears the broker announces it for it. - Every state change becomes an event row in SQLite, so there’s a history of what the pump actually did, not just what was asked.
FEATURE_COMMANDS=falseturns the whole write path off for a read-only deployment.
And under all of it there’s a physical +12 V switch on the pump supply. That’s the real interlock. Software layers make mistakes unlikely; the switch makes them impossible.
Schedules that skip instead of running late
One-shot schedules (“pulse 3 s at 08:00”) are stored in SQLite, so they survive container restarts. The important rule is what happens when a schedule comes due and the broker or the pump is offline: it’s marked skipped and never issued late.
A watering that should have happened at 08:00 is not a good idea at 14:00 after someone has already watered by hand. “Missed” is a safe state. “Surprise” isn’t.
The board that didn’t match the repo
During the migration I asked the connected board for its status. It reported a 60-second maximum pulse. The firmware in the repository said 5 seconds at the time. Somewhere along the way an older build had been flashed and never replaced.
Nothing went wrong, because the dashboard enforces its own limit and doesn’t trust the device’s. But it changed how the UI works: it now reads the limit from the retained device state and warns when it differs from what it expects.
Lesson: never assume the deployed firmware is the firmware in your repo. Ask the device.
Sleep makes control harder
A battery board that sleeps can’t hear commands. With this setup, a pulse sent while the ESP32 sleeps isn’t waiting for it when it wakes; it’s simply lost. That’s safe, but it means control needs a window: a time of day when the board stays awake on purpose. How long that window is turned out to be the biggest factor in battery life (part 5).
No login means LAN only
The dashboard has no user authentication yet. So it stays on the trusted LAN, port not exposed, MQTT with credentials. Login and per-user permissions for the command side are first on the list before this could run anywhere else.
Takeaways
- Pulses, not on/off. Every action has an end built in.
- Safety in firmware, convenience in the UI, and a physical switch under both.
- Availability via Last Will is the cheapest “is it there?” check MQTT gives you.
- Skipped beats late for anything that moves water.
- Ask the device what it’s running.
Next in this series: 72 Hours on Battery, and the Winter Firmware That Sleeps by the Clock
Part 4 of 8. Start with the series overview.