top of page
IMG_20250211_203932.jpg

Float Sensor

A float sensor is exactly what it sound like the sensor floats on the surface of the water to "activate" a switch.

​

The come in many differnt forms and price ranges but essentially all do the same thing.

​

Here is how to set one up....

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

  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 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.

FloatDash.png

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...

IMG_20250211_203923.jpg

Example of a float sensor

IMG_20250211_203903.jpg

Float Sensor

IMG_20250211_203944.jpg

Float sensors ports on sensor module

IMG_20250211_204037.jpg

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.

bottom of page