Play with Circuit Posted February 5 Report Posted February 5 Water wastage due to overflowing water tanks is a common issue in many households. A simple and effective solution to this problem is using a water level sensor. By monitoring the water level in a tank, this sensor helps prevent overflow and conserves water. In this tutorial, we will explore how a water level sensor works and how to interface it with an Arduino. How Does a Water Level Sensor Work? A water level sensor detects water levels in tanks or containers using a simple resistive principle. It consists of conductive traces that measure resistance changes when submerged in water. Higher Water Level: When more of the sensor is submerged, conductivity improves, and resistance decreases. Lower Water Level: When less of the sensor is submerged, conductivity reduces, and resistance increases. This varying resistance results in an output voltage that is directly proportional to the water level. By measuring this voltage using an Arduino, we can determine the water level. Specifications of the Water Level Sensor Operating Voltage: 3V to 5V (Consumes <20mA) Humidity Range: 10%–90% (non-condensing) Operating Temperature: 10°C–30°C Sensor Type: Analog Output Voltage Range: 0V to 3.85V Detection Area: 40mm (height) x 16mm (width) Hardware Overview The water level sensor consists of ten exposed copper traces: Five Power Traces: Carry voltage necessary for the sensor. Five Sense Traces: Detect water presence. These traces are intertwined, ensuring that each sense trace is positioned between two power traces. When immersed in water, the sensor bridges the gap between them, enabling water level detection. The sensor module also includes: A power LED that indicates when the sensor is powered. A transistor and resistors that help regulate the signal output. Water Level Sensor Pinout VCC: Power supply pin (connect to Arduino 5V) GND: Ground pin (connect to Arduino GND) OUT: Analog output pin (provides signal based on water level) Schematic Diagram The schematic diagram below illustrates the working of the water level sensor module: The NPN transistor (Q1) is connected with: Emitter to GND through R2 (100Ω) Collector to VCC Five power traces are connected to VCC through R1 (100Ω) Five sense traces are connected to the base of the transistor Current-limiting resistors (R1, R2, R3) protect the transistor and LED. When water comes in contact with the traces, it allows current flow, triggering the transistor and sending an analog signal to the Arduino. Wiring a Water Level Sensor to Arduino The circuit diagram is shown as follows: To interface the water level sensor with an Arduino UNO, connect the following pins: VCC of the sensor to 5V on the Arduino. GND of the sensor to GND on the Arduino. OUT of the sensor to Analog Pin A0 on the Arduino. Connect SCK and SDA pins of LCD is to I2C pin of the Arduino. Arduino Code for Interfacing Water Level Sensor Module with Arduino /* Interfacing Water Level Sensor with Arduino UNO using Analog Output pin of Module by www.playwithcircuit.com Using this code we will know the Analog Value when water level is very low and when it is very high. */ #include <LiquidCrystal_I2C.h> // Library to Run I2C LCD // define the size of filter array #define FILTER_SIZE 20 // Set the LCD address to 0x27 for a 16 chars and 2 line display LiquidCrystal_I2C lcd(0x27, 16, 2); // Define the analog pin for the soil moisture sensor const int WaterSensorPin = A0; // Analog Value filter int Filter(int sensorValue); void setup() { // initialize the lcd lcd.init(); // Turn on the Backlight lcd.backlight(); // Clear the display buffer lcd.clear(); // Print a message to the LCD lcd.setCursor(0, 0); lcd.print("Analog Value:"); } void loop() { // Variable to store sensor values int sensorValue; // Variable to store filtered values int filteredValue; // Read the value from the soil moisture sensor sensorValue = analogRead(WaterSensorPin); filteredValue = Filter(sensorValue); // Display the filtered Analog Value on the LCD lcd.setCursor(0, 1); lcd.print(filteredValue); // Clear Previous Data lcd.print(" "); // Wait for 50ms before the next loop delay(50); } // Averaging filter to filter Analog Values int Filter(int sensorValue) { static int analogArray[FILTER_SIZE] = { 0 }; int filteredValue = 0; int i; // Shift the Elemnent removing the oldest value stored at index 0 for (i = 0; i < (FILTER_SIZE - 1); i++) { analogArray[i] = analogArray[i + 1]; } // Put the current value in the last element of Array i.e at index FILTER_SIZE-1 analogArray[FILTER_SIZE-1] = sensorValue; for (i = 0; i < FILTER_SIZE; i++) { filteredValue += analogArray[i]; } // Return Filtered Analog Value return (filteredValue / FILTER_SIZE); } To learn how to build water level sensor checkout: https://playwithcircuit.com/water-level-sensor-arduino-tutorial/ Video Quote
bidrohini Posted March 21 Report Posted March 21 Yes. I used this water level sensor. It is very convenient. I made some projects with this. Here is another water level sensor that is quite smart and handy. https://www.pcbway.com/project/shareproject/Water_Level_Sensor_adbc9a98.html This water level sensor employs a smart setup using LEDs 1 through 8 to indicate different levels. With the assistance of a female header, 10k and 330-ohm resistors, along with the ULN2803A to amplify the signal, this design offers effective monitoring. Each LED represents a specific level, providing a clear visualization of the water. A simple and efficient solution for level control in tanks and water systems. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.