You want to stop killing your basil every summer. I get it. You’ve got a patch of earth, a few potted herbs, and the best of intentions—but no idea what’s actually going on in your soil. Time to fix that.
We’re going to build a garden sensor network. Cheap. DIY. Self-hosted. No cloud rubbish. The idea is simple: stick sensors in the ground, collect data on moisture, temperature, and light, ship it wirelessly to a central hub, and visualise everything nicely in Grafana. No mystery, no dead plants.
The Gear
Here’s what I am going to use. You can adapt based on what’s lying around in your parts bin:
- ESP32 Dev Boards — Low power, built-in Wi-Fi, dead easy to flash.
- Capacitive Soil Moisture Sensors — More reliable than resistive ones, and won’t corrode in a week.
- DS18B20 Waterproof Temperature Sensors — Digital, one-wire, bulletproof.
- BH1750 Light Sensor — I2C, straightforward, works a treat in outdoor light.
- Home Wi-Fi — You’ll want stable coverage where your garden is.
- MQTT Broker (Mosquitto) — Running on a Raspberry Pi or local server.
- InfluxDB — Time-series database to store all that sweet sensor data.
- Grafana — The dashboard to end all dashboards.
Wiring It All Up
Each ESP32 handles one sensor station. You can scale this up easily. Here’s the wiring breakdown:
- Soil Moisture Sensor → Analogue pin (e.g., A0)
- DS18B20 → Digital pin with a 4.7kΩ pull-up resistor
- BH1750 → SDA/SCL to ESP32’s I2C pins (usually GPIO21/22)
Bundle everything into a waterproof enclosure (IP65 or better), run the cables out the bottom, and seal with silicone. Leave the light sensor exposed, obviously.
Firmware: Tasmota or Arduino?
You can roll your own code with PlatformIO or Arduino IDE, but I went with ESPHome—it integrates beautifully with Home Assistant and speaks MQTT natively. Here’s a sample config for one node:
esphome:
name: garden-node-1
platform: ESP32
board: esp32dev
wifi:
ssid: "YOUR_WIFI_SSID"
password: "YOUR_WIFI_PASSWORD"
mqtt:
broker: "192.168.1.10"
sensor:
- platform: adc
pin: A0
name: "Soil Moisture"
unit_of_measurement: "%"
filters:
- lambda: |-
return (1.0 - x) * 100.0;
- platform: dallas
address: 0x3C
name: "Soil Temperature"
- platform: bh1750
name: "Ambient Light"
address: 0x23
Flash that onto your ESP32, reboot, and it’ll start shouting MQTT messages to your broker.
The Data Pipeline
Here’s the flow:
- ESP32 → MQTT Broker (Mosquitto)
- Mosquitto → InfluxDB via Telegraf or custom bridge
- InfluxDB → Grafana
InfluxDB eats time-series data for breakfast. Grafana makes it look like mission control.
Set up your dashboards with thresholds (e.g. soil moisture below 30% = red alert). Add annotations if you’re testing different watering schedules. This is where your garden starts talking back.
Powering the Nodes
You’ve got options:
- USB Power Banks — Easy, but you’ll be charging them weekly.
- 18650 Cells + Solar Panels + Charge Controller — Best for long-term deployments.
- Mains Power — If you’ve got an outdoor plug, you’re laughing.
Use deep_sleep
modes if you want to preserve battery—most sensors only need to send data every 10–15 minutes.
Lessons from the Dirt
- Wi-Fi signal strength matters. ESP32s don’t love marginal connections. Add an antenna or reposition as needed.
- Weatherproof everything. Water gets in. Every time.
- Cheap sensors drift. Calibrate them with known dry and saturated conditions.
- Grafana alerts are brilliant. Set up notifications when conditions go out of range. Slack, email, push—whatever works for you.
The Result
Now I get a ping when the tomatoes are thirsty. I can see how hot the soil got during that 30°C week in July. I know when to shade the lettuce or when it’s time to mulch.
It’s not just automation. It’s situational awareness. You’re not guessing—you’re responding.
The garden’s still on you. But now, you’ve got intel.