Arduino Projects
Water Level Sensor Arduino Tutorial
Overview
In This Tutorial, I will show how you interface the Water Level Sensor With Arduino Nano Microcontroller And How You Write the Code.
Water Level Sensor
The water Level Sensor Has a series of parallel exposed traces to measure droplets/water volume in order to determine the water level.
The water level sensor is easy to monitor the water level as the output to analog signal Is Directly proportional to the water level.
The ADC Pin is Directly connected to the Arduino’s analog PIN.
Features:-
- Voltage:- DC 3-5v
- Current:- 20mA
- Sensor Type:- Analog
- Humidity:- 10% – 90%
Water Level Sensor Pinout
- VCC – 5v
- GND – GND
- Signal – A0
Wiring Diagram Water Level Sensor With Arduino
Testing Of Water Level Sensor
Display Water Level Sensor Reading In Serial Monitor
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
int lowerThreshold = 300; int upperThreshold = 440; #define sensorPower 4 #define sensorPin A0 int val = 0; int redLED = 5; int yellowLED = 6; int greenLED = 7; void setup() { Serial.begin(9600); pinMode(sensorPower, OUTPUT); digitalWrite(sensorPower, LOW); pinMode(redLED, OUTPUT); pinMode(yellowLED, OUTPUT); pinMode(greenLED, OUTPUT); digitalWrite(redLED, LOW); digitalWrite(yellowLED, LOW); digitalWrite(greenLED, LOW); } void loop() { int level = readSensor(); if (level == 0) { Serial.println("Water Level: Empty Range"); digitalWrite(redLED, LOW); digitalWrite(yellowLED, LOW); digitalWrite(greenLED, LOW); } else if (level > 0 && level <= lowerThreshold) { Serial.println("Water Level: Low Range"); digitalWrite(redLED, HIGH); digitalWrite(yellowLED, LOW); digitalWrite(greenLED, LOW); } else if (level > lowerThreshold && level <= upperThreshold) { Serial.println("Water Level: Medium Range"); digitalWrite(redLED, LOW); digitalWrite(yellowLED, HIGH); digitalWrite(greenLED, LOW); } else if (level > upperThreshold) { Serial.println("Water Level: High Range"); digitalWrite(redLED, LOW); digitalWrite(yellowLED, LOW); digitalWrite(greenLED, HIGH); } delay(1000); } int readSensor() { digitalWrite(sensorPower, HIGH); delay(10); val = analogRead(sensorPin); digitalWrite(sensorPower, LOW); return val; } |
Display Water Level Sensor Reading In LCD Display
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
#include <LiquidCrystal.h> //Libraries LiquidCrystal lcd(12, 11, 10, 9, 8, 7); void setup() { Serial.begin(9600); lcd.begin(16,2); } void loop() { int value = analogRead(A0); lcd.setCursor(0, 0); lcd.print("Value :"); lcd.print(value); lcd.print(" "); Serial.println(value); lcd.setCursor(0, 1); lcd.print("W Level :"); if (value == 0) { lcd.print("Empty "); } else if (value > 1 && value < 50) { lcd.print("LOW "); } else if (value > 50 && value < 150) { lcd.print("Medium"); } else if (value > 150){ lcd.print("HIGH "); } } |
If You are Interested In More Projects Then Plz Check Out
- Vehicle Accident Alert System
- DIY Ventilator Using Arduino
- Arduino Based Blind Stick With GPS And GSM
- Dam Monitoring System Using Arduino