I will try to discus all the physical quantities and under what circumstances they are needed to be taken under consideration. Lets begin which the introduction of the arduino water level sensor and how it works?
How arduino water/rain/moisture level sensor/detector works?
All the sensors are analog. Means they provide and analog output. Analog output is in range from 0 to 5 volts. We need to read this analog voltage using ADC(analog to digital converter) and convert it to equivalent digital value fr future computations.
All water sensors have two legs. Some have multiple stripes. Each leg or strip is plated with a conducting material often copper. Both legs of water level sensor act as a variable resistor. To one leg we supply +voltage and to other we make ground. When both the legs are dipped in water an electric path is created between the two legs and sensor start conducting current. The value of conductance/current depends on the ratio or level of water. In the below diagram water sensor circuit and how it works is broadly highlighted.
Note: When arduino water level sensor is continuously exposed to water. Its copper starts to peer off from legs and the sensor starts decomposing. Its the biggest draw back of water detector. The life time of sensor can be increased by plating its copper part or legs with gold(not original gold; process name is gold platting). I advice you to purchase the sensor whose legs are protected from this decomposing phenomena. I used water/soil moisture sensors in big plant pots and the sensors starts giving malware error prone readings after 1 week 🙁
Its little hard for newbies to understand whats going on in the circuit and how it is producing the result. I suggest to skip it and move on 😀
Where can arduino water detector can be used?
- Arduino water sensor can be used to check the leakage of water or viscous substance from pipes.
- Water detector can be used to check spil of water from tank.
- Water sensor can measure the salinity or moisture water content in soil.
- Flood and rain situation can be monitored.
- Quantity or level of water in tank can easily be monitored using arduino water level sensor.
- Water sensor can be utilized to monitor and water the garden.
Interfacing water level sensor with arduino uno
I am going to connect the analog output of arduino water sensor to arduino analog channel 1. The code of the project is simple. In setup() function of arduino code serial monitor of arduino is initialized at 9600 bps. The instruction Serial.begin(9600) is starting the serial monitor. In the loop function i am reading the analog channel 1 of ADC. The instruction int sensor=analogRead(A1) reads the analog channel and stores the analog value in variable sensor. Next instruction Serial.println(sensor) prints the water sensor analog reading on serial monitor of arduino.
Arduino water sensor as analog input
Now lets start the digital part. Water sensor will output a high 5 volt signal as output on its D0 pin when the water touches the sensors legs. The threshold also plays a vital role here. If the quantity of water increase the threshold level(explained above) only then the D0 pin goes high. Arduino digital pin 3 is used to check the status of water detector D0 pin. If its high then arduino will buzz an alarm which is connected to pin 8 of ardunio.
Same like analog sensor code arduino water detector digital code is simple, straight forward and easy to understand. First the Arduino pins are defined by using define macro.
#define Danger 3
#define ALARM 8
Arduino pin 3 is named as Danger and 8 as ALARM. In the setup() function both the pins are declared OUTPUT. The statements
declares the pins as output
In the loop() function i am reading the Danger pin. The if statement if( digitalRead(Danger) == LOW) is reading the status of Danger pin. If found high i switch ON the ALARM. If found low i switch OFF the ALARM. The statement digitalWrite(ALARM, LOW/HIGH) switches the alarm ON and OFF.
Arduino water sensor as digital input
Filed Under: Arduino, Microcontroller Projects