Skip to content

About

Controlling irrigation and fertilization with Olla and ESPHome

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

126 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

🌿 Greenhouse Controller: Olla & ESPHome

Automating irrigation and fertigation using ancient wisdom, modern technology and a nerd going too far

The Challenge

Precisely dispensing the right amount of water and fertilizer for vegetables.

The Watering Dilemma: Over-watering wastes resources and harms roots, while under-watering stresses plants. Conventional timer-based systems often fail to adapt to real-time soil conditions. Using irrigation water directly from a deep well or tap during hot summer days poses a significant risk to plants. When ice-cold water hits sun-heated soil and roots, it triggers a thermal shock. This shock causes the plant's fine root hairs to contract instantly, temporarily halting nutrient and water uptake. For sensitive greenhouse crops like tomatoes, cucumbers, and peppers, this can lead to stunted growth, blossom drop, or root rot.

The Fertilization Dilemma: Adding liquid fertilizer (fertigation) introduces even greater complexity. Continuous or imprecise dosing leads to critical issues:

  • Over-fertilization & Leaching: Excess fertilizer leaches out, wasting nutrients and polluting groundwater.
  • Clogging: Fertilizer salts precipitate and clog fine emitters.
  • Sensor Drift: Traditional pH/EC sensors require frequent calibration and have a limited lifespan.
  • Inconsistent Concentration: Traditional injectors deliver decreasing concentrations as the stock tank empties.

1. The Concept

The core uses Olla irrigation: unglazed porous clay pots buried next to plants. Water and dissolved nutrients seep through the clay walls only when the surrounding soil is dry enough.

smart refilling and dosing layer:

  • Volumetric Dosing: Measures exact water volume and doses fertilizer proportionally via a PWM-controlled pump.
  • Hybrid Level Control: Each unit has a reservoir with a mechanical float valve (fail-safe) and electronic float switches (smart monitoring).
  • Water consumption: Each Olla is equipped with a water flow meter.

Avoid the temperature problem:

  • Gradual Release via Ollas: The porous clay pots act as a natural temperature buffer. Instead of flooding the soil instantly with cold water, the moisture seeps out drop by drop, allowing the water to warm up to ambient soil temperature before reaching the roots.
  • Insulated Supply Lines: To prevent the water from overheating in the sun before entering the Ollas, all main supply lines (13mm pipes) should be buried or covered with mulch to maintain a stable, moderate temperature.
  • Frequent Micro-Refills: The system refills small amounts of water at short intervals to prevent temperature fluctuations inside the Olla.
OllaFertilizer controller Olla lid

2. Complete Hardware List

Component Description Link / Details Images
Spang Flower Pots Standard Pot (In the picture). 🛒 Spang Flower Pots
Spang AquaSafe Olla. optional, same material. 🛒 Spang AquaSafe
Corner Connector Adaper to connect the water valve to the Lid on top of the pod. 🛒 Corner Connector
Cable Gland fixing and adjusting height limit switches 🛒 Cable Gland c
Plastic Coaster Lid for the pot 🛒 Lid
Reservoir Float Valve Mini mechanical valve. Closes automatically when water reaches the top, preventing overflow. 🛒 Float Valve v
Float Switch Sensors (2x) Magnetic reed switches for electronic level detection per unit (Top/Bottom). 🛒 Float Switches image
ESP32 with Relay Module Control unit. ESP32 for logic, Relay for switching AC loads (Main Valve). Powered via VIN (12V). 🛒 ESP32+Relay p
Motor Driver (DRV8871) PWM Motor Driver. Allows precise speed control of the peristaltic pump. Supports 6.5-45V. 🛒 DRV8871
Power Supply (Logic/Motor) 12V 1A DC Power Supply. Powers ESP32, Flow Meter, and Pump. 🛒 12V PSU n
Solenoid Valve (Hunter PGV-101) Professional main irrigation valve. Requires 24V AC. 🛒 Hunter Valve
Power Supply (Valve) 24V AC Transformer. Dedicated supply for the main solenoid valve. 🛒 24V AC PSU
Peristaltic Pump Dosing pump for fertilizer. Ensure 12V version is selected. 🛒 Pump
Water Flow Meter Hall-effect sensor. Connect to ESP32 5V pin for stable signal. 🛒 Flow Meter image
Waterproof Enclosure (IP65) Plastic housing (approx. 190x140x70mm) to protect ESP32 electronics. 🛒 Enclosure
Pressure Reducer Reduce the water pressure for the microdrip system 🛒 Pressure reducer
ESP Programmer The ESP on the Relaisboard has no USB port, so a programmer is needed 🛒 ESP Programmer image
Fertilizer Injector bring the fertilizer to the 13mm water pipe system 🛒 Injector image

