Liquid Level Sensor

Introduction


            A liquid level sensor is a device which measure the depth of a fluid in a tank, liquid level sensors have many applications, including fuel tanks, aquariums, and even toilets.


Theory


            There are many different ways of measuring liquid height, the most common is the mechanical floater found in virtually all toilets, however the method discussed here is an electrical one using variable resistance. A schematic of a liquid level sensor is shown below.  It consists of a

    

                                                               Figure 1: Liquid level sensor schematic.

resistive material, when pressure is applied the resistance changes and the height of the liquid can be worked out.


Technical Specifications


            The liquid level sensor featured in this tutorial is the 8" eTape Liquid Level Sensor, which can measure a fluid depth of up to 8.4”. It is .015” thick, 1” wide, and 10.1” long. The resistance varies linearly from 1500 Ω at a depth of 1” to 300 Ω at a depth of 8.4”. The sensor will usually not measure depths less than 1”. The sensor has 4 pins, the outer 2 give a reference resistance which can be used to adjust for temperature variation, and the inner 2 give the reading.

 

                                                               Figure 2: 8" eTape Liquid Level Sensor.



Connections


            The connections for the eTape liquid level sensor are shown below, in addition to sensor, a      


                                                          Figure 3: Connections for 8" eTape liquid level sensor.


resistor is required, its exact resistance is not critical but it should be between 50 – 2000 Ω. Pin 2 or 3 on the sensor should be connected to the resistor, analog in should be connected at the same point, ground should be connected to resistor and pin 2 or 3 of sensor, the one not used prior,  should be connected to the sensor as shown above.


Code


void setup()
{
  // put your setup code here, to run once:
  Serial.begin(9600);
}
 
float R = 1000;      // resistance of resistor used in the circuit in ohms
float v;             // variable to hold sensor reading
float h;             // fluid height with respect to reference
float ho;            // reference height
int i = 0;           // counter
 
void loop()
{
  // put your main code here, to run repeatedly:
  v = analogRead(A0);             // read sensor
  v = 5*v/1023;                   // convert sensor reading to voltage
 
  // measure height for reference
  if ( i == 0)
  {
    ho = (1500 + R*(1 - 5/v))/140;
    i++;
  }
 
  h = (1500 + R*(1 - 5/v))/140 - ho + 1;   // calculate fluid height
                                           // in inches with respect to reference
                                           // 1 is activation height
                                           
  Serial.println(h);                   // display data
  delay(100);                          // make easier to read
}





We ship to the GCC and MENA regions.

Reliable and fast shipping to your door, quality assured.

More about shipping

Find us on
Instagram

Just type @idea_link

Visit our profile