A water sensor tells a microcontroller when water is touching it. This one has ten bare metal stripes along a strip about 40mm long. Water bridging the stripes raises the voltage on the S pin, so the reading climbs as more of the strip gets wet. It tells wet from dry and gives a rough idea of depth over that 40mm. It is not a measuring gauge, because the reading also changes with how clean the water is and with the supply voltage.
You can use it as a leak alarm under a sink, an overflow alarm near the top of a sump, or a rain detector. It runs on 3.3V or 5V, and its three pins connect with jumper wires to an analogue input on an Arduino, ESP32 or Raspberry Pi Pico. The stripes corrode if the board sits powered in water, so you power it from a spare output pin and switch it on only for each reading. The steps below show how. For a tank you want to monitor all year, an HC-SR04 ultrasonic sensor mounted above the water measures the level without touching it.
Specifications
Datasheets
Wiring & getting started
- Find the pins
Hold the board with the parts facing you and the stripes pointing left. The three pins are marked S, + and - from top to bottom. S is the signal, + is power and - is ground.
- Wire it to an Arduino
Connect S to A0, + to D7 and - to GND. Our female-to-male jumper wires push straight onto the pins. Powering + from pin D7 instead of the 5V pin lets the code switch the sensor off between readings.
- On an ESP32 or Pico
Connect S to an analogue input pin, + to a spare output pin and - to GND, then change the two pin numbers at the top of the code. These boards run at 3.3V, and a sensor powered from a 3.3V pin keeps its S output within what the input pin can take. On a 38-pin ESP32, GPIO34 for S and GPIO26 for + both work with WiFi on.
- Load the test code
Upload the code below and open the Serial Monitor at 9600 baud. A new reading appears every second.
Example Arduino codeArduino C++
// Water sensor test for an Arduino Uno or Nano. // Wiring: S to A0, + to D7, - to GND. // The sensor is only switched on while it takes a reading, // which slows the wear on the bare metal stripes in water. const int POWER_PIN = 7; const int SIGNAL_PIN = A0; void setup() { Serial.begin(9600); pinMode(POWER_PIN, OUTPUT); digitalWrite(POWER_PIN, LOW); // sensor off } void loop() { digitalWrite(POWER_PIN, HIGH); // sensor on delay(10); // let the reading settle int reading = analogRead(SIGNAL_PIN); digitalWrite(POWER_PIN, LOW); // sensor off again Serial.print("Water reading: "); Serial.println(reading); delay(1000); // one reading a second } - Check it works
With the sensor dry, the reading sits at or near 0. Dip the stripes into a glass of tap water and the number jumps, then climbs as you lower the board. Write down the dry number and the number with the stripes fully under your water, and use those two as your empty and full marks. If the reading stays at 0, check that + goes to D7. The Power light on the board should flicker once a second, each time the code switches the sensor on.
- Keep the pin end dry
Only the striped end goes in the water. Keep the end with the parts and the pins above the surface.
Note: The bare metal stripes corrode in water over time, so keep this sensor out of drinking water, food and fish tanks.

