top of page
IMG_20250213_211117.jpg

Leak Sensor

Leak sensors can be attached to either the Pi-hat or the sensor module. They can save you and your floor in the case of a leak.

​

They are triggered by getting wet and can trigger alarms and automations. Every seting should have at least one Leak sensor.

​

Here is how to set one up...

Leak Sensor

Binary sensor

A 5V leak sensor detects the presence of water or other conductive liquids. It typically consists of exposed conductive traces on a flat surface or probe. When liquid comes into contact with these traces, it creates a conductive path, allowing a small electrical current to flow. This change is detected by a connected microcontroller or circuit, triggering an alert or action. The sensor operates at 5 volts, making it compatible with devices like Arduino, ESP32, or Raspberry Pi, and is commonly used for leak detection in aquariums and sump systems.

Hardware conection

How its conected

Each leak sensor has three wires. Ground, 5V and signal. they need to be conectect to the coresponding pins on the sensor module or pi-hat. Place the sensor in a place where it would get wet first in case of a leak, underneath the stand or plumbing for example.

​

If needed you can extend the wires and I recomend testing the sensor with a multimeter to be sure its working. I would also recomend using Epoxy resin to water proof the side of the PCB that shouldnt get wet.

Software setup

Checking the Code

In your dashboard you can create a card showing the status of the Three Leak sensors

​You can edit the card to show a different icon as shown here and also give a custom name.

​

Using the data provided from the sensor you can create automations as you see fit, or trigger an alarm.

opticalDash.png

If you installed the code correctly when doing the setup you shouldn't have much to do here. HA should recognise the sensor and show it on the dashboard where you can see its output, If not you my need to add a card.

I recomend going into the code and changing the name of each sensor so you know what is linked to what. here is how to do that

  1. Ensure everything is on and running correctly

  2. Go to ESP home and click on edit to open the code.

Floatcode.png

The code for the Leak sensors is located here and looks as shown here.

There are six elements:

  • Platform: set to Gpio as the optical sensor use the gpio pins on the esp32.

  • Pin: The number of the Pin that this switch is conected too.

  • Inverted: Changes the working state On to Off in this case

  • Mode Input: defines this pin as an input

  • Mode Pullup: enables the internal resistor to reduce false triggers

  • Name: Here you can set the name to what ever you would like, in this example I have it set to have the name "Leak1" and "Leak2"

​

You can change the name here to whatever you like, you can also chance it in the dashboard too.

Photos...

IMG_20250213_211136.jpg

Leak Sensor

IMG_20250213_211117.jpg

Leak Sensor

Links

Here are a few links to where you can purchase your sensors, click the link depending on your location.

​

Worldwide link generally takes longer to be delivered but is a little cheaper. Better if you want to bulk order.

​

Me Personnaly I order most of my stuff from Aliexpress, it normally gets here fairly quickly and tends to be a little cheaper.

If I need something quick I order from amazon.

Full disclosure: some of these links are affiliate links, clicking them and purchasing though my links helps me support the project.

bottom of page