Oil Level Detection in Tanks

Introduction

This experiment shows how to use a liquid level sensor to detect the oil level in a tank using an Arduino.

Oil Level Sensor

Components Needed

Circuit Setup

  1. Connect the VCC and GND of the oil level sensor to the 5V and GND pins on the Arduino.
  2. Connect the sensor’s output pin to an analog pin on the Arduino (e.g., A0).

The oil level sensor detects the oil level in the tank, sending signals to the Arduino to process the data.

Oil Level Circuit Setup

Code for Oil Level Measurement

Upload the following code to your Arduino to detect oil level:


const int sensorPin = A0;
float oilLevel;

void setup() {
  Serial.begin(9600);
}

void loop() {
  oilLevel = analogRead(sensorPin) * (5.0 / 1023.0);
  Serial.print("Oil Level: ");
  Serial.println(oilLevel);
  delay(1000);
}
            

Explanation

The oil level sensor uses resistance to measure the height of the liquid, sending data to the Arduino for analysis.

Troubleshooting