Electronic – Analog Reading of YL 69 Soil Moisture Sensor


I am using an ESP8266 12 F Module with 3 x 1,2 V Batteries.
I tried to connect an infamous chinese soil moisture sensor YL 69 like this (LINK) to the anaolog pin of the ESP8266 Module. The Module works from 3,3 Volt on to 5 V and comes with an electronic board that includes a potentiometer

I figured that since I am not going to use the digital output I don't need that extra board between ESP8266 12F and the sensor. The Sensor without the extra board offers two pins.

First Try:
First Pin: A0 Pin of ESP Module and Second Pin: Ground of Batteries
This got me some readings between 0.00 and 340 but it seemed quite unreliable and reacting slowly to changes.

Second Try:
A0 Pin of the ESP module to one pin and Pin4 of the ESP8266 12 F module to the other pin (the idea was that with this method I would be able to completely turn off the sensor while it's not needed and therefore increase durability of the sensor)
This got me some readings between 0.00 and 1024.
However while using digitalWrite(PIN 4,LOW); I still got readings out of the sensor… how if theres no current flowing?

I tried the same sensor with an NodeMCU Board that contains an ESP8266 chip. I used the extra board and the analog output and got very good and reliable readings.


  1. What could I do to adjust the setup so that the readings with the "naked" ESP8266 module match those of the NodeMCU model.
  2. Why was I able to get some reading at the second try setup when digital pin 4 was turned off?
    1. Is there a way to use the First try method but to shutdown the sensor completely when not needed so that it doesn't draw any current?

UPDATE Thanks again for the help: Here's my solution:
I connected VCC to one Pin of the Sensor and Ground via a 10 K resistor to the other Pin. Than I connected the Analog Read Pin from the ESP Module to a point between the 10 K Resistor and the Ground wire and I end up with usable reading between 0 and 1024 although I noticed that the readings reach 1024 quite soon but it is good enough for my uses.

Best Answer

This sensor is not a "voltage generator", it is actually a resistance that varies with moisture. To measure it you should make a voltage divider. Connect a 10k resistor from AO to Vcc.

Inspect the original board and you will find this resistor standing between the sensor connector and the OpAmp.

Update: Turning off to increase sensor durability... I assume you are using the sensor as its main purpose - soil moisture measuring. If your ESP is totaly disconnected from any voltage potential like in a battery only operation and no wired communication, it will be fine to reduce the diferential voltage on both pins to 0. I am not sure can you switch the ESP's analog input to digital output - if you can, than you could write a 0 there. If not, you could use a small signal external n-channel MOSFET driven by some of the other pins to short this pin.

This of course will draw some current trough 10k resistor from batteries, which may not be such a good idea for a battery operated device. You could use another small signal p-channel MOSFET to disconnect the pull up resistor. Both p- and n- channel MOSFETS could be driven by a single digital output pin.


simulate this circuit – Schematic created using CircuitLab

If your ESP is also connected to other devices, incl. battery chargers, then a leakage current may flow trough sensor's GND to the soil and cause sensor plates' corrosion. Your option here is to isolate the sensor when it is not used - you can do it with a DPST (or DPDT) relay to disconnect both sensor leads.