DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowFall ResetAmazon USFall reset deals: check better picks before checkoutAmazon US: today's deals, useful picks and quick comparisons.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
Blog

Capacitive Soil Moisture Sensor v1.2 with Wemos D1 Lite: Wiring, Code and Calibration

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

Connect the sensor’s VCC to 3V3, GND to GND, and AOUT/SIG to A0 on the Wemos board. Then read the analog value in Arduino IDE and calibrate it in your own soil. In most v1.2 capacitive modules, a higher raw value means drier soil and a lower value means wetter soil.

What this project measures

A capacitive soil-moisture v1.2 module is an analog probe. It senses changes in the soil’s electrical properties and sends a voltage to the controller; it does not calculate a percentage, provide Wi-Fi, or store readings itself. The Wemos D1 Lite supplies the processing and, when programmed for it, wireless connectivity.

Unlike a basic resistive two-prong sensor, the sensing area is usually formed on the PCB rather than by exposed metal electrodes. That reduces corrosion and electrolysis during long-term use. It does not make the entire module waterproof: keep the connector and upper electronics above the marked insertion line and dry. DFRobot’s comparable SEN0193 is specified as a capacitive analog sensor with a 3.3–5.5 V supply range; generic v1.2 boards can vary in construction and output. See the DFRobot documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check the exact Wemos board

The historical project associated with this title uses a WEMOS D1 mini Lite and reads the ESP8266 ADC with analogRead(0). “D1 Lite,” “LOLIN D1 mini,” generic D1 mini boards, and NodeMCU clones are not automatically identical. Check the silkscreen and locate the pin marked A0.

#1 Best Overall

The current LOLIN D1 mini documentation lists one analog input, 3.3 V I/O, and a 3.2 V maximum analog input. Older and cloned boards may use different ADC scaling. Use A0 in the sketch for clarity, and verify your board’s specification before applying a voltage to it.

Parts and prerequisites

  • Wemos D1 mini Lite or compatible ESP8266 board
  • Capacitive soil-moisture sensor v1.2
  • Three jumper wires or the supplied three-pin cable
  • USB data cable and computer
  • Arduino IDE
  • A plant pot and the soil in which the sensor will actually be used

An optional OLED, relay or MOSFET driver, pump, external supply, multimeter, and enclosure can be added later. Validate the sensor before adding irrigation hardware.

Wiring

Sensor VCC   -> Wemos 3V3
Sensor GND   -> Wemos GND
Sensor AOUT  -> Wemos A0
Wemos USB    -> computer

Use 3.3 V for the first build. Although some sensor boards accept 5 V, powering a sensor at 5 V can produce an output that exceeds the safe analog-input range of some ESP8266 board revisions. The published output specifications also differ between sensor versions: DFRobot lists approximately 1.2–2.5 V on its product page and up to 3.0 V in its documentation. Do not assume an anonymous module has the same circuit.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Insert only the sensing portion into the soil. Do not submerge the connector or electronics. For outdoor use, place the upper section in a suitable enclosure and prevent condensation from contacting the board. A current v1.2 product manual also warns against inserting the probe beyond its marked line.

Arduino IDE setup

  1. Install Arduino IDE.
  2. Install the ESP8266 board package using the Boards Manager or the method described by the installed core.
  3. Select the appropriate Wemos, LOLIN D1 mini, or ESP8266 board profile.
  4. Select the USB port for the board.
  5. Upload the test sketch below.
  6. Open Serial Monitor at 115200 baud.

Board names and menu labels can differ between Arduino IDE and ESP8266 core versions. Choose the profile that matches the board documentation rather than assuming every D1-style board uses the same entry.

First test: read the raw ADC value

const int SOIL_PIN = A0;

void setup() {
  Serial.begin(115200);
  delay(500);
  Serial.println();
  Serial.println("Capacitive soil sensor test");
}

void loop() {
  int raw = analogRead(SOIL_PIN);

  Serial.print("Raw ADC: ");
  Serial.println(raw);

  delay(1000);
}

You should see a changing integer about once per second. The numerical range depends on the board’s ADC scaling and ESP8266 Arduino core. Test the probe in air, dry soil, and thoroughly wetted soil. Confirm the direction and range on your hardware instead of copying values from another board.

Calibrate it in the actual pot

Calibration values are not universal. They change with soil texture, compaction, salinity, fertilizer, temperature, supply voltage, probe position, and the individual sensor.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Quick range calibration

  1. Record several readings with the probe in open air.
  2. Place it at the intended depth in the intended soil mix and record readings.
  3. Water the soil thoroughly, let excess water drain, and record the wet-soil readings.
  4. Record the reading at the point where the plant actually needs water.
  5. Use these measured values for your thresholds.

