Arduino Maker Series Under 1000: Ultrasonic Water Level Indicator

Arduino Maker Series Under 1000: Ultrasonic Water Level Indicator

Welcome to the Arduino Maker Series Under 1000! 💧 In this project, we will build a Ultrasonic Water Level Indicator that measures the water level in a tank and displays it on a 16x2 LCD or LED bar. This project is practical, affordable, and perfect for beginners who want to learn about sensors, displays, and Arduino logic.

Table of Contents

  • Introduction
  • Required Hardware
  • Arduino IDE Setup
  • Wiring the Components
  • Arduino Code
  • How It Works
  • Testing Your Project
  • Advanced Modifications
  • Common Issues and Troubleshooting
  • Learning Insights
  • Conclusion

1. Introduction

This project uses the HC-SR04 ultrasonic sensor to measure the distance from the sensor to the water surface. Arduino calculates the water level and displays it either on an LCD or as LED indicators. It also triggers a buzzer alert for high or low water levels.

2. Required Hardware

  • Arduino Uno (~₹500)
  • HC-SR04 Ultrasonic Sensor (~₹150)
  • 16x2 I2C LCD (~₹200)
  • Buzzer (~₹50)
  • LEDs (optional) (~₹20)
  • Resistors (~₹20)
  • Jumper wires & breadboard (~₹100)
  • Power supply (~₹100)

3. Arduino IDE Setup

  1. Install Arduino IDE.
  2. Connect Arduino via USB.
  3. Select board: Tools > Board > Arduino Uno.
  4. Select COM port: Tools > Port > (your Arduino port).
  5. Install LiquidCrystal_I2C library via Library Manager.

4. Wiring the Components

4.1 Ultrasonic Sensor

  • VCC → 5V, GND → GND
  • Trig → D2, Echo → D3

4.2 LCD

  • VCC → 5V, GND → GND, SDA → A4, SCL → A5

4.3 Buzzer and LEDs

  • Buzzer → D9
  • LEDs → D10-D13 via 220Ω resistors (optional bar indicator)

5. Arduino Code

5.1 LCD Version

#include 
#include 

#define trigPin 2
#define echoPin 3
#define buzzer 9

LiquidCrystal_I2C lcd(0x27,16,2);
long duration;
int distance;
int tankHeight = 20; // cm

void setup() {
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(buzzer, OUTPUT);
  lcd.init();
  lcd.backlight();
}

void loop() {
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  duration = pulseIn(echoPin, HIGH);
  distance = duration*0.034/2;

  int waterLevel = tankHeight - distance;
  if(waterLevel < 0) waterLevel = 0;

  lcd.setCursor(0,0);
  lcd.print("Water Level:");
  lcd.setCursor(0,1);
  lcd.print(waterLevel);
  lcd.print(" cm   ");

  if(waterLevel < 5 || waterLevel > 18){
    digitalWrite(buzzer,HIGH);
  } else {
    digitalWrite(buzzer,LOW);
  }

  delay(500);
}

5.2 LED Bar Indicator Version

#define trigPin 2
#define echoPin 3
#define buzzer 9
int ledPins[] = {10,11,12,13};
int tankHeight = 20;

void setup() {
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(buzzer, OUTPUT);
  for(int i=0;i<4;i++){
    pinMode(ledPins[i],OUTPUT);
  }
}

void loop() {
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin,HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin,LOW);

  long duration = pulseIn(echoPin,HIGH);
  int distance = duration*0.034/2;
  int waterLevel = tankHeight - distance;
  if(waterLevel<0) waterLevel=0;

  for(int i=0;i<4;i++){
    if(waterLevel > (i+1)*5) digitalWrite(ledPins[i],HIGH);
    else digitalWrite(ledPins[i],LOW);
  }

  if(waterLevel<5 || waterLevel>18) digitalWrite(buzzer,HIGH);
  else digitalWrite(buzzer,LOW);

  delay(500);
}

6. How It Works

The HC-SR04 ultrasonic sensor sends sound waves to the water surface and measures the time it takes to bounce back. Arduino calculates distance and derives the water level. The reading is displayed on LCD or LEDs, and a buzzer alerts if water is too low or too high.

7. Testing Your Project

  1. Upload the code to Arduino.
  2. Place sensor above water tank.
  3. Power the Arduino and check LCD or LED indicators.
  4. Fill or remove water to test buzzer alerts.

8. Advanced Modifications

  • Automatic pump control to fill or drain tank.
  • Mobile notifications using ESP8266 or Blynk.
  • Log water levels on SD card for analysis.
  • Multiple sensors for larger tanks or reservoirs.

9. Common Issues and Troubleshooting

  • Distance readings incorrect: Check sensor wiring and orientation.
  • LCD not showing: Verify I2C address and library installation.
  • False buzzer triggers: Adjust alert threshold values.
  • LEDs not lighting: Check pin connections and resistors.

10. Learning Insights

  • Understanding ultrasonic sensors and pulse measurement.
  • Using conditional statements for alerts.
  • Interfacing Arduino with LCD and LEDs.
  • Practical automation for home applications.

11. Conclusion

This Ultrasonic Water Level Indicator project is a simple, budget-friendly, and educational Arduino project under ₹1000. It teaches sensor usage, data display, and basic automation, and can be extended with pumps, notifications, and data logging for advanced applications.

By Kaushal Haladi

Comments

Popular Posts