26 – Arduino and water sensors



    • Get to know water, rain or condensation sensors.
    • Assemble a prototype

Bill of materials

Arduino UNO

 Arduino UNO or equivalent.

Jumper wires  Some jumper wires.
Water sensor
 A water sensor


Water sensors


For several reasons, it is not uncommon need to detect whether there is water in some place. It may be because we want to know if there has been a water leak, or to see if there is condensation in a certain area, and very often we need to know the level of the liquid in a tank.

In the Arduino world there are very cheap and friendly water sensors, that can be used to detect all these things, as long as you be aware that the quality of these cheap detectors is limited.

Specifically, I have serious doubts about its durability in the medium term if you hold them outdoor as rain detectors, or immerse them in the liquid to have level meters. I have no doubt about its usefulness but its duration.

In any case as they are quite cheap, I have thought to include a simple example of its use, and who knows, maybe they can be useful to you.

They are very simple and all you need to do is connect voltage and GND and the third pin is an analog signal proportional to the amount of water that detects.

That’s all. Let’s see the circuit wiring diagram.





The wiring is very simple. Simply connect voltage and GND and the remaining pin is the output analog signal.


Chapter 26, wiring diagram


  • In this diagram I have used a few short wires out of need, but when you assemble the prototype, I recommend you using the longer wires you have, because electronics and water do not get on well.
  • Be careful not to pour water in our Arduino, or it will die on active service.
  • If you submerge the sensor in water, to be used as a level meter, be careful not to submerge also the connection pins to the Arduino board, otherwise you will cause a short circuit.
  • There is not enough voltage to cause an accident, but it is always advisable to prevent a short circuit.



The program is as simple as abc and after all the programming in the latest chapters, you will be hungry for more.

Let’s read the sensor signal A0 and send the reading to the serial console to see the measure. Getting wet more and more the sensor you will see how values change as the amount of water detected grows.

Sketch 26.1
void setup()
void loop()

It is so easy that it is even disgusting!

As I have not been able to record a decent video of the sensor, the water, and the output of the Arduino serial console, I have decided to include only a display in the video that allows us to see the reading of the water sensor connected to the A0 pin.

I have not included the program with the display, because we have not talked about these components, but don’t worry, we will explain them soon.


As nevertheless you keep asking me the program with the display I’ve put it here in case you want to take a look:

Sketch 26.2





    • We have introduced a very simple water sensor. It is very useful if you want to detect a flood or simply some rain drops.
    • Watch out! It is not a humidity sensor, which is a very different kind of sensor.
    • It can be used as a not very accurate water level sensor.




No Comments

Give a Reply