Inspired by the work of
- Rob from The Hookup - https://www.youtube.com/watch?v=2kLZ7DlP9KU and
- Peter Jennings - ESP8266 Water Alarm
My GitHub project is here - GitHub - alekseyn1/WaterSensor: MQTT water sensor
I was looking around for a while for a sensor that would be
- battery operated
- wireless
- small
- with battery life from one year
- would use MQTT
and found nothing.
I had to come up with something on my own.
Out of the box solutions like Xiaomi sensors were not acceptable since they use an additional hub that I did not know would work on the local level or not (my aim is to keep all smart home traffic within the LAN). Other solutions would either be non-smart with great battery life of be smart with a very short battery life (a couple of months).
Then I ran into Robâs (The Hookup) window sensor - https://www.youtube.com/watch?v=BoYVr2UwWWg I immediately tried his setup but instead of the reed switch I was hoping to use water to complete the cirquit. No luck. Water is not a good conductor in this case. So I had to look elsewhere. But I took his code for ESP-01 and modified it slightly (âon/offâ instead of âopen/closeâ although this modificatin might not be required).
I found a few circuits that could work for my purpose but I do not have enouth electronics knowledge to check if they are functional.
Source - https://www.instructables.com/id/Simple-Water-Sensor/
Then I ran into Peter Jenningsâ work on his water sensor - ESP8266 Water Alarm. The switch he used was an answer - Pololu - Mini Pushbutton Power Switch with Reverse Voltage Protection, LV.
I contacted Peter and he confirmed that in a standby mode the switch was not consuming much at all (official spec says 0.01 micro Amperes).
Here is how you hook up ESP-01 to FTDI:
Then flash it using the ESP-01_Water_Sensor.ino file
Here is the final connection diagram:
ESP-01 code and Home Assistant samples are in the files of this repository.
Here is the video with the final look of the sensor.
So, the end result works like this: once water is closing the sensor probes (basically two wires sticking out), the switch turns on ESP-01 and ESP-01 boots up and sends an MQTT message with âonâ to a topic and then goes into a deep sleep. The whole process takes about 3 seconds in my case. All other actions are triggered in Home Assistant using automations and scripts.
In my setup, Home Assistant will then send a command to the dry contact switch (modified Sonoff) to close the Electric Manipulator Shut Off Valve gizmo that I purchased on Amazon. I retrofitted a polarity switch and power input jack.
Here is the video with the valve setup.
Hope this helps!