Free tools Windows power users keep installed
One-click scans. No signup required.
To connect a YL-69 soil probe to a NodeMCU ESP8266, plug the probe into the YL-38 controller, connect VCC to 3V3, GND to GND, and AO to A0. Use the analog output for numerical readings and cloud graphs; leave DO disconnected unless you only need a dry/not-dry trigger.
This is a useful low-cost prototype for monitoring planting areas, landscaping, or construction-site demonstration gardens. It is not a laboratory soil-water measurement system, and the ESP8266’s A0 voltage range must be verified before wiring the sensor.
As an Amazon Associate I earn from qualifying purchases.
What the YL-69 and YL-38 components do
The names describe two parts of one commonly sold sensor kit:
- YL-69: the fork-shaped, two-electrode probe inserted into soil.
- YL-38: the small controller board that powers the probe and provides analog and digital outputs.
The YL-38 commonly includes an LM393 comparator, a sensitivity potentiometer, indicator LEDs, and four pins: VCC, GND, AO, and DO. The probe measures electrical resistance between its exposed electrodes. Moisture, salts, fertilizer, soil type, temperature, probe depth, and corrosion all affect that resistance.
#1 Best Overall
- Soil Moisture Sensor Module:10Pcs Soil Moisture Sensor Module Kit
- Soil Moisture Sensor Size:30*16*6.3mm
- Soil Moisture Meter Detection Module Size:59*19.5mm
- Volts:3.3V-5V
- Comparator Chip:LM393
Use AO for a changing numerical signal. DO is only a comparator output: the potentiometer sets a threshold and the pin changes state when the measured signal crosses it. DO is therefore suitable for a simple alarm or relay trigger, not a calibrated moisture percentage. Because inexpensive modules differ, verify whether DO is HIGH or LOW in the dry condition on the actual board.
Some sellers use “YL-69” to describe the complete kit rather than only the probe. The physical parts and pin labels matter more than the listing name. See the YL-38/YL-69 module description for a typical layout.
Parts and prerequisites
- NodeMCU development board based on the ESP8266
- YL-69 probe and YL-38 controller
- Jumper wires and a USB data cable
- Arduino IDE and ESP8266 board support
- 2.4 GHz Wi-Fi network for cloud logging
- Optional: a transistor or MOSFET for switched sensor power, an external ADC, or a capacitive sensor
Here, “NodeMCU” means an ESP8266 development board, not the separate NodeMCU Lua firmware project. Board labels such as D7 and A0 are board-level labels; they are not interchangeable with raw ESP8266 GPIO numbers. On a common NodeMCU 1.0/ESP-12E layout, D7 maps to GPIO13, but confirm the markings and documentation for your particular board.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Recommended wiring
YL-69 probe → two-pin probe header on YL-38
YL-38 VCC → NodeMCU 3V3
YL-38 GND → NodeMCU GND
YL-38 AO → NodeMCU A0
YL-38 DO → not connected
The two probe wires are not polarity-sensitive for a basic resistance measurement. Swapping them can affect the direction or interpretation of the analog signal on some modules.
Rank #2
- Chip is TL555
- Operating Voltage: 3.3 ~ 5.5 VDC
- Output Voltage: 0 ~ 3.0 VDC
- PH:2.54MM
Important ESP8266 A0 warning
A bare ESP8266 ADC accepts approximately 0–1.0 V. Many NodeMCU development boards add an input divider so their board-level A0 pin accepts a higher voltage, but the divider and limits are not identical across boards and clones. Check the schematic for your board and measure the YL-38 AO voltage before connecting it.
Do not assume that a sensor output safe for a 5 V Arduino Uno is safe for an ESP8266. If AO can exceed your board’s A0 limit, use a correctly calculated resistor divider or an external ADC such as an ADS1115-class device. The ESP8266 Arduino-core ADC documentation and board documentation explain the distinction between the bare ADC and board-level scaling.
Install ESP8266 support in Arduino IDE
- Install the current Arduino IDE.
- Open Preferences.
- Add this address under Additional Boards Manager URLs:
https://arduino.esp8266.com/stable/package_esp8266com_index.json - Open Tools → Board → Boards Manager.
- Search for
esp8266and install the ESP8266 platform. - Select the matching board, commonly NodeMCU 1.0 (ESP-12E Module) for an ESP-12E board.
- Select the correct serial port.
Menu names vary slightly between Arduino IDE versions. If the labels differ, use the current equivalent board-manager controls. First upload a serial-only test rather than introducing Wi-Fi and cloud code at the same time.
Test the analog reading first
This sketch powers the resistive sensor only during a measurement, takes ten samples, and prints their average:
Rank #3
- 【Soil Moisture Meter】This probe measures soil moisture using analog resistance, making it a valuable tool for plant care. It can be used in various settings, such as gardens, greenhouses, and automated watering systems.
- 【Easy to Read】This soil moisture detector produces a low signal on the DO port when the detected humidity exceeds the set threshold. It is compatible with Arduino and Raspberry Pi for easy integration.
- 【Adjustable Threshold】Rotate the blue potentiometer to adjust the detection threshold. Power and signal indicators on the board provide real-time status updates.
- 【Analog Value Output】The soil humidity sensor's AO port provides an analog voltage value that can be obtained in real-time through the AD port of your microcontroller.
- 【Corrosion Resistant Alloy Probe】A waterproof sensor probe with high corrosion resistance lasts at least 6 months in soil.
const uint8_t SENSOR_POWER = D7;
const uint8_t SENSOR_PIN = A0;
int readMoistureRaw() {
digitalWrite(SENSOR_POWER, HIGH);
delay(100);
long total = 0;
const int samples = 10;
for (int i = 0; i < samples; i++) {
total += analogRead(SENSOR_PIN);
delay(10);
}
digitalWrite(SENSOR_POWER, LOW);
return total / samples;
}
void setup() {
Serial.begin(115200);
pinMode(SENSOR_POWER, OUTPUT);
digitalWrite(SENSOR_POWER, LOW);
}
void loop() {
int raw = readMoistureRaw();
Serial.print("Raw moisture value: ");
Serial.println(raw);
delay(2000);
}
Open Tools → Serial Monitor and select 115200 baud. Test the probe in the intended soil at the intended depth. Do not treat a value such as 900 as a universal “dry” threshold: the original project reported a value around that range in its own setup, but ADC scaling and soil conditions vary.
Calibrate the sensor for the actual soil
The module does not directly measure volumetric water content. A percentage is only a convenient local scale between two observed reference points.
- Insert the probe at the depth and orientation you will use.
- Record several readings in dry soil and save the average as
dryValue. - Water the soil thoroughly, allow excess water to drain, and record several readings.
- Save the second average as
wetValue. - Confirm experimentally whether wet soil produces a higher or lower ADC value.
- Repeat calibration if the soil mix, fertilizer, probe depth, or sensor changes.
int moisturePercent(int raw, int dryValue, int wetValue) {
long percent = map(raw, dryValue, wetValue, 0, 100);
return constrain(percent, 0, 100);
}
Display both the raw value and the calculated percentage. The raw value helps diagnose a loose wire, a saturated ADC, or a deteriorating probe. Soil composition, mineral content, temperature, drainage, electrode spacing, and corrosion can all change the result.
Add Wi-Fi and ThingSpeak logging
ThingSpeak is a practical example for a simple cloud graph. Create a channel, enable a field such as Moisture, and copy the channel write API key. Keep that key and your Wi-Fi password private. The MathWorks NodeMCU moisture example documents a comparable ESP8266 workflow.
Rank #4
#include <ESP8266WiFi.h>
const char* ssid = "YOUR_WIFI_NAME";
const char* password = "YOUR_WIFI_PASSWORD";
const char* writeApiKey = "YOUR_THINGSPEAK_WRITE_KEY";
WiFiClient client;
const uint8_t SENSOR_POWER = D7;
const uint8_t SENSOR_PIN = A0;
int readMoistureRaw() {
digitalWrite(SENSOR_POWER, HIGH);
delay(100);
long total = 0;
for (int i = 0; i < 10; i++) {
total += analogRead(SENSOR_PIN);
delay(10);
}
digitalWrite(SENSOR_POWER, LOW);
return total / 10;
}
void connectWiFi() {
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
unsigned long started = millis();
while (WiFi.status() != WL_CONNECTED &&
millis() - started < 20000) {
delay(500);
}
}
void setup() {
Serial.begin(115200);
pinMode(SENSOR_POWER, OUTPUT);
digitalWrite(SENSOR_POWER, LOW);
connectWiFi();
}
void loop() {
if (WiFi.status() != WL_CONNECTED) connectWiFi();
int raw = readMoistureRaw();
if (WiFi.status() == WL_CONNECTED &&
client.connect("api.thingspeak.com", 80)) {
String request =
"GET /update?api_key=" + String(writeApiKey) +
"&field1=" + String(raw) +
" HTTP/1.1rnHost: api.thingspeak.comrn"
"Connection: closernrn";
client.print(request);
client.stop();
}
Serial.print("Uploaded raw value: ");
Serial.println(raw);
delay(30000);
}
Replace the raw upload with moisturePercent(raw, dryValue, wetValue) after calibration. Keep a local serial diagnostic even when the cloud is unavailable. A 30-second interval also avoids needless ADC polling and provides a recovery opportunity if Wi-Fi drops.
ADC and Wi-Fi limitations
The ESP8266 has one user-accessible ADC channel. Reading several analog sensors requires an external multiplexer or ADC. The ESP8266 Arduino-core documentation also warns that excessively frequent analogRead() calls can interfere with Wi-Fi timing, and readings may be cached for several milliseconds while Wi-Fi is operating.
Use a small batch of samples, average or median-filter them, avoid tight polling loops, and include timeouts in Wi-Fi connection code. Never block forever waiting for an unavailable access point.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minutePower switching and probe life
Leaving voltage across exposed resistive electrodes continuously accelerates electrochemical corrosion and can make readings drift. Briefly powering the module during measurement reduces that exposure and saves energy in battery projects.
Best Value
- Through adjusting the potentiometer to control the soil humidity threshold,can automatic watering the vegetable garden, garden, control the flower pot soil moisture.
- Include Relay module, Mini water pump, Plastic Battery Storage Case Holder, USB power cable, Jumper wires, 0.5m Vinyl Tubing and Soil Moisture Detector Module.
- Note:Do not pour water directly on the sensor. The humidity of the water will rust the sensor.
- Easy assemble, make your life more automated, particularly suitable for people who travel frequently!
Powering the entire YL-38 from a GPIO is appropriate only when its current draw is within that GPIO’s safe operating limits. If the current is unknown, the board resets, or the wiring is long, power the module from 3V3 and switch it with a suitably rated transistor or MOSFET. Do not drive a pump directly from a NodeMCU GPIO.
Troubleshooting
| Symptom | Likely cause | Action |
|---|---|---|
| Always 0 | No common ground, wrong pin, or no power | Confirm VCC, GND, AO, and the probe connector. |
| Always near maximum | Disconnected probe, very dry soil, wrong ADC range, or floating AO | Check probe continuity and measure AO voltage. |
| Value never changes | Reading DO instead of AO or probe not connected | Use AO and inspect the two-pin probe header. |
| NodeMCU resets | Supply sag or excessive GPIO load | Use a stable supply and separate switched sensor power. |
| Wi-Fi fails after adding readings | Excessive ADC polling or blocking code | Reduce sampling, add delays, and use connection timeouts. |
| Digital logic is reversed | Comparator polarity differs between modules | Test dry and wet states, then invert the logic if necessary. |
| Readings drift over time | Corrosion or changing soil chemistry | Shorten measurement time or replace the probe with a capacitive sensor. |
| Upload fails | Wrong board, port, cable, or bootloader connection | Check board and port selections and use a data-capable USB cable. |
When to upgrade
The YL-69/YL-38 combination is inexpensive, widely available, easy to understand, and well suited to classroom demonstrations and short prototypes. Its exposed resistive electrodes are a poor choice for unattended measurements over months or years.
Choose a capacitive sensor for longer-lived installations or battery projects. It generally avoids direct electrode corrosion, but it still needs calibration and low-cost versions can vary in sealing and output voltage.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallChoose an external ADC when the NodeMCU A0 range is uncertain, the sensor output needs safer scaling, higher resolution is useful, or multiple analog sensors are required. Choose an ESP32 when you need more analog inputs, Bluetooth, or room for additional automation.
For a construction or landscaping installation, separate sensing from irrigation control. A pump requires its own correctly rated driver, flyback protection, suitable power wiring, and isolation where appropriate. Soil monitoring alone does not make a pump-control circuit safe.
For local systems, MQTT or Home Assistant can avoid dependence on an external cloud service. ThingSpeak remains a straightforward option for a quick graph; check its current service documentation and limits before designing a production deployment.
Quick Recap
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.