(Note: Verify exact pinouts on product pages. Critical: Do not mix 24V AC and 12V DC lines.)

3. System Architecture

A. Dispensing the right amount of water with Ollas

An Olla is an unglazed, porous clay pot buried in the soil with only its opening exposed. It functions via osmotic pressure (and capillary action), where the dry surrounding soil creates a suction force that draws water out through the clay walls. This process releases water only when the soil is dry, automatically stopping when the desired moisture level is reached, ensuring efficient, targeted root hydration without evaporation or overwatering.

B. Flow-Based Fertigation (No pH Sensors)

  1. Measure: Water flows through the Flow Meter (powered by ESP32 5V, signal lowered through voltage divider). The ESP32 counts pulses to calculate total volume.
  2. Dose: The DRV8871 Driver activates the Peristaltic Pump with precise PWM speed control, injecting the exact fertilizer ratio (e.g., 5ml per 10L).
  3. Mix: The solution mixes in the flow before reaching the reservoirs.

C. Smart Reservoir Management (Hybrid Control)

  1. Filling: When the Bottom Float Switch signals "Empty", the ESP32 opens the main Hunter Solenoid Valve.
  2. Distribution: Water flows to all connected reservoirs in parallel.
  3. Auto-Stop:
    • Mechanical: The Mini Float Valve in each pot closes as it fills, preventing overflow even if electronics fail.
    • Electronic: When all Top Float Switch signaling "Full", the ESP32 immediately closes the main Hunter Valve.
  4. Seeping: Water slowly seeps from the pot into the soil based on soil moisture demand.

Benefits:

  • Fail-Safe: Mechanical valves prevent flooding.
  • Scalability: Multiple units on one main line.
  • Precision: PWM dosing ensures exact nutrient concentration.

⚡ Power & Wiring Architecture

The system safely separates high-power AC loads from sensitive DC logic within an IP65 enclosure.

1. DC Circuit (12V Main)

  • Source: 12V 1A DC Power Supply.
  • ESP32: Connect to VIN pin. Do not connect 12V to the 5V pin!
  • Flow Meter: Connect VCC to ESP32 5V Pin.
  • Float Switches: Connect to ESP32 GPIOs (with external pull-up).
  • DRV8871 Driver: VM to 12V, Inputs to ESP32 GPIOs.
  • Pump: Connected to Driver outputs.

2. AC Circuit (24V Valve)

  • Source: 24V AC Transformer.
  • Valve: Connected via Relay Module (NO/COM terminals).
  • Safety: Never connect 24V AC directly to the ESP32.

3. Olla sensors

After the first version, where I connected each float switch directly to the ESP, I decided to use Modbus between the ollas and the ESP (just to make it more overengineered). This gave me the opportunity to add more sensors to each olla. Now, every olla gets an Arduino Nano, an RS485 adapter, a flowmeter, and two float switches.

📦 Enclosure & Installation Tips

  • Cable Glands: Use M12 or M16 cable glands for sensor wires to maintain IP65 rating.
  • Mounting: Secure all boards (ESP32, Driver, Relay) with standoffs or double-sided tape.
  • Placement: Mount the enclosure in a shaded area to prevent overheating.

Safety Note: Ensure all 230V mains connections (inputs to power supplies) are properly insulated. Ideally, place power supplies outside the enclosure.

Key Features

  • Self-Regulating Watering: Olla pots release water only when soil is dry.
  • Upcycled Design: Uses Milbona PET bottles and Alutec boxes.
  • Hybrid Safety: Mechanical float valves + electronic sensors prevent overflow.
  • Volumetric Fertigation: Precise dosing based on flow, no pH/EC sensors needed.
  • PWM Pump Control: Variable speed for micro-dosing accuracy.
  • Scalable: Multiple Olla units on a single main line.
  • Fully Local: Runs on ESP32/ESPHome; no cloud dependency.
  • Maintain Stable Temperature: Avoid pouring ice-cold water on the roots to prevent shock.

⚙️ Setup

image

💧 Flowmeter Calibration

To ensure precise water measurement, the flowmeter must be calibrated after installation. Since the correction factor depends on the specific sensor and flow conditions, please follow this one-time process:

Step-by-Step Instructions

  1. Preparation: Ensure a measuring container (at least 10 liters) is ready.
  2. Reset Water Meter:
    • Go to your Home Assistant Dashboard.
    • Press the '1. Reset Water Meter.' Button.
  3. Perform Measurement:
    • Open the water valve and dispense exactly 10 liters.
    • Close the valve immediately.
  4. Read Value & Calculate Factor:
    • In Home Assistant, press the button '3. Set Correction Factor.' to set Correction Factor.

