When I realized there was a leak in my home, I knew it was time to put my expertise to work. I needed to call on my years of experience and passion for my job - as a software engineer? While at first glance, it may appear that a plumber would have been a better option, my argument is that there is a step to be taken before a plumber is even involved to fix a leak. And that is to detect the leak when it first happens.
Sure, I could have a plumber on call who checks for leaks every day, but seeing as that’s not an effective use of time or money, we needed to find an alternative to waiting for the problem to become bad enough to become a major problem. So if a 24/7 plumber-butler wasn’t an option, I thought some kind of automated system would be more realistic.
As it turns out, I had been thinking for some time about how to use a Raspberry Pi with Courier to bring notifications to life. This happened to be a perfect use case to try it out, so I decided to invest in the appropriate hardware and make use of my own software development skills to make sure that I would get a notification any time there was even a small leak in my home. This way, I’d know to call the plumber and handle the problem before it became too big to handle.
I myself had a water leak in my apartment some time ago. Because I didn’t know there was a problem until it was already too late, I had to call for a plumber when the damage was already done. Even for a simple leak like this, I ended up spending more than $500 to fix it.
But things could have been much worse. Major damage is often caused by mold spores.
Water leaks may also cause structural damage to property. Walls start swelling and warping, leading to cracks and holes in them. Furthermore, water leaks may negatively impact the value of a home.
I never wanted to deal with the complications, so I decided to take matters into my own hands. But of course, it was important to find a solution that would be fun and interesting as well as useful.
During my research for a solution in the form of alerts for water leaks, I found that I could use a small, affordable Raspberry Pi single-board computer to achieve my goal. With this tiny computer, I could read signals from my water sensor and then send those signals to my monitor.
To develop the project, which I called potential-octo-lamp, I first got all the hardware I needed to detect water leaks and connect to my computer. These devices included:
- Raspberry Pi 4 Model B
- Floor Water Sensor for Flood and Leak Detection
- SanDisk 128GB Ultra MicroSDXC UHS-I Memory Card with Adapter
With Courier, I could create custom alerts and define their titles and body text. I could also specify the communication channels through which the alerts should go and the recipients of these alerts. I also added a Twilio integration on Courier to deliver the contents of my alerts through the channels I specified — in this case, SMS and email.
Luckily, I’m a really nice guy and have made potential-octo-lamp open source. You can use my program to protect your own home from water leaks. Once you have all the hardware requirements listed above, connect your Raspberry to your water sensor. If you need help setting them up, this tutorial will help. Then you can begin using potential-octo-lamp to receive alerts for water leaks in five easy steps:
If you don’t already have Courier and
Twilio accounts, you’ll need to sign up for both to configure your alert system. You may sign up for free on Courier and Twilio using an email address. Courier also allows you to use your Google or GitHub account to create an account.
Start by getting your Account SID, Auth Token, and messaging service SID from Twilio. Then log into your Courier account and go to Integrations. Add the Twilio info to their corresponding fields in Courier.
When you create an account with Courier, you get an Auth Token so that you can safely make requests to and from Courier. Once logged in, you may retrieve your Courier Auth Token from the API keys page in Settings.
Next, go to GitHub and clone potential-octo-lamp. Because it’s unsafe to input your Courier Auth Token directly in your code, create a .env file and add it there. That way, it’s only visible to you.
Finally, run the following commands one after the other to install dependencies and start checking for water leaks:
npm run build
npm run start
As soon as your floor water sensor detects leaks, potential-octo-lamp sends alerts for water leaks to the recipients you added on Courier. Then you can quickly repair the leak to prevent further damage.
Potential-octo-lamp is open-source, so you can clone it and use it yourself. Any improvements or suggestions you may have are also welcome. You can raise an issue or reach out to me if you’d like to contribute to the project!