Sensors, Automation & Monitoring

🤖 Sensors, Automation & Monitoring

You can't manage what you don't measure. A two-container farm has dozens of variables that need constant monitoring — and the difference between a thriving crop and a dead one can be a few hours of unmonitored pump failure or temperature spike. Automation isn't a luxury; it's your farm's immune system.

The Sensor Stack: What to Measure

SensorWhat It MeasuresPlacementAccuracy NeededCost Each
Temperature/Humidity (SHT40/45)Air temp ±0.2°C, RH ±1.8%3–4 per container at different heights±0.3°C$5–15
CO₂ (SCD40/SCD41)CO₂ ppm ±50 ppm1 mid-container, 1 near exhaust±50 ppm$15–40
pH probeNutrient solution acidityMain reservoir, return line±0.1 pH$30–80
EC probeNutrient concentrationMain reservoir±0.1 mS/cm$20–60
Dissolved oxygenO₂ in nutrient solutionReservoir (DWC applications)±0.2 mg/L$50–150
Water temperatureReservoir temp (DS18B20)Reservoir, each NFT return±0.5°C$3–8
Water level / flowReservoir level, pump flow rateReservoir, main supply lineLevel ±1cm, Flow ±5%$10–40
Light (PAR sensor)PPFD at canopy levelOne per lighting zone±5%$50–200
Power monitorEnergy consumption per circuitDistribution panel±2%$20–50
📊 Total sensor cost per container: ~$150–300 for a comprehensive sensor suite using ESP32 microcontrollers and I²C sensors. That's less than the cost of losing one crop to an undetected pH crash.

Controller Architecture

ESP32 × 4 Sensor nodes (I²C/1-Wire) MQTT Broker Mosquitto (RPi or cloud) Home Assistant Automation engine + dashboard Relay / SSR Bank Lights · Pumps · Fans · Dampers · Humidifier · HVAC Alerting Pipeline Telegram/SMS on: pump fail · temp out of range · low reservoir · power loss Internet-connected via 4G failover — remote monitoring keeps the farm safe when you're away InfluxDB (time-series) + Grafana (dashboards) · All sensor data logged every 30s

Automation Rules: The Critical Ones

RuleTriggerActionPriority
CO₂ damper controlVeg CO₂ < 600 ppm AND mushroom CO₂ > 800 ppmOpen inter-container damper, run duct fanMedium
CO₂ safety overrideEither container CO₂ > 3,000 ppmClose damper, vent both containers to outside, alertCRITICAL
High temp emergencyContainer temp > 90°FMax HVAC, dim/kill lights, alertCRITICAL
Pump failure detectionFlow sensor = 0 for > 60 secondsSwitch to backup pump, alertCRITICAL
Low reservoirWater level < 20%Auto-fill from holding tank (if available), alertHigh
pH driftpH outside 5.5–6.5 for > 30 minDose pH adjuster, alert if persistsHigh
Light scheduleTime = 06:00 / 22:00Relay on/off LED circuitsLow
Power lossGrid + solar both downBattery-only mode, kill non-critical loads, alertCRITICAL

Recommended Hardware Stack

You don't need enterprise industrial controllers. A robust DIY stack works perfectly for a two-container farm:

  • Microcontrollers: ESP32 dev boards — WiFi + Bluetooth, $5–10 each, Arduino or ESPHome firmware
  • Central controller: Raspberry Pi 4 or 5 running Home Assistant + Node-RED + Mosquitto MQTT
  • Sensors: Sensirion SHT4x (temp/humidity), Sensirion SCD4x (CO₂), Atlas Scientific or DIY pH/EC probes, DS18B20 (water temp), YF-S201 (flow), BH1750 or SQ-120 (PAR light)
  • Relays: Solid-state relays (SSR) for lights (inductive loads), mechanical relays for pumps/fans
  • Connectivity: WiFi primary, 4G LTE failover modem (critical for remote alerts)
  • Power monitoring: CT clamp sensors on each circuit + INA219 voltage/current sensors for DC side
📱 Remote access: Home Assistant's companion app lets you monitor and control your farm from anywhere. Set up a WireGuard VPN tunnel (or use Nabu Casa cloud) for secure remote access. Set alert thresholds for the critical rules above, and you'll know about problems before your plants do.

🧠 Quick Check

Q1: What communication protocol is typically used to connect ESP32 sensor nodes to the central controller?

Q2: What is the most critical alert to set up for a two-container farm?