Note: After setting the factor, the factor will immediately display in configuration.

🧪 Fertilizer Pump Calibration

To ensure accurate dosing, the fertilizer pump must be calibrated to determine how many milliliters (ml) of fertilizer are dispensed when 10 liters of water flow through the system at maximum PWM.

Step-by-Step Instructions

  1. Connect System: Attach the liquid fertilizer container to the peristaltic pump intake and ensure the output line is connected to the main water flow path.
  2. Prime the Pump:
    • In Home Assistant, activate the switch/button "Max PWM Fertilizer Pump".
    • Let it run until all air bubbles are purged from the pump head and tubing, and liquid flows steadily.
    • Turn the pump OFF.
  3. Prepare Measurement: Place a graduated cylinder or measuring cup under the fertilizer outlet.
  4. Dispense Test Volume:
    • Activate the "Max PWM Fertilizer Pump" again.
    • Flow exactly 10 Liters of water (monitor your calibrated water meter).
    • Stop the fertilizer pump immediately when the 10L water mark is reached.
  5. Measure & Set Factor:
    • Measure the exact volume of fertilizer dispensed in milliliters (ml).
    • Enter the measured volume (e.g., 15 for 15ml) in the max PWM 10l field.
  6. ** Do the same with min PWM

Note: This value represents ml of fertilizer per 10L of water. The system will use this ratio to calculate the required pump PWM for any target dosage.

📊 Fertilizer Dosing Strategies

When calibrating your system, you can choose between two common fertilization strategies. The value you enter into the "Fertilizer per 10L" field depends on which method you select.

Strategy 1: Periodic Dosing (Label Recommendation)

Follow the manufacturer's standard advice (e.g., fertilize 1–2 times per week with the full recommended dose, water only at other times).

  • How it works: You configure your automation to activate the fertilizer pump only on specific days (e.g., Monday and Thursday). On other watering events, only the water valve opens.
  • Calculation for "Fertilizer per 10L": Enter the full recommended dose (in ml) that the manufacturer suggests for a single application per 10L of water.

    Example: If the label says "Add 15ml per 10L, twice a week", enter 15 into the field. Your automation must handle the schedule (only run pump on Tue/Fri).

Strategy 2: Continuous Dosing (Constant Feed)

Dilute the fertilizer dose and apply it with every single watering event.

  • How it works: The fertilizer pump runs every time the irrigation system activates, providing a steady, low-level nutrient supply. This prevents nutrient peaks and troughs, often leading to more consistent growth.

  • Calculation for "Fertilizer per 10L": You must mathematically reduce the weekly dose based on your watering frequency. $$ \text{Value to Enter} = \frac{\text{Weekly Recommended Dose}}{\text{Number of Waterings per Week}} $$

    Example:

    • Label recommendation: 20ml per 10L, 2 times per week (Total weekly dose = 40ml).
    • Your watering schedule: You water every day (7 times per week).
    • Calculation: $40\text{ml} / 7 \approx 5.7\text{ml}$.
    • Enter 5.7 into the "Fertilizer per 10L" field.

Summary Table

Strategy Frequency Input Value for "Fertilizer per 10L" Automation Requirement
Periodic 1–2x / week Full single dose (e.g., 15ml) Schedule pump only on specific days
Continuous Every watering (Weekly Total Dose) ÷ (Waterings/Week) Run pump with every water cycle

Tip: Continuous dosing (Strategy 2) is often preferred for automated systems with frequent, short watering cycles (like drip irrigation or Olla refills), as it mimics a natural nutrient supply and reduces the risk of fertilizer burn.

🛡️ 3-Level Safety System Against Continuous Irrigation

To prevent accidental overwatering, water damage, or fertilizer overdose, the system implements three independent safety layers. All protections run locally on the ESP, ensuring they function even if WiFi or Home Assistant fails.

1. Timeout "No Fertilizer" (Water Only)

  • Target: Switch Water
  • Function: Limits the maximum runtime for pure water irrigation cycles.
  • Configuration: Set the Timeout no fertilizer field (e.g., 130 s).
  • Scenario: Prevents a single watering cycle from running indefinitely due to an automation error or stuck logic.

2. Timeout "With Fertilizer" (Combined)

  • Target: Switch Water with Fertilizer
  • Function: Limits the maximum runtime for combined water and fertilizer cycles.
  • Configuration: Set the Timeout with fertilizer field (e.g., 130 s).
  • Scenario: Prevents both overwatering and dangerous fertilizer overdosing if the dosing pump fails to stop.

