Project update 3 of 17
Okay, now that the storm is over I can update you on how HestiaPi Touch saved my (basement’s) life during the Christmas holiday.
I was working in my basement when I realised there was a leak and drips of water were coming down from the ceiling. Naturally, I put a bucket underneath and went ahead to identify the actual problem. About an hour later I had found the cracked pipe, but the plumber wouldn’t be coming for a week.
Threat Level: Substantial |
So, I thought, oh well, I’ll be emptying the bucket once a day and I can survive. As the flow was not regular, I ended up having to check twice a day. One morning I was greeted by water on the floor. :( Not your average holiday morning.
Threat Level: Severe |
So, I did what every hacker does in these situations - I got my electronics parts box out and fired up my favourite code editor! A couple of hours later I had a larger bucket to collect the water, a water level indicator inside it, a threshold set, and notifications enabled on my phone. Oh, and a graph of the level against time.
Network coverage was not great, so I colour coded the age of “Last Message” timestamp to spot outdated info.
A NodeMCU was checking the analog value of the water level sensor and sending it to HestiaPi (OpenHAB) via MQTT over Wi-Fi. A few extra lines in items, rules, and sitemap file and it was live. I could finally relax by the fireplace… Or so I thought.
I checked level before going to bed. I woke up in the morning to another flooded basement. :( Someone from our building used the washing machine, which produced a lot of "drips" overnight, overfilling the bucket. You can guess the rest.
Threat Level: Critical |
It became obvious that notifications were not enough and my system had to react to the water level! I had a little 12 VDC pump for a pond project I never used, so by adding a relay in the digital pins of NodeMCU, adding one more line of code, and subscribing to a different MQTT topic (hestia/flood/pump), I could control the pump from my phone. A hose would send the water out through a ventilation hole.
Lastly, I created a rule to turn the pump on when the level is above the threshold and let me know with a notification on start and end of the pumping. To fine tune it, I added another threshold for a minimum and maximum level to avoid turning the pump on for a few seconds too often.
The flood level reported is inverted: 102 (a.k.a. int(1024/10)
) means no water, 0 is fully submerged.
Okay, I am biased, but I really loved how quick and easy I could build from scratch such a system, especially during the time of year that coding and soldering should be left aside.