Function: what a Float switch does in a circuit
A switch for liquid level. A hollow float slides up a stem as the water rises, and at the top it closes the switch.
- Closes when the liquid lifts its float
- Tells a program that a tank is full or empty
- Works as a second check beside another level sensor
Float switch key facts
| Type | normally open: closes when the float rises (turn the float over for normally closed) |
|---|---|
| Switching voltage | up to 100 V DC |
| Switching current | up to 0.5 A |
| Switching power | up to 10 W |
| Contact resistance | less than 0.2 Ω when closed |
| Body | polypropylene, about 52 mm long, M10 thread |
| Working temperature | −10 to 85 °C |
| Wires | 2, either way round |
Connections
The legs from left to right, as the part is drawn in the simulator:
| No. | Name |
|---|---|
| 1 | Wire 1 |
| 2 | Wire 2 |
- What a float switch is
- What a float switch is for
- How a float switch works
- How to use the float switch in the simulator
- Worked example
- Common mistakes
- Key words
- What to learn first and next
What a float switch is
A float switch is a switch that is worked by the level of a liquid instead of by a finger. It has a plastic stem with two wires coming out of it and a hollow plastic float that slides up and down the stem. The float is lighter than water, so it rises when the water reaches it and drops when the water falls away.
Inside the sealed stem is a reed switch: two thin strips of metal in a small glass tube, with a tiny gap between them. The float carries a ring magnet. When the float rises level with the reed switch, the magnet pulls the two strips together and the switch closes, so current can pass between the two wires. When the float drops, the strips spring apart and the switch opens. Nothing electrical ever touches the water, which is why this kind of switch is safe and lasts a long time.
A float switch gives only two answers, such as “the water has reached this level” or “it has not”. It does not say how deep the water is. For that you need a sensor that measures, such as an ultrasonic distance sensor looking down at the surface.
What a float switch is for
- Stopping a tank from overflowing. A switch near the top turns the pump off or sounds an alarm.
- Protecting a pump. A switch near the bottom stops the pump before the tank runs dry.
- Sump pumps and bilge pumps, which start when water collects.
- Washing machines, coffee machines and aquariums, to check that there is enough water.
- Checking another sensor. A float switch and a distance sensor together are harder to fool than either one alone.
How a float switch works
Buoyancy. The float is hollow, so it is less dense than water. Water pushes it up with a force equal to the weight of the water it pushes aside, and it floats.
Magnet and reed switch. The reed strips are made of a metal that a magnet attracts. Near the magnet each strip becomes a small magnet itself, with opposite poles facing across the gap, so they pull together and touch.
Normally open. With no water the switch is open. This is called normally open. If the float is taken off, turned upside down and put back, the magnet sits at the other end and the switch works the other way: closed with no water. That is called normally closed.
Reading it with a board. Wire it like a push button: one wire to an input pin and the other to GND, with the pull-up resistor of the pin switched on. While the switch is open the pull-up holds the pin HIGH. When the water lifts the float, the switch joins the pin to GND and it reads LOW. So LOW means “water is here”.
In code. On an Arduino: pinMode(pin, INPUT_PULLUP) and digitalRead(pin) == LOW. On a Raspberry Pi with RPi.GPIO: GPIO.setup(pin, GPIO.IN, pull_up_down=GPIO.PUD_UP) and GPIO.input(pin) == GPIO.LOW. With gpiozero: Button(pin).is_pressed is True when the water is high.
How to use the float switch in the simulator
- Open the Studio and add a board and a breadboard.
- Find the Float switch in the parts bin under Sensors and place it on the breadboard.
- Wire one leg to an input pin and the other leg to GND. The two wires can go either way round.
- In your program, switch on the pull-up for that pin and print what the pin reads.
- Press Run, then use the control on the float switch to raise and lower the water. The pin reads 1 with the water low and 0 with the water high.
- Try the guided project “Tank alarm with two sensors”, where a float switch checks an ultrasonic sensor.
Worked example
Question. A float switch is wired between GPIO 27 of a Raspberry Pi and GND, and the program switches on the pull-up inside the Pi, which is about 50 kΩ to 3.3 V. What does the pin read with the tank empty and with the tank full, and how much current flows through the switch when it is closed?
- Tank empty: the switch is open, so no current flows. The pull-up holds the pin at 3.3 V and it reads HIGH (1).
- Tank full: the switch is closed and joins the pin to GND, 0 V. It reads LOW (0).
- With the switch closed, the whole 3.3 V is across the pull-up resistor.
- Current = voltage ÷ resistance = 3.3 V ÷ 50,000 Ω = 0.000066 A, which is 66 µA.
Answer. The pin reads 1 when the tank is empty and 0 when it is full. Only about 66 µA flows through the closed switch, far below the 0.5 A it is made for.
Common mistakes
- Leaving out the pull-up.With the switch open the pin is connected to nothing and reads random values. Switch on the pull-up in the program.
- Expecting HIGH to mean “full”.With a pull-up and the switch to GND, the pin is LOW when the water is high. Test for LOW.
- Wiring the switch between the pin and 5 V on a Raspberry Pi.The pins take 3.3 V only. Wire the switch to GND and use the pull-up.
- Switching a pump directly with the float switch.The switch is made for about 0.5 A and 10 W. A pump takes more. Let the board read the switch and drive the pump through a relay.
- Mounting it upside down.The float then rests at the wrong end and the switch works in reverse. Check which way it reads before fixing it in the tank.
- Using it to measure depth.It reports one level only. Use two switches for “low” and “high”, or a distance sensor for a measurement.
Key words
- Float switch
- A switch that opens or closes when a float rises or falls with the level of a liquid.
- Reed switch
- A switch made of two thin metal strips in a glass tube that touch when a magnet is near.
- Normally open
- Describes a switch that is open, so no current passes, until something operates it.
- Normally closed
- Describes a switch that is closed, so current passes, until something operates it.
- Buoyancy
- The tendency of an object to float in a fluid, because of the upward force on it.
- Pull-up resistor
- A resistor that joins an input pin to the supply voltage, so the pin reads HIGH when nothing else drives it.
- GPIO
- General-purpose input and output: a pin that a program can set HIGH or LOW, or read.
- Ground
- The point in a circuit taken as zero volts, from which other voltages are measured.
See every key word in the glossary
What to learn first and next
- Push button: A float switch is wired and read in the same way.
- Reed switch: The part inside the stem.
- Density and buoyancy: Why the float rises.
- Tank alarm with two sensors: A float switch and an ultrasonic sensor together.
- Relay module: Switch a pump from a board pin.
- Raspberry Pi 4 Model B: The board used in the tank project.
How it works
The stem is a sealed plastic tube with a reed switch inside. The float around it carries a small ring magnet. When the liquid lifts the float, the magnet comes level with the reed switch and its two metal strips snap together, so current can pass. When the level falls, the float drops and the contacts spring apart. This type is called normally open: open with no water, closed with water. Turn the float upside down on the stem and it works the other way round (normally closed). Wire it like a push button: one wire to an input pin with the pull-up switched on, the other wire to GND. The pin then reads LOW when the water is high.
What it is made of
- Float and stem: Polypropylene plastic, which does not soak up water CH
- Magnet: A ferrite ring inside the float FeOSr
- Reed switch: Iron–nickel strips in a glass tube filled with nitrogen FeNiSiN
- Wires: Copper with plastic insulation Cu
Where the materials come from: Polypropylene from crude oil or natural gas; iron and strontium for the ferrite magnet from iron ore and celestine; nickel from laterite and sulfide ores; copper from ores in Chile and Peru.
The chemistry
Polypropylene is less dense than water (about 0.9 g/cm³ against 1.0), and the float is hollow, so it floats high. The plastic does not react with water or most cleaning liquids, and the switch contacts never touch the liquid at all.
Biology connection
Your body also measures a level. Sensors in the brain detect when the blood has too little water, and the kidneys then save water, much as a float switch tells a pump when to run. How the kidneys work →
Safety and the environment
The reed switch carries only a small current (about 0.5 A at most), so switch a pump through a relay or transistor, never directly. Keep the wire ends dry. Do not use it in petrol or solvents unless it is made for them.
Did you know? A toilet cistern uses a float too, but there the float pushes a valve shut by itself. A float switch does the same job with an electrical signal.
Reed switchMagnetic fieldsMicrocontroller simulator Elements inside: CHFeOSrNiSiNCu
Try it in the simulator
Build and code a circuit with a Float switch in these practice projects:
Questions students ask
What does a Float switch do?
A switch for liquid level. A hollow float slides up a stem as the water rises, and at the top it closes the switch. Main functions: closes when the liquid lifts its float; tells a program that a tank is full or empty; works as a second check beside another level sensor.
How do I wire a float switch to a Raspberry Pi or an Arduino?
Wire a float switch like a push button: one wire to an input pin and the other wire to GND, with the pull-up switched on in the program. On a Raspberry Pi write GPIO.setup(pin, GPIO.IN, pull_up_down=GPIO.PUD_UP); on an Arduino write pinMode(pin, INPUT_PULLUP). The pin reads LOW when the water lifts the float and HIGH when the water is low.
What are the connections of a Float switch?
In order: Wire 1, Wire 2.
How does a Float switch work?
The stem is a sealed plastic tube with a reed switch inside. The float around it carries a small ring magnet. When the liquid lifts the float, the magnet comes level with the reed switch and its two metal strips snap together, so current can pass. When the level falls, the float drops and the contacts spring apart. This type is called normally open: open with no water, closed with water. Turn the float upside down on the stem and it works the other way round (normally closed). Wire it like a push button: one wire to an input pin with the pull-up switched on, the other wire to GND. The pin then reads LOW when the water is high.
What is a Float switch made of?
Float and stem: Polypropylene plastic, which does not soak up water. Magnet: A ferrite ring inside the float. Reed switch: Iron–nickel strips in a glass tube filled with nitrogen. Wires: Copper with plastic insulation.
Is a Float switch safe? How should it be recycled?
The reed switch carries only a small current (about 0.5 A at most), so switch a pump through a relay or transistor, never directly. Keep the wire ends dry. Do not use it in petrol or solvents unless it is made for them.
More switches and controls
Connected tools
The same idea from another angle, across the site.