Lessons and the learning game

Build a greenhouse controller

A greenhouse controller on an Uno: climate and vapor pressure deficit, fans with hysteresis, safe watering, a grow light, a schedule and a season log.

The controller

Every lesson opens on the same wiring:

  • The air: an SHT31 at 0x44 for temperature and humidity.
  • The time: a DS3231 on the same I2C bus.
  • The soil: a capacitive soil moisture probe on A0, 2.55 V in air and 1.27 V in water.
  • The fan: an L9110 fan module, speed by PWM on pin 5.
  • The relays: a four-channel relay board, active low. Relay 1 runs a pump and relay 2 a 6 V lamp standing in for the grow light, both from a 6 V pack.

How it works

VPD. Warm air holds more water than cold. The vapor pressure deficit, the saturation pressure times (1 - RH), is how hard the air pulls water from a leaf: under 0.4 kPa is mold weather, 0.4 to 0.8 suits seedlings, 0.8 to 1.2 leafy growth, 1.2 to 1.6 flowering, and over that plants close up.

The fan. On at 28 C, off only under 26 C, from 40 percent up to full at 32 C, and 60 percent for air over 85 percent humidity.

Watering. Start under 35 percent, stop at 50, never more than 10 seconds, then a 20 second soak. A full run that does not wet the soil locks the pump out. The relay pin is written HIGH before it becomes an output, so an active-low board never kicks at reset.

Lights. On from 06:00 to 22:00, set from the clock every pass rather than by events, so a power cut cannot leave it wrong.

Schedules. Watering only in windows at 07:00 and 19:00, from a table, with the next event worked out from the clock.

The season log. An hourly line of every reading, and at midnight a summary: the lowest and highest temperature, the waterings, and the hours of light.

The course

Build a greenhouse controller gets there in six lessons, each a sketch on the same wiring:

  1. Climate sensing: temperature, humidity and VPD.
  2. Fans and vents: hysteresis and speed.
  3. Watering: a relay, a pump and its limits.
  4. Lights: a photoperiod from the clock.
  5. Schedules: watering windows from a table.
  6. Project: a season log: the whole house, logged.

Every step but the last is checked against the running circuit.