Buying guide · Intermediate · 3 min read
Liquid Level Sensors
Float Switches, Non-Contact, Ultrasonic and Submersible
By Geekobot Learning Team · Updated 29 Oct 2026
On this page
The right liquid level sensor depends on whether you need a single trip point or a continuous reading. Float switches are cheap, reliable point sensors. Non-contact capacitive sensors stick to the outside of a plastic or glass tank. Ultrasonic sensors read the distance to the surface from above. Submersible pressure sensors measure depth in tanks and wells. Avoid bare PCB probes in water, because they corrode.
Key specs at a glance
- Float switch
- Point level; reed switch rated about 10 to 50 VA; mounts vertically or horizontally
- Capacitive non-contact
- Point level through up to roughly 20 mm of plastic or glass wall
- Ultrasonic
- Continuous distance, dead zone of 2 to 25 cm depending on the sensor
- Submersible pressure
- Continuous, 0 to several metres, 4-20 mA, 0.5-4.5 V or RS485 output
- Bare conductive probes
- Cheap but corrode quickly; use for short tests only
Choosing a level sensor
First decide between a point sensor (full, empty or a trip level) and a continuous sensor (percentage full).
| Type | Reads | Pros | Cons |
|---|---|---|---|
| Float switch | One level per switch | Cheap, rugged, no electronics, handles pump loads through a relay | Moving part can stick; foam and debris interfere |
| Non-contact capacitive (XKC-Y25 / Y26 style) | One level per sensor | No wetted parts; works on plastic and glass tanks | Fails on metal tanks; position-sensitive; sensitivity tuning |
| Ultrasonic (from above) | Distance to the surface | No contact; continuous reading | Dead zone near the sensor; foam and steam give errors |
| Submersible pressure transducer | Depth from the bottom | Accurate; works in wells and deep tanks | Sits in the liquid; needs cable and an amplifier or 4-20 mA input |
| Optical / infrared prism | One level | Small, quick, no moving parts | Only for clean liquids |
| Bare PCB water-level module | Rough wetness | Cheapest | Electrodes corrode; best for demos |
- Float switch
- Reads:
- One level per switch
- Pros:
- Cheap, rugged, no electronics, handles pump loads through a relay
- Cons:
- Moving part can stick; foam and debris interfere
- Non-contact capacitive (XKC-Y25 / Y26 style)
- Reads:
- One level per sensor
- Pros:
- No wetted parts; works on plastic and glass tanks
- Cons:
- Fails on metal tanks; position-sensitive; sensitivity tuning
- Ultrasonic (from above)
- Reads:
- Distance to the surface
- Pros:
- No contact; continuous reading
- Cons:
- Dead zone near the sensor; foam and steam give errors
- Submersible pressure transducer
- Reads:
- Depth from the bottom
- Pros:
- Accurate; works in wells and deep tanks
- Cons:
- Sits in the liquid; needs cable and an amplifier or 4-20 mA input
- Optical / infrared prism
- Reads:
- One level
- Pros:
- Small, quick, no moving parts
- Cons:
- Only for clean liquids
- Bare PCB water-level module
- Reads:
- Rough wetness
- Pros:
- Cheapest
- Cons:
- Electrodes corrode; best for demos
Wiring and electrical notes
Float switches are dry contacts: wire one side to GND and the other to an Arduino pin set to INPUT_PULLUP. Non-contact and optical sensors usually have an NPN or PNP output and need 5 to 24 V; read the datasheet for which level means "liquid present". Never connect a 12 or 24 V output straight to a 3.3 V board; use a divider or an optocoupler.
To switch a pump, drive a relay module from a pin and follow the module's isolation and rating notes. Mains pumps need a proper enclosure and earth.
Pump control with two floats
Using a low and a high float gives built-in hysteresis, so the pump does not chatter near one level. The pump starts when water falls below the low float and stops when it reaches the high float.
const int LOW_SW = 2; // closes (reads LOW) when water is above the low float
const int HIGH_SW = 3; // closes (reads LOW) when water reaches the high float
const int PUMP = 8; // relay module input
bool pumping = false;
void setup() {
pinMode(LOW_SW, INPUT_PULLUP);
pinMode(HIGH_SW, INPUT_PULLUP);
pinMode(PUMP, OUTPUT);
}
void loop() {
bool aboveLow = digitalRead(LOW_SW) == LOW;
bool atHigh = digitalRead(HIGH_SW) == LOW;
if (!aboveLow) pumping = true; // tank is low: start filling
if (atHigh) pumping = false; // tank is full: stop
digitalWrite(PUMP, pumping ? HIGH : LOW);
delay(200);
}Getting reliable readings
- Mount floats away from inlets, where splashes and turbulence make them bounce.
- For ultrasonic sensors keep clear of tank walls and pipes in the beam, and allow for the dead zone when choosing mounting height.
- Add a timeout so the pump stops if the tank never fills, which protects a dry-running pump.
- In tanks with chemicals or hot liquid, check the material and temperature rating of the float or sensor.
Try it: Water tank level calculator (ultrasonic sensor to litres)
Change the values and the diagram and results update as you type.
Common mistakes to avoid
- Using bare PCB probes in a tank for weeks and watching them corrode.
- Mounting an ultrasonic sensor inside its dead zone.
- Putting a capacitive sensor on a metal tank.
- Running a pump from one level with no hysteresis.
- Wiring a 24 V sensor output to a 3.3 V pin.
Frequently asked questions
What is the best sensor for a water tank?
For on/off pump control, two float switches. For a percent-full display, an ultrasonic sensor or a submersible pressure sensor.
Do non-contact sensors work on metal tanks?
No. Capacitive sensing needs a non-metal wall.
Can I use an HC-SR04 for tank level?
Only for demos. Use a waterproof ultrasonic sensor such as JSN-SR04T for damp tanks.
How do I stop my sensor false-triggering?
Add a delay or debounce time and use hysteresis. Floats in waves can bounce.
NPN or PNP output?
NPN sinks to ground when active; PNP sources voltage. Match your controller input.
Can a float switch run a pump directly?
Only if its current rating exceeds the pump's. Usually the float drives a relay or contactor.
Parts for this guide
Terms in this guide
Projects that use it
Put this into practice: 14 step-by-step builds in our project library use parts from this guide.
Keep learning
Sources
- XKC-Y25 and XKC-Y26 manufacturer datasheets
- Reed switch float sensor datasheets (Celduc, TE Connectivity)
- DYP and JSN-SR04T ultrasonic datasheets
Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.




