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.
arduino:avr:uno
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.
| Pin | Mode | Connect to |
|---|---|---|
A0 | INPUT | Soil moisture probe signal |
7 | OUTPUT | Relay IN for the pump |
| Name | Value | Unit |
|---|---|---|
DRY_THRESHOLD | 620 | raw ADC |
PUMP_SECONDS | 20 | s |
MAX_RUNS_PER_DAY | 6 | runs |
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.
| Pin | Mode | Connect to |
|---|---|---|
A1 | INPUT | 10k NTC divider midpoint |
9 | OUTPUT | MOSFET gate for the fan |
| Name | Value | Unit |
|---|---|---|
TARGET_C | 26 | C |
FULL_SPEED_C | 33 | C |
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.
| Pin | Mode | Connect to |
|---|---|---|
4 | OUTPUT | H-bridge IN1 (open) |
5 | OUTPUT | H-bridge IN2 (close) |
| Name | Value | Unit |
|---|---|---|
OPEN_AFTER_MIN | 480 | min from power-on |
TRAVEL_SECONDS | 18 | s |
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.
| Pin | Mode | Connect to |
|---|---|---|
2 | INPUT_PULLUP | Tank float switch |
8 | OUTPUT | Buzzer or lamp |
| Name | Value | Unit |
|---|---|---|
DEBOUNCE_MS | 400 | ms |