Water Detection System
About the project
Get notified of water wherever you are
Project info
Difficulty: Easy
Platforms: Particle
Estimated time: 1 hour
License: Apache License 2.0 (Apache-2.0)
Items used in this project
Hardware components
Story
Disaster can be around the corner
A pretty frustrating situation one can experience in North America, at least in the parts of North America where houses have basements, is to go down your basement one day and find it with ten centimeters of water. What is worse, this could have happened in the past week or so, and one never realizes it until their feet get wet when going to get that expensive wine from the cellar!
Another bad experience could arise from your beautiful aquarium, when something goes wrong with it while you are not there. This can potentially damage your property and your neighbor's one floor below! Not only that, what is going to happen to your beautiful clown fish if you don't get there on time?
I remember when my neighbor next door told me the story about his water heater reaching its end of life and started leaking water. It wasn't long until his family realized that the hot water was not hot anymore, just that it was during a weekend when plumbers are more expensive to call. Ouch.
And even if you don't have a basement or an aquarium (or a water heater?), a pipe is a pipe, a sump-pump is a sump-pump, a dishwasher is a dishwasher and a washing machine is a washing machine, and something could go wrong with any of them at any point in time, creating the unexpected kind of trouble nobody was ....errr.... expecting!
Solutions can be around the corner, too
I hope I did not scare you big time with the previous list of potential disasters.
So, for being better prepared for the unexpected, or at least to be aware of such a situation right away, we will use a Particle Photon and a water leak sensor, that's it!
Ok, ok, maybe we'll use some bits on the internet, plus some more on your router, and surely some on your phone.
The architecture
We want instant alerts if water is detected, and instant alerts for me today mean receiving a notification on any (or all) of my devices -- that could be my phone or my computer.
Instant alerts in all your devices thanks to Pushbullet, webhooks and the Particle CloudThis is how it works:
- The firmware running in the Particle, will publish a cloud event once water is detected.
- This published cloud event in turn will get intercepted by a webhook living in the Particle cloud.
- This webhook will push a notification to Pushbullet.
- Pushbullet in turn, will push it to our devices.
The hardware
1- The Particle Photon
In case you did not know what a Particle Photon is, it is a great Arduino compatible WiFi development kit that allows us to connect many types of sensors to the internet. Wait, that was incomplete... The Particle Photon allows us to connect many types of things to the internet, be it a sensor, another device, a garage door and why not, a water sensor.
The Particle Photon comes standard with a Particle cloud platform, and it brings with it browser-based, wireless flashing!
; ; 1 / 3 • Ohhh the cloud...2- The water leak sensor
Think about it: for water detection we could just use two exposed wires, since water is a great conductor. If the wires are close enough, once water touches them it will shortcut them and this would be easy to detect with a digital input in our Particle Photon.
Now think about it again: will our project look professional and beautiful? Hum, maybe not.
So for beauty's sake we will buy something better looking than simple, exposed wires: its evolution!
; ; 1 / 2 • The beautiful water leak sensorWe will profit from the Particle's internal pull-up resistors and connect the water leak sensor between ground and the digital input D0.
Note: if you want to monitor different spots, you can connect more water leak sensors to different digital inputs in the Particle (and modify the firmware accordingly) or connect the sensors in parallel like it is described in this project.
The software
There are two parts to this equation:
- the firmware - flash it in your Particle and you are ready to go
- the webhook - requires some configuration, see below
Configure the webhook to connect to pushbullet
Head to the pushbullet site, sign up for an account if you don't have one already and get your Access Token from the settings page.
Note: do not share this Pushbullet Access Token, since it grants access to your account!
Now save in your computer the webhook code (find it in the software section below) in a file named webhook.json.
Edit the webhook.json file just created and replace your Access Token in the Bearer field (you have to replace 123456789012345678901234567890 with your Access Token). Save and close the file.
Once the file is edited with the token, you are ready to upload this webhook to the Particle cloud.
Configure the webhook in the Particle cloud
Webhooks are configured via the particle CLI. If you don't have it installed already, please do so following the instructions here.
Once installed, open a console and type:
particle webhook create webhook.jsonThe output of that command would look like this:
Using settings from the file webhook.jsonSending webhook request { uri: 'https://api.particle.io/v1/webhooks', method: 'POST', json: { eventName: 'pushbullet', url: 'https://api.pushbullet.com/v2/pushes', requestType: 'POST', headers: { Authorization: 'Bearer 123456789012345678901234567890', 'Content-Type': 'application/json' }, json: { type: 'note', title: '{{SPARK_EVENT_VALUE}}', body: '' }, mydevices: true, event: 'pushbullet', deviceid: undefined }, headers: { Authorization: 'Bearer skljhklasjhdfjklhasdkljfhklasjhdf' } }Successfully created webhook with ID 1234kljhl123h41234jklhThat means the webhook got configured correctly.
In action!
To test everything is properly configured, drop the water leak sensor in a glass of water and observe that the on-board led in the Particle dev kit will light up.
Ten seconds after, you should receive a notification in your devices, be it your phone or your computer (this requires a pushbullet app installed).
If the condition continues (ie: water is detected), the notifications are configured to be sent as follows:
- at 10 seconds,
- at 1 minute,
- at 5 minutes
- at 15 minutes,
- at 1 hour,
- every 4 hours ever after, until the situation gets rectified
The end
So, did you build something similar? are you planning to? any questions?
leave me a note below,
Gustavo.
Psst: please find my other projects here.
Help
If you require professional help with your projects, don't hesitate to write me a line about your needs at gusgonnet@gmail.com. Thank you!
Leave your feedback...