Back to Sensors & Actuators Series

Float Switch Liquid Level Sensor

April 10, 2026 Wasil Zafar 7 min read

Float switch deep dive — reed switch actuation, buoyancy physics, pump control, Arduino code, and water tank/appliance applications.

Contents

  1. Working Principle
  2. Electrical Characteristics
  3. Interfacing with MCU
  4. Calibration
  5. Code Example
  6. Real-World Applications
  7. Limitations

Working Principle

A float switch is the simplest liquid-level sensor: a buoyant float containing a permanent magnet rises and falls with the liquid level. When the float reaches a reed switch mounted at a fixed position, the magnet actuates the switch, opening or closing a circuit. The output is purely binary: level above or below the threshold point.

Types: Vertical stem (common in tanks), horizontal side-mount (for wall installation), multi-point (several reed switches at different heights on one stem), and cable-suspended (for deep tanks). The reed switch is sealed in glass, making it intrinsically waterproof.

Electrical Characteristics

ParameterTypical Value
Output TypeNormally Open (NO) or Normally Closed (NC) contact
Switch Rating0.5 A @ 100 V DC (typical reed switch)
Contact Resistance<200 mΩ
Supply VoltageNone required (passive switch)
Operating Temperature−10 to +85 °C (PP plastic), +200 °C (stainless steel)
Buoyancy RequiredLiquid density >0.75 g/cm³ (won’t float in gasoline)
Hysteresis5–15 mm (prevents rapid on/off at threshold)
MountingVertical stem (3/4″ thread) or side-mount (horizontal)

Interfacing with an MCU

Wire like any mechanical switch: one terminal to a GPIO pin with INPUT_PULLUP, the other terminal to GND. When the float reaches the reed switch, the circuit closes and the pin reads LOW. No power supply, debounce IC, or analog conversion needed.

Direct relay control: Float switches can directly switch small pumps (<0.5 A) or relay coils without any MCU — making them fail-safe for critical level protection even if the controller fails.

Calibration

  • Mounting height: Set the switch at the desired trigger level; the float actuates ±5–15 mm around the reed switch position
  • Hysteresis: The switch turns on and off at slightly different levels (built-in hysteresis prevents chattering)
  • Debounce: Add a 50 ms software debounce in case of mechanical bounce during transition

Code Example

/*
 * Float Switch — Arduino
 * Wiring: One terminal → Pin 4, Other → GND
 * Uses INPUT_PULLUP; LOW = switch closed = level reached
 */
#define FLOAT_PIN 4
#define PUMP_RELAY 8

void setup() {
    Serial.begin(9600);
    pinMode(FLOAT_PIN, INPUT_PULLUP);
    pinMode(PUMP_RELAY, OUTPUT);
    digitalWrite(PUMP_RELAY, LOW);
    Serial.println("Float Switch Level Sensor Ready");
}

void loop() {
    static bool lastState = HIGH;
    bool state = digitalRead(FLOAT_PIN);

    if (state != lastState) {
        delay(50);  /* Debounce */
        state = digitalRead(FLOAT_PIN);
        if (state != lastState) {
            lastState = state;
            if (state == LOW) {
                Serial.println("Level HIGH — stopping pump");
                digitalWrite(PUMP_RELAY, LOW);
            } else {
                Serial.println("Level LOW — starting pump");
                digitalWrite(PUMP_RELAY, HIGH);
            }
        }
    }
    delay(100);
}

Real-World Applications

Pump Control, Overflow Protection & Appliances

Float switches are ubiquitous: sump pump auto-start/stop, water tank overflow prevention, washing machine water level, aquarium auto-top-off systems, HVAC condensate drain pans, cooling tower makeup water, and industrial chemical tank high-level alarms. Their simplicity and direct relay-switching capability make them the most reliable level detection method — no electronics needed for basic pump control.

Pump ControlOverflow SafetyApplianceHVAC

Limitations

  • Single threshold: Only detects one level point; use multiple switches or an ultrasonic sensor for continuous level.
  • Stuck float: Debris, scale build-up, or viscous liquids can jam the float mechanism.
  • Low-density liquids: Won’t float in liquids with density <0.75 g/cm³ (some solvents, gasoline).
  • Mechanical wear: Reed switches have finite cycle life (typically >1 million cycles).
  • Mounting constraints: Requires physical access inside the tank; cannot be added externally.