The problem
Overhead water tanks in Pakistani homes run dry without warning, and pumps get left on until they overflow. I wanted to know the level from my phone and get a nudge before either happened.
What I built
An ultrasonic sensor on a microcontroller measures the level and pushes readings over Wi-Fi to a small Node service. A React dashboard shows the current level, the last 24 hours of usage and pump state, and sends an alert when the tank drops below a threshold.
Decisions worth mentioning
- Readings are averaged on the device. Ultrasonic sensors are noisy over water; a rolling median on the microcontroller means the dashboard doesn't jitter and the server stores one clean sample a minute.
- Push, not poll. The server broadcasts new readings over a WebSocket so the dashboard updates live without hammering a tiny board with requests.
- Runs on nothing. The whole backend fits in a few megabytes of RAM, which is the same instinct behind how this site is hosted.
What I'd do differently
- Add a second sensor. One ultrasonic sensor over a sloshing tank is fine, but a cheap float switch as a sanity check would have caught the one bad week of readings sooner.
- Log to disk on the board. If the Wi-Fi drops, readings are lost; a small ring buffer that flushes on reconnect is a few lines and would have made the chart honest.
Outcome
Running at home. Small, but it's mine end to end, from the sensor to the chart.