3. Hard Stop at Liters (Total Volume Limit)

  • Target: Global System (Water + Fertilizer)
  • Function: Immediately shuts down all pumps and valves once a defined total water volume has been dispensed.
  • Configuration: Set the Stop at Liters field (e.g., 200 L).
  • Scenario:
    • Acts as the ultimate fail-safe against tank depletion (running the pump dry).
    • Stops irrigation regardless of active timers if a leak causes excessive water usage.
    • Provides a hard cap on per-cycle consumption to protect the physical infrastructure.

Note: The Stop at Liters limit requires a calibrated flowmeter. Ensure your flowmeter is calibrated (see Flowmeter Calibration section) for this safety feature to work accurately.

Appendix: Terracotta Diffusion Experiment

Experiment 1: Determining Hydraulic Conductivity via Capillary Rise

To accurately model the water release curve of the Ollas, an initial experiment was conducted to analyze how water diffuses through unglazed terracotta via capillary action.

Setup & Methodology

  • A standard terracotta pot is placed inside a saucer filled with a constant level of water.
  • As water is drawn into the porous clay, the wetting front visibly climbs up the pot walls against gravity.
  • By tracking the height of this moisture line over time, we can calculate the material's hydraulic conductivity and the exact rate at which water permeates the terracotta.

Empirical Measurement Data

Use the table below to log the progression of the wetting front. This data helps calibrate the micro-refill intervals of the controller.

Timestamp (hh:mm) Time Elapsed (min) Wetting Front Height (cm) Calculated Seepage Rate (mm/h)
10:14 58 4.0 —
10:30 74 4.2 7.50
11:09 113 4.6 6.15
11:35 139 4.9 6.92
12:21 185 5.4 6.52
12:50 214 5.7 6.21
13:43 267 6.0 3.40

Note: The absorption rate typically slows down as the clay reaches structural saturation and balances with ambient evaporation. image

Experiment 2: Determining Structural Saturation and Permeation Delay

Objective: To analyze the material's lateral water permeation speed and determine the time required to reach uniform structural saturation across a defined wall thickness.

Methodology & Setup

  1. Initial Layering: The terracotta pot (featuring a measured wall thickness of 10 mm) is initially filled to exactly 1/4 of its total volume with water.
  2. Pre-Saturation Baseline: The setup is left undisturbed until a sharp moisture gradient (clear visual contrast) is established on the exterior wall of the pre-filled section.
  3. Full Volume Charge: The pot is then filled to 1/1 capacity (completely full).
  4. Permeation Measurement: A timer is started immediately upon filling to measure the precise duration it takes for the moisture line to vanish—specifically, until the visual contrast between the lower 1/4 section and the upper 3/4 section becomes completely indistinguishable.

Empirical Result & Analysis

  • Pot Wall Thickness ($d$): 10 mm
  • Measured Duration ($t$): 18 minutes and 24 seconds (1104 seconds or $0.3067\text{ hours}$)
  • Observation: After 18m 24s, the hydraulic gradient on the exterior wall completely homogenized. The visual boundary between the initial 1/4 hydration zone and the newly filled 3/4 zone became indistinguishable.
Material Characteristic: Horizontal Permeation Velocity

Using the pot's physical parameters, the intrinsic horizontal permeation velocity ($v_h$) of this specific terracotta alloy is calculated as:

$$v_h = \frac{d}{t} = \frac{10\text{ mm}}{0.3067\text{ h}} \approx 32.61\text{ mm/h}$$

This metric defines the baseline physical throughput capability of the Olla barrier when subjected to a sudden hydraulic head gradient.

🚧 Project Status & Roadmap

This project is currently under active development.

  • Concept & Design: Hybrid Olla/Volumetric system with upcycled reservoirs.
  • Hardware Selection: All components finalized (Milbona, Alutec, Electronics).
  • Wiring & Assembly: Building the prototype in the IP65 enclosure.
  • Firmware Development: Implementing flow counting, PWM dosing, and float-switch logic.
  • Calibration: Determining pump flow rates at various PWM speeds.
  • Testing: Validating multi-unit scaling and nutrient ratios.
  • Documentation: Publishing wiring diagrams and code.

🔜 Next Steps

The complete source code (ESPHome YAML configuration) and detailed wiring diagrams will be published in the /config, /stl, and /docs directories.

How to Contribute

We welcome contributions! Whether it's improving the firmware logic, or refining the dosing algorithms, please feel free to open an issue or submit a pull request.


Stay tuned for the upcoming code release and detailed build instructions.

About

Controlling irrigation and fertilization with Olla and ESPHome

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages