Float Sensor
Binary sensor
A float sensor is a device used to measure the level of liquid in a tank or container. It typically consists of a buoyant float that rises or falls with the liquid level. The float is connected to a switch, lever, or sensor mechanism that detects its position. As the float moves, it triggers an electrical signal or mechanical action, indicating the liquid level. Float sensors are commonly used in water tanks, fuel systems, and industrial applications to monitor and control fluid levels.
The Pi-hat module has ports available to connect these and the sensor module has 6 dedicated ports for float sensors
Hardware conection
How its conected
Each float sensor has two wires, each one of these goes either side of a Float switch input on the sensor module. These sensors cannot be conected the wrong way. One wire goes to ground and one to the controller (ESP32), when the switch is activated the circuit is closed and the switch is active.
​
If needed you can extend the wires and I recomend testing the sensor with a multimeter to be sure its working.
Software setup
Checking the Code
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
-
ensure everything is on and running correctly
-
Go to ESP home and click on edit to open the code.

The code for the Float switches is located here and looks as shown here.
There are three elements to each float switch:
-
Platform: set to Gpio as the float switches 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 float senosr 1 set to have the name "float1"
​
You can change the name here to whatever you like, you can also chance it in the dashboard too.

In your dashboard you can create a card showing the float switch data, Here all 6 are shown but if you only need a couple you can remove the rest for a cleaner look.
​
You can edit the card to show a different icon as shown here and also give the switches a custom name.
​
Using the data provided from the float switches you can create automations as you see fit.
Photos...

Example of a float sensor

Float Sensor

Float sensors ports on sensor module

Marine assistant ATO with Two float sensors
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.