Automatic Water Level Indicator with Arduino: A Beginner’s Guide to Liquid Level Monitoring
Objective
The objective of this Automatic Water Level Indicator with Arduino project is to help beginners build a system that measures and displays the water level in a tank using a water level sensor. This project introduces the fundamentals of liquid level monitoring and Arduino programming.
Project Goal for Automatic Water Level Indicator with Arduino
- Learn to interface a water level sensor with Arduino.
- Understand how to measure and display water levels.
- Build a basic water level monitoring system that provides real-time feedback.
Requirement Components for Automatic Water Level Indicator with Arduino
Here is the list of components needed to build this Automatic Water Level Indicator with Arduino:
- Arduino Uno — Buy on Amazon
- Water Level Sensor — Buy on Amazon
- 16x2 LCD Display Module — Buy on Amazon
- 10k Ohm Potentiometer — Buy on Amazon
- Breadboard — Buy on Amazon
- Jumper Wires — Buy on Amazon
- USB Cable — Buy on Amazon
Sensor Basics for Automatic Water Level Indicator with Arduino
What is a Water Level Sensor?
A Water Level Sensor is a sensor designed to detect and measure the level of water in a tank. It uses conductive traces to determine the water level by measuring changes in resistance as water rises or falls.
How Does the Water Level Sensor Work?
- The sensor consists of conductive tracks that act as probes.
- As water touches different tracks, the resistance changes, which is read as a varying voltage by the Arduino.
- The varying voltage corresponds to different water levels, which can be displayed in real-time.
Pinout of Water Level Sensor
- The water level sensor has three pins:
- VCC: Connects to the 5V pin on Arduino.
- GND: Connects to the GND pin on Arduino.
- SIG (Signal): Connects to an analog input (e.g., A0) on Arduino.
Sensor Real-Life Applications
- Water Tanks: Monitors water levels in overhead or underground tanks.
- Agricultural Fields: Monitors water levels in irrigation systems and reservoirs.
- Industrial Systems: Tracks water levels in storage tanks and processes.
- Flood Detection: Warns about rising water levels during floods.
Circuit Connection for Automatic Water Level Indicator with Arduino
- Connect the Arduino Uno: Use the USB cable to connect the Arduino Uno to your computer.
- Connect the Water Level Sensor:
- Connect the VCC of the sensor to the 5V pin on Arduino.
- Connect the GND of the sensor to the GND pin on Arduino.
- Connect the SIG to the analog input pin A0 on Arduino.
- Connect the 16x2 LCD Display:
- Connect the LCD pins according to the standard configuration.
- Use a 10k Ohm Potentiometer to adjust the contrast of the LCD.
- Connect the LCD to Arduino using digital pins 2 to 7.
Circuit Connection Analysis: How the Automatic Water Level Indicator Works
- The water level sensor detects the water level in the tank by measuring the change in resistance as water touches different conductive traces.
- The Arduino reads the analog signal from the sensor and converts it into a water level percentage.
- The calculated water level is displayed on the 16x2 LCD, providing real-time monitoring of the water level.
Safety Tips for Automatic Water Level Indicator with Arduino
- Disconnect the power before connecting or modifying the circuit.
- Ensure the water level sensor is securely placed to avoid damage.
- Avoid exposing the sensor to extreme water conditions or direct submersion beyond its limits.
Arduino Programming Section for Automatic Water Level Indicator with Arduino
Arduino Syntax
- analogRead(pin); — Reads the analog value from the specified pin.
- pinMode(pin, mode); — Sets a pin as INPUT or OUTPUT.
- lcd.begin(columns, rows); — Initializes the LCD display.
- map(value, fromLow, fromHigh, toLow, toHigh); — Maps a range of values to another range.
Arduino Code for Automatic Water Level Indicator with Arduino
#include <LiquidCrystal.h>
const int sensorPin = A0; // Water level sensor connected to analog pin A0
int sensorValue = 0; // Variable to store sensor value
int waterLevel = 0; // Variable to store water level percentage
LiquidCrystal lcd(2, 3, 4, 5, 6, 7); // Initialize the LCD
void setup() {
pinMode(sensorPin, INPUT); // Set sensor pin as input
lcd.begin(16, 2); // Set up the LCD with 16 columns and 2 rows
lcd.print("Water Level:"); // Print header on the LCD
}
void loop() {
sensorValue = analogRead(sensorPin); // Read the sensor value
waterLevel = map(sensorValue, 0, 1023, 0, 100); // Convert to percentage
lcd.setCursor(0, 1); // Move cursor to the second line
lcd.print(" "); // Clear previous reading
lcd.setCursor(0, 1);
lcd.print(waterLevel); // Display water level percentage
lcd.print("%");
delay(1000); // Wait for 1 second before updating
}
Steps to Upload Code for Automatic Water Level Indicator with Arduino
- Open the Arduino IDE on your computer.
- Connect the Arduino Uno using the USB cable.
- Select the Board: Go to ‘Tools’ > ‘Board’ > ‘Arduino Uno’.
- Select the Port: Go to ‘Tools’ > ‘Port’ and select the correct port.
- Upload the Code: Copy the code above, paste it into the IDE, and click ‘Upload’.
Check Output of Automatic Water Level Indicator with Arduino
After uploading the code, place the water level sensor in a water tank. The 16x2 LCD will display the water level as a percentage, providing real-time monitoring.
Code Explanation for Automatic Water Level Indicator with Arduino
- analogRead(sensorPin);: Reads the analog signal from the water level sensor.
- map(sensorValue, 0, 1023, 0, 100);: Maps the sensor’s analog value to a percentage representing the water level.
- lcd.print(waterLevel);: Displays the water level percentage on the LCD.
Troubleshooting Tips for Automatic Water Level Indicator with Arduino
- No readings on LCD? Check the water level sensor and LCD connections.
- Inaccurate readings? Ensure the sensor is correctly positioned and not exposed to water beyond its limits.
- Code not uploading? Verify the correct board and port settings in the Arduino IDE.
Suggestion for Beginners
Book Recommendation
For a comprehensive guide on Arduino programming, I recommend Arduino Programming for Absolute Beginners. This book covers projects like the Automatic Water Level Indicator, offering clear instructions and practical examples.
Free Tutorials
For more tutorials on Arduino, ESP8266, ESP32, and Raspberry Pi projects, visit mechatronicslab.net.
Start building your own Automatic Water Level Indicator with Arduino and explore more liquid level monitoring projects!