Arduino Greenhouse Sketch — Greenhouse Controller Sketch

How it works
  1. Read below what is included.
  2. Open the parts you need directly on this page.
  3. A question? Use the question box at the bottom of the page.

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

Get the full version

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.

This page is the free working part. The full version is sent to your inbox.

A packaged greenhouse controller with the same four functions sells for 180-320 USD, sensors excluded.

Send it to me

Need more than this one? ReadyStack Pass opens all 679 files and 561 full versions — $29/month or $199/year. See the Pass →

ENDEJAESPT

Find a tool

Email me this result
A copy of what you see above, in your inbox — the tool stays free, nothing here is locked.

Questions and answers

What does this page do?

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

Is it free?

The preview on this page is free.

How do I use it?

1. Read below what is included. 2. Open the parts you need directly on this page. 3. A question? Use the question box at the bottom of the page.

Ask about this tool

One question, answered by the person who built it. Your email only if you want the answer sent.

Privacy: your e-mail is used only to send you the answer. A question appears on this page only after it is answered, without your e-mail.

For a team or company: for an invoice with your company details, a quote or several licences, write to [email protected].

More in Developer tools See all →