Build a Farm Monitoring Station with ESP32: Soil Moisture, Temperature & Humidity
Share
A DIY farm or field monitoring station is a small battery- or mains-powered device that reads soil moisture, air temperature and humidity at a fixed location and reports them without a person walking out to check — typically a microcontroller with WiFi, a soil probe, and a combined temperature/humidity sensor, all running on a regulated power supply. The point isn't novelty: soil moisture is the single number that tells you whether a plant or field actually needs water right now, and pairing it with air temperature and humidity lets you separate "the soil is dry because it's hot and hasn't rained" from "the soil is dry and nothing else explains it." Because the controller has WiFi built in, the same station that logs data locally over serial today can push those same three readings to a phone or dashboard later, with no hardware changes.
What parts does a farm monitoring station need?
At minimum, five things: a WiFi-capable microcontroller, a soil moisture sensor, a combined temperature/humidity sensor, a stable power supply, and wiring. Each does one job:
- Microcontroller with WiFi — reads both sensors and is the part that eventually sends data off-site. This build uses a bare ESP32-WROOM-32 module: an Xtensa dual-core chip at 240MHz with 4MB flash, 520KB RAM, a 12-bit ADC, 48 pins, and built-in WiFi and Bluetooth.
- Soil moisture sensor — the capacitive version measures moisture through a change in capacitance under an insulated coating rather than bare exposed metal, which matters for anything left in the ground for weeks at a time (see below). It outputs a raw analog value (0–1023) and needs calibration against dry and wet reference readings before that number means anything.
- Temperature/humidity sensor — a DHT22 (AM2302) module reports both from one part over a single digital wire: -40°C to +80°C for temperature (±0.5°C accuracy) and 0–100% relative humidity (±2% RH accuracy).
- Power supply — a 5V 2A adapter is more than enough current for this build (the active parts draw roughly 87mA combined), but a bare ESP32-WROOM-32 module expects 3.3V DC directly at its power pin, not 5V. Unlike a devkit board with an onboard regulator, this module needs that 5V stepped down to 3.3V before it reaches the chip, or you risk damaging it.
- Wiring — standard breadboard wire connects everything for prototyping before any permanent installation.
Why use ESP32 instead of Arduino for this?
A monitoring station is only useful if you can eventually get the data off the device without walking out to the field, and that's exactly where a bare Arduino Uno falls short — it has no wireless radio at all, so it needs a separate WiFi shield or module bolted on. The ESP32-WROOM-32 module in this build has WiFi and Bluetooth built into the same chip, a 12-bit ADC (finer resolution on the soil moisture reading than the Uno's 10-bit ADC), and a deep-sleep current draw of roughly 5µA — low enough that a battery- or solar-powered station can sleep between readings and run for a long time on a small power budget. None of this is required to read two sensors and print values to Serial, which is exactly what the generated firmware below does first, but it's the reason to pick ESP32 over Arduino for a station meant to eventually report data remotely rather than sit tethered to a laptop.
How do you keep the electronics safe outdoors?
None of these parts are weatherproof as sold. A few things matter for a station left in a field or garden rather than on a bench:
- Enclosure: put the ESP32 module, DHT22, and wiring inside a sealed plastic project box (not metal — metal blocks the WiFi signal you added the ESP32 for). Run the soil probe's cable out through a cable gland or a sealed grommet so the enclosure stays closed.
- The DHT22 needs airflow: it measures ambient humidity, so it can't be sealed in fully airtight plastic or it will just read the trapped air inside the box. Vented enclosures or a small sheltered opening (shielded from direct rain and sun) are the usual compromise.
- Moisture inside the enclosure: a small silica gel packet inside the box helps protect the ESP32 module and any exposed solder joints from condensation, which is a more common failure point outdoors than the sensors themselves.
- The soil probe itself: this is exactly why the build above uses the capacitive sensor rather than the cheaper resistive (LM393-style) module — resistive probes have two bare exposed metal prongs that corrode from electrolysis if left powered in damp soil for weeks, and a corroding probe drifts and eventually fails. The capacitive sensor has no exposed electrode.
- Move off the breadboard for anything permanent: breadboard connections work for prototyping and testing the code, but vibration and humidity outdoors will eventually work a jumper loose. Solder the final wiring to perfboard or a small custom PCB before installing it in the field.
How often should you check soil moisture?
Soil moisture doesn't change on the timescale of seconds — it changes over hours as water drains and evaporates. The firmware generated for this build reads every 5 seconds, which is a sensible default for watching values scroll on a serial monitor while you're testing and calibrating, but it's far more often than a deployed station needs. For an installed monitoring station, especially a battery- or solar-powered one, spacing readings out to every 15–60 minutes (and letting the ESP32 deep-sleep in between) gives you plenty of resolution on soil drying trends while dramatically extending runtime between charges or battery swaps. Air temperature and humidity can be read on the same schedule as soil moisture since there's no cost to reading the DHT22 alongside the soil sensor on each wake cycle.
Watch it built live: a real ESP32 farm monitoring build
Rather than describe a generic build, we typed one real sentence into Compoden's AI build assistant on the storefront and let it pick parts, price them, and explain the build — unscripted, screenshotted as it happened:
"I want to build a farm monitoring station to measure soil moisture, temperature and humidity remotely using an ESP32."

