Tech • AI • Robotics • Game

ENFR

I wired my toilet to a Raspberry Pi

3/10
AINetworkChuckNovember 11, 2026 at 05:24 PM11:02
Audio player

TL;DR

A home lab experiment gave a toilet its own IP address using a Raspberry Pi and a float switch to log flushes and correlate them with unexplained network outages.

KEY POINTS

Why the toilet was monitored

The project started with a practical troubleshooting problem: every time the toilet near a workspace was flushed, computers briefly lost access to a NAS and even the internet connection appeared to dip. The goal was to capture the exact moment of each flush and compare that timestamp with network events, rather than relying on guesswork.

Simple hardware setup

The build used an older Raspberry Pi 3 Model B+, chosen mainly for its GPIO pins, along with a cheap float switch mounted inside the toilet tank. The switch rises when the tank is full and drops when water drains during a flush, turning the falling water level into a simple on-off electrical signal.

How the sensor works

The float switch contains a small magnet and metal contacts inside a sealed tube. When the water level falls, the float changes position and closes the circuit. Two wires were connected from the switch to the Pi, using pin 9 for ground and pin 11, mapped as GPIO 17, for input.

Software logic on the Pi

The Pi ran Raspberry Pi OS Lite 64-bit and polled the sensor every 0.1 seconds. A built-in pull-up resistor held the input at 3.3 volts when the switch was open, preventing random electrical noise from creating false flush events. When the float dropped and connected the input to ground, the state changed from high to low and the system registered a flush.

Event logging and network visibility

Flush data was written to a state.json file so the timing could be compared with other logs. The toilet also received its own local IP address, 10.77.14.178, making it a visible endpoint on the home network and turning a bathroom fixture into a basic observability tool.

Installation inside the tank

Mounting the sensor was done with zip ties and an improvised support piece, creating a functional but visibly makeshift installation. The process required several attempts to keep the wiring positioned correctly and avoid water contact in the wrong places, but the final placement allowed the switch to move reliably with the tank’s water level.

Successful flush detection

Live testing confirmed the system worked: a real flush triggered the sensor and produced an immediate event. The setup was also tuned so very brief movements would not count, helping distinguish a genuine flush cycle from quick accidental motion or bounce in the switch.

Slack alerts for the team

Flush notifications were sent into Slack, allowing others in the workspace to see when a bathroom event occurred that might line up with a network interruption. That turned the project from a joke into a lightweight diagnostic mechanism for a strange infrastructure issue.

Broader lesson about observability

The toilet monitor doubled as a demonstration of a larger IT principle: unusual outages are often solved by collecting precise signals around the time of failure. In this case the signal was a toilet flush, but the same idea applies to production systems, where correlating logs, sensors, and event timing can reveal hidden causes of disruptions.

AI security tie-in

The experiment was also used to highlight how correlation becomes more important as organizations deploy AI agents with access to real infrastructure. A referenced security scenario showed an AI application manipulated by prompt injection, leading to code execution, theft of cloud credentials, a reverse shell, and attempted database exfiltration. The point was that modern systems need connected telemetry across application logs, cloud trails, DNS activity, and host sensors to identify complex attack paths quickly.

CONCLUSION

The project showed that a toilet can be turned into a networked sensor with inexpensive parts and a few lines of logic. More importantly, it underscored a core operational truth: even absurd data points can become useful when they help explain real system failures.

Ask a question

More from AI