Air and water are useful boundary checks, but they are not a substitute for soil calibration. For a plant monitor, define at least a dry threshold, a preferred target range, and a wet limit. A recent study of low-cost capacitive probes highlights the importance of soil-specific calibration; a mapped percentage should not be presented as laboratory-grade volumetric water content without independent validation. See the research review and study.

Rank #3
MTDELE 10Pcs 3.3V Capacitive Soil Moisture Sensor Module
  • Capacitive Soil Moisture Sensor: Compatible with for Arduino Raspberry Pi
  • Size:98*23mm
  • Operating Voltage:3.3V DC;Output Voltage:0-3.0V DC
  • Interface Type:PH2.54 3Pin
  • Commodities include:10Pcs Soil Moisture Sensor;10Pcs connecting wire

Convert the reading to a relative moisture estimate

Most v1.2 modules produce a higher raw value in drier conditions and a lower value in wetter conditions. The mapping therefore needs to be inverted:

const int SOIL_PIN = A0;

// Replace these examples with values measured on your board and soil.
const int DRY_VALUE = 800;
const int WET_VALUE = 400;

int moisturePercent(int raw) {
  raw = constrain(raw, WET_VALUE, DRY_VALUE);
  return map(raw, DRY_VALUE, WET_VALUE, 0, 100);
}

void setup() {
  Serial.begin(115200);
}

void loop() {
  int raw = analogRead(SOIL_PIN);
  int percent = moisturePercent(raw);

  Serial.print("Raw ADC: ");
  Serial.print(raw);
  Serial.print("  Moisture estimate: ");
  Serial.print(percent);
  Serial.println("%");

  delay(1000);
}

Here, 0% means the calibrated dry endpoint and 100% means the calibrated wet endpoint. It is a project-specific index, not an absolute measurement. Values such as 800 and 400 are placeholders; do not treat them as specifications.

To reduce random noise, average several samples:

int readAverage(uint8_t samples = 10) {
  long total = 0;

  for (uint8_t i = 0; i < samples; i++) {
    total += analogRead(A0);
    delay(10);
  }

  return total / samples;
}

Averaging cannot correct an incorrect calibration, water damage, ADC saturation, poor grounding, or a defective sensor.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Using the sensor for automatic watering

Do not switch a pump from one instantaneous ADC reading. Average samples, require the threshold to remain crossed for a defined period, and use hysteresis: start below a dry threshold and stop only after reaching a wetter stop threshold.

Rank #4
VKLSVAN 3PCS Capacitive Analog Soil Moisture Sensor 3.3-5.5V Corrosion Resistant Humidity Detection Sensors Garden Watering DIY for Arduino for Raspberry Pi
  • 【Specifications】Operating voltage: DC3.3-5.5V, output voltage: DC0-3.0V, size: 98*23mm,Interface:PH2.0-3P, The sensor has a 3-pin "gravity" interface, which can be directly connected to the gravity I/O expansion baffle.
  • 【Capacitive sensing】Soil moisture content is measured by capacitive sensing. Instead of measuring soil moisture by resistive sensing like other types of humidity sensors,It avoids the problem of resistive sensors and their easy corrosion, greatly extending its working life.
  • 【DIY watering system】 If you combine this soil moisture sensor with a small water pump, hose, relay module, etc., you can create an automatic watering device. DIY kit for a device that waters when the soil is dry, freeing you from daily watering and making things easier. Rest assured when you are away for work or travel.
  • 【Easy to use】Insert the soil and detect the output of real-time soil moisture data. This soil moisture meter has a built-in constant voltage chip and supports a 3.3V voltage operating environment, so it will work normally with a 3.3V master board. Micro PCs can be operated by simply connecting one external ADC (analog signal to digital signal) conversion module.
  • 【Application in Various Occasions】Connect the screen and the motherboard to obtain real-time soil moisture data. Suitable for automatic watering system robots, etc. Commonly used in garden plants, humidity detection, and smart agriculture.

Also add a maximum pump runtime, a cooldown period, and a check that the reading changes after watering. Treat a disconnected or impossible fixed reading as a fault. Never power a pump directly from a Wemos GPIO. Use a correctly rated relay or logic-level MOSFET driver, a separate pump supply, common grounding where appropriate, and flyback protection for inductive loads. Keep mains-voltage work separate from this low-voltage prototype.

ESP8266 limitations

  • The D1 mini has only one analog input, so one probe uses the board’s ADC.
  • Multiple analog probes require an external multiplexer or ADC.
  • An I2C OLED does not create additional analog channels.
  • Wi-Fi activity, USB power, motors, and switching regulators can introduce noise.
  • Never exceed the analog-input limit for the exact board revision.

