2.29 Water Sensor Module

Overview

In this lesson, you will learn how to use a water sensor module. A water sensor module is designed for water detection, which can be widely used in sensing the rainfall, water level, even the liquid leakage.

Fritzing Circuit

In this example, we directly connect the pins of Water Sensor Module to pins of Mega 2560 Board. We use analog A0 to get the value of Water Sensor Module, and get the pin「S」of Water Sensor Module to A0, 「-」to GND, 「+」to 5V.

../_images/image227.png

Schematic Diagram

../_images/image228.png

Code

Note

  • You can open the file 2.29_waterSensorModule.ino under the path of sunfounder_vincent_kit_for_arduino\code\2.29_waterSensorModule directly.

  • Or copy this code into Arduino IDE 1/2.

  • Or click Open Code to open it in Web Editor.

  • Then Upload the Code to the board.

After uploading the code to the Mega2560 board, you can open the serial monitor to see the read value of the pin. As the water level rises, the readings increase. Readings vary within the range 「0」~「1023」, but influenced by the environmental condition and the characteristics of water level sensor, the actual reading range may be smaller than the theoretical range. Refer to Part 1-1.5 Analog Read to check the detail code explanation.

Phenomenon Picture

../_images/image229.jpeg