Greenhouse Controller Sketch Pack for Arduino Uno — Irrigation, Fan and Vent Timing

Four ready-to-flash sketches that run a small greenhouse on one Uno: a replacement commercial controller starts around 180 USD and still needs its own sensors.

Board

arduino:avr:uno

Parts you need (8)

Sketches in this pack (4)

SoilMoistureIrrigation

Water only when the probe reads dry, with a hard daily cap so a stuck probe cannot flood the bed.

Reads a resistive or capacitive probe on A0 and drives a relay on D7. The daily cap is the safety device most tutorials leave out.

Wiring

PinModeConnect to
A0INPUTSoil moisture probe signal
7OUTPUTRelay IN for the pump

Connect in this order

  1. Soil moisture probe signal → A0
  2. Relay IN for the pump → 7

Values you can change

NameValueUnit
DRY_THRESHOLD620raw ADC
PUMP_SECONDS20s
MAX_RUNS_PER_DAY6runs
ThermistorFanControl

Ramp a 12 V fan with PWM from a 10k NTC thermistor instead of switching it fully on and off.

Uses the Steinhart-Hart approximation on a voltage divider at A1 and writes PWM to D9. Hysteresis keeps the fan from chattering at the setpoint.

Wiring

PinModeConnect to
A1INPUT10k NTC divider midpoint
9OUTPUTMOSFET gate for the fan

Connect in this order

  1. 10k NTC divider midpoint → A1
  2. MOSFET gate for the fan → 9

Values you can change

NameValueUnit
TARGET_C26C
FULL_SPEED_C33C
VentWindowTimer

Open and close a linear actuator on a daily schedule using millis, with an end-stop timeout so the motor never stalls.

Drives an H-bridge on D4 and D5. The timeout is what protects a cheap actuator when a limit switch fails.

Wiring

PinModeConnect to
4OUTPUTH-bridge IN1 (open)
5OUTPUTH-bridge IN2 (close)

Connect in this order

  1. H-bridge IN1 (open) → 4
  2. H-bridge IN2 (close) → 5

Values you can change

NameValueUnit
OPEN_AFTER_MIN480min from power-on
TRAVEL_SECONDS18s
LowWaterAlarm

Latch an alarm when the tank float opens, so a night-time dry run is still visible in the morning.

Float switch on D2 with INPUT_PULLUP and a buzzer on D8. The latch is the point: a momentary alarm you slept through tells you nothing.

Wiring

PinModeConnect to
2INPUT_PULLUPTank float switch
8OUTPUTBuzzer or lamp

Connect in this order

  1. Tank float switch → 2
  2. Buzzer or lamp → 8

Values you can change

NameValueUnit
DEBOUNCE_MS400ms