Over the Christmas break, my parents were out of town to celebrate the holidays. When they came back, they saw something every homeowner fears – a flooded basement. In a basement, there are pipes that collect water from around the foundation and bring it into the sump pit, which pumps it out away from the house. When the sump pump fails, water has no way to leave the basement and it floods.
I recently bought my first house, so this horror story is still weighing heavy on my mind. Our basement has a sump pit, but there isn’t a pump in the hole. Being the paranoid person I am, I saw two options: I could either poke my head down in the basement every time there’s a storm, or I can place a sensor near the pit to alert me.
Water alarms are nothing new; there are plenty of cheap ones on the market that will alert you with a loud piezo alarm when water touches the two sensing pads. But what if you’re out of town, or just out of the house? For that reason, I decided to make the ESP32 Water Alarm. Just like a standard water alarm, there are two electrical contacts that sense the presence of water, but instead of turning on audible alarm, it will send you a text message.
How does it work?
For this project, you can use either the ESP8266 Thing, or the ESP32 Thing. One of the many improvements made on the ESP32 is the capacitive touch circuitry built in to ten of the IO pins (we can see the pins capable of capacitive touch in the datasheet below). It should be noted though, that Touch1 cannot be used as capacitive touch sensor because of the pull-up resistor connected to GPIO pin 0. With the capacitive touch, we’ll be able to sense water with just two pins; the first will be connected directly to a capacitive touch pin, and the second will be connected to ground.
To receive a text message, I used the free (and beautifully simple) service If This Then That (IFTTT). IFTTT gives you a huge amount of control, from devices like smart switches and thermostats, to sending or receiving emails, to interacting with Twitter and much more. I combined two services: Maker, which receives a HTTP post from the ESP32, and SMS, which will send an SMS text message to the phone number you provide.
Read more: Creating a Smart Water Sensor with the ESP32 Thing