A couple of weeks ago I wrote about my re-discovery of the fascination and use of the electronics kits I experimented with in my youth and how I wanted to make good use of them again in combination with a Raspberry Pi. The project I had in mind and which has borne some fruits now is a water alarm system with Internet connectivity.
I'm a practical guy so playing around with new hardware and software always has to have an application for me. When you enter the kitchen in the morning and are welcomed by a pool of water on the floor you instantly know something is wrong. In my case it was a leak in the rooftop that subsequently proved to be a bit difficult to find so we went through a trial and error phase. During the trial and error phase I wanted to know at once when water started accumulating on the kitchen floor again to take the appropriate counter measures.
A perfect application for the Raspberry Pi that could warn me of a new water pool building on the floor via email. The Pi itself has some I/O pins that are, however, not well protected so I decided to buy one of the hardware extension boards that offers buffered and protected I/O ports. There are a number of different boards available and my choice fell on the Pi-Face as it's the same size as the Raspberry Pi and hence I could fit it into a small casing. As the Pi-Face is only a generic I/O board I needed additional hardware to detect water on the floor. This is were my electronics kit came in for prototyping a detector as seen on the first picture on the left.
Once this was working I decided to go for the real thing and build five of those sensors on a real board so I could place five detectors at different locations on the floor. The second picture on the right shows how the final solution looks like: The casing contains the Raspberry Pi with a tiny Wi-Fi adapter below the PiFace which is connected to the self made electronic board via a number of cables. From there 2x five 3m sensor cables leave the casing on the right to different locations on the floor. On the other end I just taped the uninsulated cables to the floor. Water between the ends of two cables change the resistance between the two cables which is detected by the detector on my self soldered board.
When one of the detectors on the board recognizes a change in resistance at the end of the cable it drives an input port on the PiFace which in turn is detected by a Phython program running on the Pi. The Phython program in turn will immediately send me an eMail to notify me of the event. The program also sends me regular status updates of all input ports and also notifies me in case an input is switched off again, i.e. the water has disappeared again.
Sending an email with Python by the way is pretty much straight forward as there are already libraries that can even handle encryption via secure SMTP. I've attached the source to this part of the program at the end of this post as this could come in quite handy for other projects you might to want to try.
Quite frankly I wouldn't have gone through the whole thing if I just had a water leak. But a RasPi project, real world interaction, connectivity to the Internet, a little electronics project and a real world problem to solve was too hard a thing to resist.