Arduino – Water Detector / Sensor

Sensors are widely used for detecting different quantities like the presence of light, level of water, etc. One such example of a sensor is the water sensor which uses various principles of physics to detect the presence of water. This sensor is known for detecting different water levels with accuracy and precision.

This article will talk about the design of a water sensor using the Arduino board and programming software. We will study the specifications needed for this sensor, and the methods and circuit diagrams used for designing this sensor. In order to understand the functioning of the sensor, we will study the principles of the sensor. In addition to this, we will see the Arduino code written on IDE that will result in a sensor. The article will end with some frequently asked questions that can be referred to by readers.

Table of Content

  • Water Sensor
  • Types or Classification
  • Components
  • Construction
  • Important Terminologies
  • Working
  • Arduino Code
  • Advantages
  • Disadvantages
  • Applications

What is a Water Sensor?

Similar to any other sensor, the Arduino water sensor is used to sense the water level in various appliances like irrigation systems, and rainwater harvesting systems. Therefore, we can define the Arduino Water Sensor as a device that uses the sensing techniques of physics to estimate the level of water.

Arduino is used for creating this sensor since it needs to be programmed to detect the water level display the distance or maybe blink when it detects the water level.

Types or Classification of Water Detector / Sensor

There are different types of water sensors known as

  • Optical Water Level Sensor: This sensor is used to indicate if water is present or not and these sensors are based on infrared light which changes the light output due to a change in medium. Therefore, these sensors use LEDs.
  • Capacitance Liquid Level Sensor: This sensor is used to tell how much water is present. These sensors are made of two metal electrodes and their distance changes when the sensor is placed in the water medium.
  • Ultrasonic Liquid Level Sensor: This sensor is usually controlled by a microprocessor and works on the ultrasonic principle. When the sound wave is reflected from a water medium, the receiver detects the rays and predicts the height of the water.
  • Tuning Fork Level Sensor: As the name suggests, this sensor is based on the tuning fork principle which says that every object has a resonant frequency. At the resonant frequency of water, vibrations are felt in the sensor.

Components For Arduino – Water Detector / Sensor

Some components are needed for the project. The components required for designing a water sensor using Arduino include.

  • One Breadboard
  • Arduino Uno R3 (Generally this model is only preferred)
  • One Water Sensor
  • One LED
  • Some wires for making connections.
  • A 330 ohm resistor

These devices are easily available at nearby electronics shops.

Construction of Water Detector / Sensor

Here is the construction of the water level sensor

Connections of Water Sensor


The water sensor consists of 3 pins. Let us see the connections made to these pins

  • The signal pin is an analog output pin that is used for taking analog input from the analog pin on the Arduino board. This pin is connected to pin number 8 on Arduino.
  • The power pin (+Vcc) is used for supplying sufficient power to the sensor which ranges between 3.5V to 5V. This is connected to Arduino’s 5V supply.
  • The LED is also connected to the output terminal at pin 9 of Arduino.
  • The GND pin or the ground pin is used for setting a reference level in the circuit. This is connected to Arduino’s ground pin.

Important Terminologies in Arduino – Water Detector / Sensor

Here are some important terminologies about water sensor

  • Sensor: It is a device that is used to measure some quantity like water level in this case.
  • Interfacing: The Arduino board needs to be connected to the water sensor to work hand-in-hand and these connections are made using interfacing.
  • Digital Output: When the water sensor is used to indicate whether water is present or not, it is represented using digital output i.e. high or low.
  • Analog Output: When the water sensor is used to generate an analog output corresponding to the water level detected.

Working of the Water Detector

Let us see the working of a water sensor based on Arduino

Working of Water Detector Sensor


  • The sensor is made up of some copper traces. The count of these traces is 10, 5 of which are for power and the other 5 for sensing purposes. The parallel connection of traces allows the presence of one sense ambushed between two power traces.
  • The traces can be understood as variable resistors similar to potentiometers that change the circuit resistance depending on the water level.
  • The resistance varies inversely with the height of the water level. Therefore, when the maximum water level is present, the resistance is minimum and conduction is maximum.
  • When the minimum water level is present, the resistance is maximum and conduction is minimum Therefore, the output voltage produced by the sensor will vary directly with the water level.


