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

Grove - Water Sensor Grove - Water Sensor you can get one of these, or just search ebay for "water leak sensor" to get an alternative x 1
Particle Photon Particle Photon you can use a Photon or a Core (you do not need both) x 1
Particle Photon Particle Photon you can use a Photon or a Core (you do not need both) x 1

Software apps and online services

Pushbullet Pushbullet

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 Cloud

This is how it works:

  • 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 / 3Ohhh 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 / 2The beautiful water leak sensor

We 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.json

The 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 1234kljhl123h41234jklh

That 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

Flood notifications in your phone!

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!

Schematics, diagrams and documents

waterLeakSensor.jpg

We connect the water leak sensor to GND and D0 since we use the Particle's internal pull-up resistor

Code

Particle firmware

paste this code in Particle Build, then add the elapsedmillis library.Flash and enjoy!

pushbullet webhook

You need to configure this in the Particle cloud

Credits

Photo of gusgonnet

gusgonnet

If you need professional help with a project, contact me at gusgonnet@gmail.com

   

Leave your feedback...