Friday, September 7, 2018

It's leaking

After living for several years in our house we decided to have all our window frames replaced by plastic window frames. No more painting. And plastic does not deteriorate like wooden frames do. So long story short it is done.

However a problem has risen. When the wind blows straight towards our house and it is pouring we have a leak. At one time we had a real puddle of water in our living room which almost ruined our parquet.

Second problem: we are not always at home. Therefore it would be nice when we had some kind of leak detection system.

ESP to the rescue

The hardware setup.

There was one spot where it was leaking under the above mentioned conditions which do not happen often luckily. So we put a reservoir below the window-still where the leak was occuring. That will take care of the water pouring from the leak. However how to know when we are not at home.

So I started testing if I could detect water with my ESP. And that proved to be easy.



I just attached a wire to ground and a wire to an IO pin (D1) and that was sufficient.

If you want to replicate this project attach a 10K pull up resistor to the IO pin for safety. I can not guarantee that your ESP will react to water like mine does !!

I powered it with a power bank which supplies enough current to last a day. So we have to recharge it every day. Forunately we do not need this every day as it is not storming all the time !! A USB charger can do the trick when you have no power-bank available.

The notification.

How are we to know that it is leaking. Well like most people today I carry my phone always with me. It is an Android Phone. The obvious solution is to have the ESP send a notification to Els's and my phone.

And that is easily done.

For this purpose I use ESP-Basic as it is the quickest way to implement a project.

What the software does is test if the IO-pin is pulled LOW (when water is detected) and then trigger IFTTT to send a message to my phone.

The Basic program



interrupt d1, [leak detected]

wait

[leak detected]
iftttkey = "YOUR IFTTT KEY"
trig = "maker.ifttt.com/trigger/Leak Detected/with/key/" & iftttkey
print wget(trig)
print "yep did it"

interrupt d1

wait


This is as simple as it can get.

An interrupt is initiated when IO-port D1 changes state. This jumps to the routine [leak detected]
The variable trig is then filled with the IFTTT key and recipes name. And a wget command send the data to IFTTT


IFTTT

I am not going to write down how IFTTT works as you can read that in my 4 part story published on this weblog. Click here for the Index to my webpages and look for the IFTTT stories. Read them and it will be clear how IFTTT works.




I just give you here my IFTTT recipe which is self-explanatory.

And it works !!




Above you can see the complete setup.



Here you can see that the IFTTT recipe was triggered.

We are just still waiting for the repairs to happen.

Till next time.
Watch the flooding and have fun !!!

Luc Volders