If you need several probes, an external ADC such as an ADS1115 or MCP3008 may be appropriate, but it adds wiring, software, cost, and reference-voltage considerations.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting

The reading never changes

  • Confirm that AOUT is connected to A0, not a digital GPIO.
  • Check VCC and the shared ground.
  • Verify the cable pin order against the sensor markings.
  • Insert the sensing area, not just the insulated upper section.
  • Confirm the Serial Monitor is set to 115200 baud.
  • Test another sensor or measure the wiring with a multimeter.

Some inexpensive Wemos- and NodeMCU-compatible combinations report intermittent or absent output, so do not assume every generic v1.2 board is electrically identical. See the community troubleshooting report.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The reading is fixed

  1. Disconnect AOUT from A0.
  2. Measure the sensor’s VCC-to-GND voltage.
  3. Measure AOUT-to-GND in air.
  4. Touch or wet the sensing area and check whether AOUT changes.
  5. Reconnect it only after confirming the output is within the board’s ADC limit.

A fixed value can indicate a short to ground or VCC, reversed connector wiring, missing ground, damaged electronics, water ingress, saturation, or a poor power supply.

Best Value
AITRIP 10 Pack Capacitive Soil Moisture Sensor Corrosion Resistant for Arduino Moisture Detection Garden Watering DIY Electronic for Arduino and Raspberry Pi (10PCS)
  • This capacitive soil moisture sensor is distinguished from most resistive sensors on the market and uses capacitive sensing to detect soil moisture. The problem that the resistance sensor is easily corroded is avoided, and its working life is greatly extended.
  • The sensor has a built-in voltage regulator chip that supports a 3.3-5.5V working environment, which means it works even on a 3.3-5.5V Arduino control board. A miniature PC such as the Raspberry Pi only needs an external ADC (analog to digital signal) conversion module to work.
  • With an external screen and a motherboard, you can talk to your plants! See if it is thirsty and you don't need more water to moisten.Garden plants, Moisture detection, Intelligent agriculture
  • Interface: PH2.54-3P, Size: 98 x 23mm (LxW)
  • Package Includes: 10pcs Capacitive Soil Moisture Sensor

The reading is backwards

This is normally expected. Rename the variable or reverse the mapping so that the reported wetness increases as the raw ADC value falls.

The reading drifts

Temperature, supply variation, fertilizer or salt, probe movement, changing soil contact, water pooling, Wi-Fi activity, and pump noise can all contribute. Use a regulated supply, short wiring, sample averaging, physical support for the probe, and recalibration after changing soil or installation conditions.

It works in water but not soil

Water is a convenient extreme, not a universal soil reference. Air gaps, potting mix, mineral content, compaction, and placement alter the electrical response. Calibrate in the actual soil and use plant-specific thresholds.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When this sensor is a good choice

It is a practical low-cost option for a plant monitor, greenhouse logger, Wi-Fi notification project, or small irrigation prototype when you need an analog three-wire sensor and can calibrate locally. The DFRobot SEN0193 is worth considering when a documented SKU, schematic, cable, and calibration guidance are more important than the lowest anonymous-marketplace price. Its listed price was $5.90 when checked on August 18, 2026; price, stock, shipping, and tax vary by location.

A branded sensor is not automatically a calibrated scientific instrument, and generic v1.2 modules should not be assumed equivalent to SEN0193. A manufacturer claim that capacitive construction provides two to three times the lifespan of resistive sensors should be treated as a product claim, not a universal independent result.

When to choose an alternative

  • Resistive probe: cheaper and simple, but exposed electrodes corrode more readily.
  • Waterproof capacitive probe: better for exposed irrigation installations, usually at higher cost and with different wiring.
  • Digital I2C sensor: avoids consuming the D1 mini’s lone ADC, but costs more and is not a drop-in replacement.
  • External ADC: useful for multiple analog sensors or greater measurement flexibility.

DFRobot lists a separate waterproof capacitive sensor, SEN0308, while the Arduino community also discusses I2C alternatives such as Adafruit’s capacitive soil sensor. These are different products with different interfaces and should be selected for the installation rather than substituted blindly.

Final recommendation

This sensor and a Wemos D1 Lite make a straightforward beginner-to-intermediate electronics project: wire the analog output to A0, print raw values, calibrate in the real soil, and treat the resulting percentage as a relative moisture index. It is a poor choice for uncalibrated scientific measurements, fully submerged installation, or unattended outdoor irrigation without enclosure, electrical protection, hysteresis, and pump safeguards.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.