Menu Close

Magnetic Float Sensor – Arduino

This tutorial of Robo India explains, how to use Magnetic Float Sensor as water level indicator.

1. Introduction:

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.

1.1 Working:

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.

2. Required Hardware

Following Hardware will be required to perform this circuit.

S.No.ItemQuantity
1 Arduino UNO 1
2 Breadboard 1
3 Magnetic Float Sensor 1
4 LED 1
5 Resistor 1k 1
6 Male to Male Jumper 2

3. Building Circuit

Make the following connections with Arduino-

4. Programming

You may download this Arduino Sketch from here.

//Robo India tutorial on Magnetic Float Sensor
//https://www.roboindia.com/tutorials

int FloatSensor=2;   
int led=3;           
int buttonState = 1; //reads pushbutton status 

void setup() 
{ 
Serial.begin(9600); 
pinMode(FloatSensor, INPUT_PULLUP); //Arduino Internal Resistor 10K
pinMode (led, OUTPUT); 
} 
void loop() 
{ 
buttonState = digitalRead(FloatSensor); 
  if (buttonState == HIGH) 
  { 
    digitalWrite(led, HIGH);
    Serial.println( "WATER LEVEL - HIGH"); 
  } 
  else 
  { 
    digitalWrite(led, LOW);
    Serial.println( "WATER LEVEL - LOW" ); 
  } 
delay(1000); 
}

5. Output

After uploading the code successfully, you can see when water level goes up led attached will get turn on and when water level goes down led will get turn off.

If you have any query please write us at support@roboindia.com

Thanks and Regards
Content Development Team 
Robo India
https://roboindia.com

Leave a Reply