Easy Basics: Project 073a Float Switch

of Acoptex.com in UNO

Basics: Project 073a

Project name: Float Switch

Tags: Arduino Uno, Float Switch, Level Switch, Liquid Level Sensor, Magnetic Float Sensor

Attachments: sketch

In this project, you needed these parts (Dear visitors. You can support our project buy clicking on the links of parts and buying them or donate us to keep this website alive. Thank you):

1.Arduino Uno R3 (you can also use the other version of Arduino)

2. Float switch 1pc

3.Arduino IDE ( you can download it from here  )


We will learn how to connect float switch to Arduino board and use it.

It is normally used to notify if the tank is full of water or when it is empty.

Understanding the float switch

A float sensor is a device used to detect the level of liquid within a tank. The switch may be used in a pump, an indicator, an alarm, or other devices. Magnetic float sensor is an electromagnetic ON/OFF switch. It helps to sense the level of water present in the overhead tank or sump.

Works like your toilet float valve. When the water rises past a certain level the float rises and throws a switch.

To complete a circuit, float switches utilize a magnetic reed switch, which consists of two contacts sealed in a glass tube. When a magnet comes close to the contact, they become attracted to each other and touch, allowing current to pass through. When the magnet moves away, the contacts demagnetize and will separate (breaking the circuit).

Float Sensor which we have used is Normally Opened (NO), that is when the float is at its low point, resting on its bottom clip circuit will be open and when float is at its high point, it will complete the circuit. So, when the water level goes down float sensor breaks the circuit and attached led will get off.

How to select correct float switch?

When selecting a float switch for a liquid level sensing application, a number of factors need to be considered, including float switch and gasket materials, physical arrangement, electrical ratings and cable type.

Many industrial processes require devices that are able to sense the level of liquid stored within various types of tank or chamber. The signals from these devices may be used to control the production process or to provide indication of the status.

One of the most reliable, well-proven technologies for liquid level sensing is a float switch. This type of switch comprises a magnet contained within a float, as well as a magnetic reed switch contained within a fixed housing. The movement of the float, due to the changing liquid level, will cause the reed switch to operate (i.e. close or open) at a particular level. This tried and trusted technology is based on a relatively simple design that offers long term reliability without the need for the user to calibrate the switch.

Whilst there are different methods available for selecting the right float switch for a particular application, the main factors to consider include the following:

Physical arrangement and style

The choice of styles that may be suitable for an application will depend on the physical arrangement of the tank, the available mounting positions and whether access is available to the inside of the tank. The main styles are horizontal/side mounting and vertical mounting. The horizontal/side mounting type normally has a fixed housing, which passes through the sidewall of a tank, with a hinged float attached to the fixed housing. Vertical mounting types normally have a fixed vertical stem, which is installed through the top or bottom of a tank, along which slides a cylindrical float.

Another important consideration is whether a build up of deposits from the liquid on the float body is likely to occur. These deposits can, over a period of time, accumulate to such an extent that the float switch can fail to operate. Whilst particular types of float switch have been developed to limit the effects of this build up, the experience and knowledge of the switch manufacturer is also critical here.

Material selection

It is critical to select a float switch that is constructed from the right materials that are compatible with the liquids and temperatures of the particular application. Component damage as a result of incorrect materials selection can ultimately cause failure of a float switch, which may have severe consequences. Typical float switch materials include:

  • Nylon: suitable for many oils, diesel, organic chemicals and MEK-based printing inks.
  • Polypropylene (PP): suitable for many acids and alkali, detergents, inorganic and organic chemicals, oils and water.
  • Polyphenylene sulphide (PPS): suitable for many of the more aggressive chemicals and higher process temperatures, up to 120ºC.
  • Buna/Nitrophyl: suitable for many oils, diesel, petrol and water (non-potable applications).
  • D300 foam (PVC): suitable for most hydraulic oils and many chemical solutions.
  • Stainless steel: suitable for most medical and food applications, chemicals, hydraulic fluids, fuel oils and applications with process temperatures up to 135ºC.

Selection of the most suitable materials for both float switch and gasket can be made by referring to a ‘Chemical Compatibility’ table. These tables provide a good indication of the suitability of the various float switch materials in a wide range of liquids. For some process liquids, it may be necessary to obtain a sample float switch in order to test the compatibility.


It is important to fully understand the nature of the load that needs to be switched and to ensure that the float switch is capable of handling this load. The electrical ratings, which most manufacturers provide in their float switch specifications, are for purely resistive loads. Any loads that have either inductive or capacitive components should have the appropriate contact protection measure applied.


In applications where aggressive liquids may spill onto external wiring, it is important to specify particular materials for the cables used to connect to the float switches. There are standard, UL-approved cable types for the various float switches, as well as high temperature, low smoke zero halogen (LSZH) and other specialised materials.

Custom engineered float switches

The operating environment is critical to the choice of float switch. A water tank for an industrial process may only require a simple plastic float switch. However, if the application is in a hazardous area, for example, a petrochemical storage tank where flammable gases, vapours or dust are present, a stainless steel, explosion-proof float switch will be required.

Float switch can transmit only two types of signal - level zero, level high A circuit can be design to start stop some process by receiving the signals from float switch. Common processes are sending low or high level alarm, starting or stopping water pump motor.

There are two types of float switch constructed:

  1. Emptying type – On at floated upward position and off at clinging downward position.
  2. Filling type – On at clinging downward position and off at floated upward position.

Water is at the bottom of the tank, float switch is downward position. Water in tank is at high level, float switch position is downward.

In our project we are going to use vertical mount type sensor.


  • Cable length: 40cm
  • Maximum load: 50w
  • Max Switching voltage: 100V DC
  • Minimum Voltage: 250v DC
  • Maximum Switching Current: 0.5A
  • Max load current: 1.0A
  • Max contact resistance: 0.4 Ω
  • Temp Rating: -10 - +80
  • Net weight: 16g

Signals and connections of the Float Switch

The sensor comes with two wires: connect one to GND pin of Arduino board, another - to any digital pin of Arduino board (we used digital pin 7).


The following picture shows the needed connections with the Arduino Uno 

Step by Step instruction

  1. Do wiring.
  2. Open Arduino IDE.
  3. Plug your Adruino Uno board into your PC and select the correct board and com port
  4. Verify and upload the the sketch to your Adruino Uno
  5. Open up serial monitor and set your baud to 9600 baud.
  6. Put float switch in glass of water and check results.
  7. When float switch is up, you will see "1" and when float is down - "0".


We learnt how to connect float switch to Arduino board and use it.

You could add a water sensor above the float switch as an overflow emergency shutoff. You could automatically refill your pet's water dish, or use it to make a fountain. You could make a punch bowl that never goes dry for a party.

Can you think of a way to use this to water plants? What other things do you know of that would benefit from having a steady water level? Get creative and let us know!


  • No libraries required for this project


  • See attachment on the begining of this project

Other projects of Acoptex.com
Medium Basics: Project 083w Sipeed Maixduino board - Using PlatformIO IDE of Acoptex.com in Sipeed Maixduino 08-08-2019
Medium Basics: Project 083e Sipeed Maixduino board - Uploading MaixPy of Acoptex.com in Sipeed Maixduino 04-08-2019
Medium Basics: Project 083f Sipeed Maixduino board - Using MycroPython of Acoptex.com in Sipeed Maixduino 04-08-2019

Published at 10-05-2018
Viewed: 3054 times