Once, on a beautiful Saturday morning, I heard a loud pop sound in the house. Suddenly, our cat, Mirella, was acting weird. She arched her back and started walking in circles near the basement entrance. When I approached her, she led me downstairs. That’s when I found nearly an inch of water in the basement. The pop sound was the backflow preventer valve exploding.
Due to Mirella’s insistence, there was no permanent damage. Sure, Saturday was completely ruined. But it was still a better outcome than extensive damage, restoration, or mold cleanup. A couple of hours of mopping and additional ventilation brought the basement back in working order.
Since then, I have been obsessed with detecting leaks in the basement. With the amount of plumbing in my basement, it’s only a matter of time until another leak springs another surprise. There are too many points of failure in this old house. It could be a busted heating system, leaky laundry machine, or an overflow in the bathroom.
Selecting the right water leak detector
The first thing I bought was a 110 dB battery-operated water alarm. But the battery required extra monitoring from me. Also, a loud alarm causes so much stress to our pets but will never reach me when I’m away from the house. So that solution was not sufficient.
Then I looked into systems with whole house water shut-offs. But they still relied on regular sensors to detect water. They required a professional plumber to install. They are expensive. So, in the end, the water shutoff system was an unnecessary add-on.
Finally, I decided to tinker with my sensors to build a water detection system that is: highly configurable, inexpensive and sends smart notifications. I made such a system, so let me share with you how it looks.
Here’s easy to program microcontroller that’s also WiFi-enabled. It can work off a battery pack or simply plug it into a switch. It comes in a pack of three. Create three separate water detectors for a heating system, a laundry machine, and a bathroom.
Here’s a pack of water detecting sensors. They offer a great way to detect a leak, spill, flood, rain, etc. Use them to check for the presence, level, volume, or absence of water. The sensor has an array of exposed traces, which indicate LOW when water is detected.
Putting them together is simple. I chose to power the sensor with the VIN pin to give it close to 5v of power. However, this setup can still work with drawing 3.3v power to the sensor. Then, connect the S (signal) pin to A0 (analog) on the microcontroller.
Note: Yes, I know that three microcontrollers and 5 sensors don’t match up. But neither does a 10 pack of hot dogs and an 8 pack of hot dog buns.
Program the device (with Zentser)
There are two main steps to tie your hardware to a smart cloud-enabled mobile app.
1. Partition the device in Zentser
Download the Zentser app (iOS or Android.) Sign up. Create a new device. Then copy the certificates and IDs for your partitioned device to be used in coding later.
2. Flash your device with custom code
In Arduino IDE (download), go to Tools > Manage Libraries. Install ‘Zentser ESP SDK’ and its dependencies.
Then you can use the following code. Make sure to replace the WiFi credentials with your SSID and password. Then replace the certificates and IDs that you got from a step above and paste it between the “// --- START ---” and “// --- END ---” lines.
After you compile and upload the code, you should see in Serial Monitor that the device is sending information.
Now just repeat the steps for creating a Leak Detector Device number two and number three.
Configure and Test
This is the final fun part. It’s where you get to see your creation come to life.
Go into the Zentser app, you should see some latest values recorded from your Leak Detector. In the perfect dry environment, you should see a meager presence of water (less than 5%.)
Set up the alert to notify you when the sensor reads a value over 5%. If you placed the sensor in a dry place, it should trigger a warning in case there’s even a milliliter of water. I mean, in case there’s even a 1/32 of an inch of water.
You can see a simple test. Then after you see the triggered warning, wipe everything, including the sensor. That’s it. You should be good to go.
If you found value in this project or want me to improve it even more, let's talk directly on the official Reddit page.
Looking forward to your feedback!