Skip to content
Project
18 min read
October 17, 2026

ESP32 Automatic Plant Watering with Blynk and Soil Moisture Sensor

Build an ESP32 plant-watering system with a soil-moisture sensor and Blynk dashboard. Calibrate wet/dry readings, use hysteresis, limit pump runtime, and keep a safe local policy if Wi-Fi or cloud access disappears.

ESP32 Automatic Plant Watering with Blynk and a Soil Moisture Sensor

This project reads a soil-moisture sensor with an ESP32 and provides visibility through Blynk. It uses a local threshold rule to decide when watering is needed, while the dashboard shows moisture and pump state. Keeping the core watering logic on the ESP32 means it can continue the local rule during a temporary cloud outage.

Soil sensors vary widely. Capacitive modules, resistive probes and boards with different output circuits can produce different raw readings and have different corrosion behavior. Calibrate your exact sensor in the actual growing medium before treating an ADC number as a percentage.

Image pending: Image placeholder: ESP32 reads a soil sensor, runs local hysteresis and pump timeout, and reports moisture/pump state to a Blynk dashboard.

Hardware and safety

Use an ESP32, a soil-moisture sensor with an output compatible with the ESP32 ADC, a suitable DC pump, a correctly rated MOSFET/driver or relay interface, an external pump supply and appropriate tubing/reservoir. Never power a pump directly from an ESP32 GPIO. Add inductive-load protection as required by the driver design, keep water away from exposed electronics, and choose a supply rated for the pump's startup current.

Check the sensor output voltage before connecting it to an ESP32 analog input. A 5 V sensor output can exceed the ESP32 input limit; use an appropriate 3.3 V supply or level conditioning. If the pump uses a separate supply, follow the driver/module wiring instructions and grounding requirements.

Image pending: Image placeholder: safe low-voltage wiring of ESP32 analog sensor, MOSFET pump driver, flyback protection and separate pump supply; no exposed mains.

1. Calibrate the sensor instead of guessing the percentage

Record the raw ADC value from your sensor in two repeatable conditions: relatively dry soil and thoroughly watered soil after excess water drains. Call these DRY_RAW and WET_RAW. Many capacitive probes produce a lower ADC count when wetter, but this is not universal—measure your actual module.

A percentage calculated from those two points is only a rough relative moisture indicator. Soil type, compaction, temperature, salinity, probe placement and sensor aging all affect it. Don't present the percentage as a scientifically calibrated volumetric water-content measurement unless you have calibrated against an appropriate reference method.

Image pending: Image placeholder: calibration worksheet showing measured dry and wet ADC readings and an example mapping to a relative 0–100% moisture indicator.

2. Configure Blynk datastreams

Create datastreams for V1 moisture percentage, V2 pump state, V0 automatic/manual mode, and V3 manual pump request. Bind dashboard widgets to those channels and label their meanings clearly. The mode switch determines who owns the pump request; the manual control is used only in manual mode. Dashboard widgets should not be treated as proof that the physical pump is running.

Treat the device auth token like a password. Confirm current Blynk account features and event/retention limits in official documentation before promising a specific plan entitlement.

Image pending: Image placeholder: Blynk dashboard showing relative soil moisture, automatic/manual mode, pump status and manual pump request with clear labels.

3. Firmware pattern with hysteresis and a run-time limit

The sketch below illustrates a simple automatic rule. Replace template/device credentials, calibrate DRY_RAW and WET_RAW, verify the pump driver polarity and adjust the threshold to the plant and soil. It deliberately turns the pump off after a maximum continuous run. A production design should also handle sensor disconnection, reservoir empty detection and a minimum interval between watering cycles.

C++
Image pending: Image placeholder: Arduino IDE code with calibration constants, hysteresis thresholds and maximum pump run duration. Credentials replaced by placeholders.

The code's map() function assumes DRY_RAW and WET_RAW are the endpoints you measured; verify that your probe's wet/dry direction matches them. The run-time limit reduces the chance of a continuous pump command but is not a complete dry-run or overflow safeguard. Add independent water-level sensing and a physical maximum-run protection if the application requires it.

Image pending: Image placeholder: test sequence showing dry soil, threshold crossing, pump off at the upper threshold and maximum-run cutoff.

Offline behavior and troubleshooting

The watering rule runs locally but this example uses Blynk calls in a simple teaching sketch; it is not a fully hardened production controller. Decide how reconnecting to Blynk should affect mode and manual requests, and avoid restoring cloud state blindly. Local watering should have maximum-run limits, cool-down intervals and safe behavior if the sensor is disconnected.

Percentage seems reversed: remeasure DRY_RAW/WET_RAW and fix the mapping. Pump won't run: test sensor thresholds, driver polarity and separate supply with the pump disconnected from water hazards. Pump cycles rapidly: widen the hysteresis gap and sample at a sensible interval. Pump runs too long: verify the time limit and add independent hardware/process protections where necessary.

Next steps

Official reference: Blynk documentation. Calibrate the sensor and validate pump behavior in a supervised low-voltage test before leaving the system unattended.

Signal In

Built from what makers search for

The lookups piling up in SolderHub's search bar every day shape what we publish next — new component pages, board guides, and firmware notes, sent out as they go live.

By subscribing you agree to our Privacy Policy. Unsubscribe anytime.