Water level indicators are essential in various applications, from maintaining water tanks to managing reservoirs. An ultrasonic water level indicator provides a non-contact method for measuring and displaying water levels. In this project, we will create a simple ultrasonic water level indicator using TinkerCAD. This system will use an ultrasonic sensor to measure the water level and display the results on an LCD.
Materials Needed:
Arduino Uno
HC-SR04 Ultrasonic Distance Sensor
16x2 LCD Display (with I2C adapter)
Breadboard
Jumper Wires
Resistors (220Ω for LCD)
Step 1: Understanding the Components
HC-SR04 Ultrasonic Sensor:
VCC: Connects to 5V on the Arduino.
GND: Connects to GND on the Arduino.
Trig: Trigger pin to initiate the measurement.
Echo: Echo pin to receive the reflected signal.
16x2 LCD Display (I2C Adapter):
VCC: Connects to 5V on the Arduino.
GND: Connects to GND on the Arduino.
SDA: Connects to A4 on the Arduino.
SCL: Connects to A5 on the Arduino.
Step 2: Setting Up the Circuit in TinkerCAD
Arduino Uno: Place the Arduino Uno on the TinkerCAD workspace. This will be the controller for your ultrasonic water level indicator system.
HC-SR04 Ultrasonic Sensor:
Place the HC-SR04 sensor on the breadboard.
Connect the VCC pin to the 5V pin on the Arduino.
Connect the GND pin to the GND pin on the Arduino.
Connect the Trig pin to a digital pin on the Arduino (e.g., pin 9).
Connect the Echo pin to another digital pin on the Arduino (e.g., pin 10).
16x2 LCD Display with I2C Adapter:
Place the LCD on the breadboard.
Connect the VCC pin of the LCD to the 5V pin on the Arduino.
Connect the GND pin of the LCD to the GND pin on the Arduino.
Connect the SDA pin to the A4 pin on the Arduino.
Connect the SCL pin to the A5 pin on the Arduino.
Power: Ensure the Arduino is powered, either through a USB connection or an external power source.
Step 3: Writing the Arduino Code
The Arduino code will measure the distance to the water level using the ultrasonic sensor and display the water level on the LCD.
#include <Wire.h> // Include the Wire library for I2C communication
#include <LiquidCrystal_I2C.h> // Include the LCD library for I2C display
// Create an LCD object with the I2C address 0x27 and a 16x2 display
LiquidCrystal_I2C lcd(0x27, 16, 2);
const int trigPin = 9; // Pin connected to the Trig pin of the ultrasonic sensor
const int echoPin = 10; // Pin connected to the Echo pin of the ultrasonic sensor
const int maxDistance = 200; // Maximum distance in centimeters that the sensor can measure
void setup() {
lcd.begin(); // Initialize the LCD
lcd.backlight(); // Turn on the backlight
lcd.setCursor(0, 0); // Set cursor to the top-left corner
lcd.print("Water Level:"); // Print "Water Level:" on the first line
pinMode(trigPin, OUTPUT); // Set the Trig pin as output
pinMode(echoPin, INPUT); // Set the Echo pin as input
}
void loop() {
long duration;
int distance;
// Trigger the ultrasonic sensor
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Read the duration of the pulse
duration = pulseIn(echoPin, HIGH);
// Calculate the distance
distance = duration * 0.0344 / 2; // Convert duration to distance in centimeters
// Clear the previous distance reading
lcd.setCursor(0, 1);
lcd.print(" "); // Print spaces to clear the previous reading
// Display the distance on the LCD
lcd.setCursor(0, 1);
lcd.print("Level: ");
lcd.print(maxDistance - distance); // Display the distance as the water level
lcd.print(" cm");
delay(500); // Wait for 0.5 seconds before the next reading
}
Step 4: Simulating the Circuit in TinkerCAD
Start the Simulation: Click the "Start Simulation" button in TinkerCAD. The LCD should display the water level based on the distance measured by the ultrasonic sensor.
Testing the System: Simulate different water levels by adjusting the distance readings from the ultrasonic sensor. Observe how the LCD updates with the new water level.
Troubleshooting: If the LCD does not display the correct readings, verify the connections and ensure the code is correctly uploaded. Ensure the I2C address of the LCD matches the address used in the code.
Step 5: Enhancing the System
Once you have the basic system working, consider these enhancements:
Calibration: Implement calibration to account for the height of the water tank and adjust the calculations accordingly.
Alert System: Add a buzzer or LED to alert when the water level is too high or too low.
Wireless Communication: Use a Wi-Fi or GSM module to send water level data to a remote server or notification system.
Step 6: Building the Physical Circuit
After successfully simulating the circuit in TinkerCAD, you can build the physical version of the water level indicator.
Assemble Components: Transfer the TinkerCAD design to a physical breadboard or custom PCB.
Upload Code: Connect your Arduino to a computer, upload the code, and test the system with real components.
Test and Calibrate: Verify the system’s accuracy with actual water levels and adjust the calibration as needed.
Step 7: Expanding the Project
With a functional prototype, you can explore further enhancements:
Integration with IoT: Connect the water level indicator to an IoT platform for remote monitoring and control.
Multiple Sensors: Implement multiple ultrasonic sensors for larger tanks or more detailed level measurement.
User Interface: Design a more sophisticated user interface with touch screens or mobile apps for interacting with the system.
Conclusion
Congratulations on designing and simulating an ultrasonic water level indicator using TinkerCAD! This project demonstrates how to use ultrasonic sensors with an Arduino to create practical measurement and display systems. The skills learned in this project can be applied to various applications, from home automation to industrial monitoring.
With the foundation you’ve built, you can continue to innovate and develop more complex and useful electronic systems.
Happy tinkering!
Want us to guide you through your project or make the project for you ?
Create Various Projects
Check out our Free Arduino Projects Playlist - Arduino Projects
Check out our Free Raspberry Pi Projects Playlist - Raspberry Pi Projects
Check out our Free TinkerCAD Projects Playlist - TinkerCAD Projects
Check out our Free IoT Projects Playlist - IoT Projects
Check out our Free Home Automation Projects Playlist - Home Automation Projects
Check out our Free NodeMCu Projects Playlist - NodeMCu Projects
Comments