Water Level Sensor + ESP32: Pinout, Wiring Diagram and Working Code

Water Level Sensor + ESP32: Pinout, Wiring Diagram and Working Code

Quick answer: the board's header is marked S, + and −. Connect − to GND, S to GPIO32 (an ADC1 pin) and + to a 3.3 V source: either the 3V3 pin or, as in the sketch, GPIO25 switched on only while reading. Powering it from 3.3 V keeps S inside the ESP32's input range. Treat the reading as wet versus dry, not as a precise depth.

Red resistive water level sensor board with exposed traces and an S + - header sold by Compoden
Resistive water level sensor. The header silkscreen reads S, + and −. Distributor-permissioned Compoden catalogue photo, resized to 474 px.

What is the water level sensor pinout?

The header is labelled on the board itself. In the listing photo the silkscreen beside the three pins reads S, + and − in that order. The listing calls the same pins OUT, VCC and GND. There is no maker datasheet for this generic board.

Water level sensor pins (order as printed on the board in the listing photo)
Pin Function Source
S Analog output; rises as more of the traces are wet Photo silkscreen + listing
+ Supply, 3.3–5 V Photo silkscreen + listing
− Ground Photo silkscreen + listing

How do you wire the water level sensor to an ESP32?

Water level sensor to ESP32 DevKit (30-pin) wiring
water level sensor pin ESP32 DevKit pin Why this pin
S GPIO32 ADC1 pin: works with Wi-Fi on
+ GPIO25 (switched) or 3V3 Switching power cuts the time the traces carry current
− GND Common ground

Which ESP32 pins should you avoid?

Every GPIO choice on this page follows the same rules for the 30-pin ESP32-WROOM-32 DevKit (the board Compoden stocks as the ESP32 30-pin CP2102 development board). Espressif's ESP32 GPIO reference is the source:

  • Never use GPIO6–11. They connect to the module's SPI flash.
  • Avoid the strapping pins GPIO0, 2, 5, 12 and 15 for sensors. Their level at reset decides boot mode and flash voltage, so a sensor holding one of them can stop the board booting. GPIO0 is not even on the 30-pin header; it only goes to the BOOT button.
  • GPIO34, 35, 36 and 39 are input-only and have no internal pull-up or pull-down. They are ideal for analog inputs and useless for outputs or clocks.
  • Use ADC1 (GPIO32–39) for analog readings. ADC2 pins (GPIO0, 2, 4, 12–15, 25–27) cannot be read while Wi-Fi is running.
  • Leave GPIO1 and GPIO3 alone. They carry the USB serial link used for uploads and the Serial Monitor.
  • ESP32 GPIOs are 3.3 V only. They are not 5 V tolerant.

What voltage should the water level sensor use with an ESP32?

The listing gives 3.3–5 V supply and an output of up to about 4.2 V at 5 V supply, which is too high for an ESP32 pin. At 3.3 V supply the output cannot exceed 3.3 V, so power it from 3.3 V. The listing itself notes that 3.3 V boards should power it at 3.3 V.

The exposed copper traces corrode when current flows through them in water, and the listing warns against leaving the sensor submerged. Switching + from a GPIO only for the few milliseconds of each reading slows that down. The board carries only a power LED and a single transistor, but check that its current stays within the ESP32 GPIO drive limits in Espressif's datasheet; if in doubt, power + from 3V3 instead.

Working Arduino code for the water level sensor on ESP32

No library is needed. The sketch turns the sensor on, waits 10 ms, reads S and turns it off again, once a second. Note the raw value dry, half-wet and fully wet in your own water, then set thresholds from those numbers. Water conductivity changes the reading.

// Resistive water level sensor (pins S, +, -) + ESP32 DevKit (ESP32-WROOM-32)
// Wiring: + -> GPIO25 (powers the sensor only while reading), - -> GND, S -> GPIO32 (ADC1)
// Powering from a GPIO limits how long the exposed traces carry current.
const int LEVEL_POWER = 25;
const int LEVEL_SIG = 32;

void setup() {
  Serial.begin(115200);
  pinMode(LEVEL_POWER, OUTPUT);
  digitalWrite(LEVEL_POWER, LOW);
  analogReadResolution(12);
}

void loop() {
  digitalWrite(LEVEL_POWER, HIGH);
  delay(10);                           // let the reading settle
  int raw = analogRead(LEVEL_SIG);
  digitalWrite(LEVEL_POWER, LOW);
  Serial.printf("Water level raw=%d (near 0 = dry, higher = more trace under water)\n", raw);
  delay(1000);
}

Compile check: this exact sketch compiled for the esp32:esp32:esp32 board (ESP32 Dev Module, ESP32 Arduino core 3.3.10) on 5 October 2026. A clean compile proves the code and libraries agree. It does not prove your wiring, so test it on the bench with the Serial Monitor at 115200 baud.

Common mistakes with the water level sensor and ESP32

  • Powering + from 5 V. S can then reach about 4.2 V, above the ESP32's limit.
  • S on an ADC2 pin such as GPIO4 or 25–27. ADC2 cannot be read while Wi-Fi is on.
  • Leaving it powered and submerged all the time. The traces corrode.
  • Treating it as a depth gauge for a big tank. It senses only along its roughly 40 mm trace area.
  • Submerging the header end. Only the trace area should touch water.

Where can you get the parts?

Parts used in this guide (Compoden catalogue)
Item Role Link
Water level sensor module Analog wet/dry and shallow level detection View water level sensor
ESP32 30-pin CP2102 development board Controller with ADC, Wi-Fi and Bluetooth View ESP32 board

Want this sensor in a bigger build? Describe the whole device in Soldr, for example “I want to build a water leak alarm with an ESP32 and a water level sensor”. Soldr returns the exact parts, a wiring map and code that compiles, all from one parts list, so the pins in the code match the pins in the wiring. Compoden stocks the parts and delivers across India.

Sources

Pin labels: the board silkscreen in the Compoden listing photo. Supply, output range and sensing area: the same listing (no maker datasheet exists for this generic board). ESP32 ADC and pin rules: Espressif ESP32 GPIO reference.

Related ESP32 wiring guides

Frequently asked questions

Which ESP32 pin should I use for a water level sensor?

Connect S to an ADC1 pin such as GPIO32, because ADC2 pins stop working when Wi-Fi is on. Connect − to GND and + to 3.3 V.

Can I power the water level sensor from 5 V with an ESP32?

Not if S goes straight to the ESP32: the listing gives up to about 4.2 V output at 5 V supply. Power it from 3.3 V.

How do I stop the water level sensor corroding?

Power it only while reading, for example from a GPIO switched on for a few milliseconds, and keep the header end dry.

Back to blog

Open this project in the Soldr app → What is Soldr.ai → parts, wiring and code for what this guide builds