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
| Sensor | What It Measures | Placement | Accuracy Needed | Cost 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 ppm | 1 mid-container, 1 near exhaust | ±50 ppm | $15–40 |
| pH probe | Nutrient solution acidity | Main reservoir, return line | ±0.1 pH | $30–80 |
| EC probe | Nutrient concentration | Main reservoir | ±0.1 mS/cm | $20–60 |
| Dissolved oxygen | O₂ in nutrient solution | Reservoir (DWC applications) | ±0.2 mg/L | $50–150 |
| Water temperature | Reservoir temp (DS18B20) | Reservoir, each NFT return | ±0.5°C | $3–8 |
| Water level / flow | Reservoir level, pump flow rate | Reservoir, main supply line | Level ±1cm, Flow ±5% | $10–40 |
| Light (PAR sensor) | PPFD at canopy level | One per lighting zone | ±5% | $50–200 |
| Power monitor | Energy consumption per circuit | Distribution 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
Automation Rules: The Critical Ones
| Rule | Trigger | Action | Priority |
|---|---|---|---|
| CO₂ damper control | Veg CO₂ < 600 ppm AND mushroom CO₂ > 800 ppm | Open inter-container damper, run duct fan | Medium |
| CO₂ safety override | Either container CO₂ > 3,000 ppm | Close damper, vent both containers to outside, alert | CRITICAL |
| High temp emergency | Container temp > 90°F | Max HVAC, dim/kill lights, alert | CRITICAL |
| Pump failure detection | Flow sensor = 0 for > 60 seconds | Switch to backup pump, alert | CRITICAL |
| Low reservoir | Water level < 20% | Auto-fill from holding tank (if available), alert | High |
| pH drift | pH outside 5.5–6.5 for > 30 min | Dose pH adjuster, alert if persists | High |
| Light schedule | Time = 06:00 / 22:00 | Relay on/off LED circuits | Low |
| Power loss | Grid + solar both down | Battery-only mode, kill non-critical loads, alert | CRITICAL |
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?