The assistant returned a five-part tray on the first try and opened with the point of the whole build: "This build lets you measure how wet the soil is, and the air temperature and humidity, from a distance. The parts work together to collect this information and send it over Wi-Fi, so you can check on your farm without being there." It picked a bare ESP32-WROOM-32 module specifically because, in its own words, "it has Wi-Fi to send your farm data remotely, and enough pins to connect all your sensors." It flagged the soil sensor's calibration requirement unprompted, and it caught a real wiring detail before anything got connected: the power adapter it selected outputs 5V, but "the ESP32-WROOM-32 expects a 3.3V DC power input. You will need to make sure the power is stepped down to 3.3V before connecting it to the microcontroller, or you risk damaging the board."
Watch the firmware get generated
We then asked Compoden's build companion, Soldr, to write the actual ESP32 firmware for the same kind of project — reading a soil moisture sensor and a temperature/humidity sensor and printing both to the serial monitor:

Soldr matched all five parts against its catalog, compiled the build, and generated a sketch that includes the DHT sensor library, wires the soil probe's analog output to GPIO32, and wires the DHT22's single data line to GPIO4. GPIO32 is a real, deliberate choice rather than an arbitrary pin: it's on the ESP32's ADC1 bank, which keeps working correctly even while the WiFi radio is active — the ADC2 bank shares hardware with WiFi and can return unreliable analog readings when the radio is on, which would defeat the purpose of a station meant to report readings wirelessly. The generated sketch sets a 115200 baud serial rate and a 5-second read interval, and the panel notes which library (the Arduino DHT sensor library) needs to be installed before it will compile.
What this build teaches you
This build is a compact lesson in mixed-sensor design: reading one analog signal (the soil probe) and one single-wire digital signal (the DHT22) from the same microcontroller, keeping the analog reading off a WiFi-shared ADC bank, and getting the power regulation right on a bare module rather than a devkit board with a built-in regulator. It's also a template — the same pattern of "one WiFi controller, a handful of environmental sensors, a stable 3.3V rail" extends directly to light sensors, rain gauges, or a second soil probe in another bed, without changing the underlying approach.
Get everything in this build
The exact five parts Soldr picked for the farm monitoring build above, at today's live price and stock — each links straight to checkout, or add the whole tray in one click.
| Part | Price | |
|---|---|---|
| ESP32-WROOM-32 | ₹280 | Add to cart → |
| Capacitive Soil Moisture Sensor V2.0 | ₹55 | Add to cart → |
| DHT22 (AM2302) Temperature and Humidity Sensor Module | ₹100 | Add to cart → |
| 5V 2A Micro-USB Power Adapter | ₹140 | Add to cart → |
| 23 AWG Multi-Strand Breadboard Wire | ₹10 | Add to cart → |
| Total | ₹585 | Add all 5 to cart → |
Prices and stock verified live at the time this was written; Compoden's storefront always reflects the current price at checkout.
Built and Backed by Compoden
Every part above ships from Compoden's own India stock, tested for compatibility before it's carded together — not sourced individually and hoped to work. Delivery in 3–7 days across India, with COD and UPI available at checkout. If a part in this build doesn't perform as described, Compoden's support team will help you troubleshoot or replace it.
FAQ
Can this farm monitoring station run on solar or battery power instead of a wall adapter?
Yes, and it's a natural fit — the ESP32 can drop into deep sleep between readings at roughly 5µA, so a station that wakes up every 15–60 minutes, takes a reading, and sleeps again can run for a long time on a small solar panel and battery instead of a permanent wall adapter.
Do I need to calibrate the soil moisture sensor before trusting its readings?
Yes. The capacitive sensor outputs a raw analog value with no fixed meaning on its own. Take one reading with the probe in dry air and another with it in a cup of water, then use those two readings as your 0% and 100% endpoints to map any future reading to a moisture percentage.
Why does the generated firmware use GPIO32 for the soil sensor instead of any analog-capable pin?
GPIO32 sits on the ESP32's ADC1 bank, which continues to give reliable analog readings even while WiFi is transmitting. The ADC2 bank shares hardware with the WiFi radio and can return distorted readings when the radio is active, which matters for a station whose entire purpose is reporting readings over WiFi.
Can I add more sensors to this same station later, like a rain gauge or light sensor?
Yes. The ESP32-WROOM-32 module has 48 pins in total, with plenty of GPIO, additional ADC channels, and I2C/SPI available beyond what this build uses, so the same station can take on more sensors without a second microcontroller.