Codey OnlineArduino & ESP32 component library › Water Sensor
Water Sensor
Sensors

Water Sensor

A water sensor module detects the presence of water or moisture and provides an analog output on the S pin. Connect GND to ground, VCC to the module’s power supply, and read S with an Arduino/ESP32 analog input to get a varying signal that reflects moisture or wetness level.

Width: 28.1 mm

Pinout — Water Sensor

Pin Signal Description
GND ground Ground return for the water sensor module.
VCC power Positive supply input for the water sensor, typically 3.3V or 5V.
S analog Analog sensor output proportional to detected water level or conductivity.

Example wiring diagram — Water Sensor

From To Wire
board:GND x1:GND black
board:5V x1:VCC red
board:A0 x1:S green

Example Arduino code — Water Sensor

This example was written and compile-checked for the arduino-uno. Codey Online adapts it to any other supported board for you.

// Water Sensor canonical example for Arduino Uno
// Reads the analog output from the water sensor and prints it to Serial.

const int waterSensorPin = A0;

void setup() {
  Serial.begin(9600);
  while (!Serial) {
    ;
  }
  Serial.println("Water Sensor example starting...");
}

void loop() {
  int sensorValue = analogRead(waterSensorPin);

  Serial.print("Water sensor analog value: ");
  Serial.println(sensorValue);

  delay(500);
}

Related components

18650 Battery Shield with USB-C Charger and 5V Boost Converter

18650 Battery Shield with USB-C Charger and 5V Boost Converter

2.4 inch OLED Display I2C 3.3V

2.4 inch OLED Display I2C 3.3V

3.5 inch TFT LCD Shield

3.5 inch TFT LCD Shield

50kg Load Cell Weight Sensor

50kg Load Cell Weight Sensor

Build your Arduino or ESP32 project with AI

Describe what you want to build. Codey Online writes the code, draws the wiring diagram, compiles it and flashes your board straight from the browser.

Start for free