Arduino Code for Water Detector / Sensor

Here is the pseudocode and code for making an ultrasonic Sensor using Arduino.

Pseudocode

Firstly, we need to initialize the constants that denote the pins to be used.

Define the pins that will be made for generating input and output. 
The water sensor is connected to
PIN number 8 of Arduino.
The LED is also connected to digital PIN 9. The water sensor is connected to the input PIN and the LED is
connected at the output.
The water sensor is programmed to turn LOW when the water level is detected.
The Arduino is programmed to light the LED when the water level is detected. It also generates a buzzing
noise. The LED remains OFF when no water level is detected.

Code

C++
#define Grove_Water_Sensor 8 
#define LED 9 

void setup() {
   pinMode(Grove_Water_Sensor, INPUT); 
   pinMode(LED, OUTPUT); 
}

void loop() {
   if( digitalRead(Grove_Water_Sensor) == LOW) {
      digitalWrite(LED,HIGH);
   }else {
      digitalWrite(LED,LOW);
   }
}

Advantages of Arduino- Water sensor

Let us study some advantages of Arduino-water sensor

  • The process of designing a water sensor based on Arduino is an easy task and can be used as a beginner-level project.
  • The power required to run the Arduino-based sensor is very low making it an economic choice.
  • The sensor requires minimal maintenance making it a good choice for projects.
  • The water sensor accurately predicts the water level therefore making it useful in many water level detection appliances.
  • The size of the Arduino-based sensor is very small making it compact.

Disadvantages of Arduino-Water sensor

Let us study some disadvantages of Arduino-water sensor

  • The Arduino-based water sensor can get rusted over a period of time therefore, it needs to be replaced after a certain period of time.
  • As the need for specific tasks increases, the installation design of Arduino-based sensors gets complicated.
  • The Arduino-based sensor doesn’t come with a warranty therefore there is no guarantee of these appliances.
  • The Arduino-based sensors are calibrated only to a certain extent therefore, the accuracy and precision offered by them are limited.
  • The Arduino-based sensors have a limited range over which they can predict the water level therefore, they can’t be used in appliances with variable water levels.

Applications of Arduino-water sensor

Let us study some applications of Arduino water sensor :

  • Arduino-based water sensor is used in home appliances to prevent the overflow of water from tanks.
  • Arduino-based water sensor is used in commercial factories and industries that work on water sensitivity principles.
  • Arduino-based water sensor is used in swimming pools installed in hotels and homes to prevent overflow while filling water in pools.
  • Arduino-based water sensor is used for detecting water levels in huge containers that store water for commercial purposes.
  • Arduino-based water sensor is used in washing machines that use water for cleaning.
  • Arduino-based water sensor is used in refrigerators that are used for making ice.
  • Arduino-based water sensor is used in sinks and toilets to predict the overflow in water level.
  • Arduino-based water sensor is used in fish tanks to ensure that the water level is within the safety limit and oxygen is available to fish.
  • Arduino-based water sensor is used in vehicles to indicate the fuel level.
  • Arduino-based water sensor is used in different wells like bore wells and open wells for water level detection.


Conclusion

Once you have uploaded this code on Arduino, the sensor will begin working. The Arduino will successfully turn the LED on with a buzzing sound when the water level is detected. The LED and buzz sound will be generated depending on the code written. The sensor will work accurately at different depths of water. Readers are advised to note the advantages as well as limitations of the Arduino before using it. You can make further modifications to improve the project according to your needs by incorporating some advanced boards.


Arduino – Water Detector – FAQs

What are the three terminals of the water sensor?

The water sensor has three terminals namely power pin, signal pin and ground(GND).

What is the difference between digital and analog water sensors?

The digital water sensor is used to tell whether water is present or not whereas the analog water sensor is used to tell the level of water by generating a proportional voltage level.

Which PIN is used for taking input and giving output?

The input is taken at pin number 8 of Arduino and output is generated at pin number 9.