Premium

Automatic Plant Watering

A stuck sensor does not mean "unsure" — it settles at one extreme and stays there. This sketch is built to survive that.

  • Arduino
  • C++
  • Sensors

About this project

A soil moisture sensor decides whether a plant needs water, a relay or transistor drives a small pump, and the board's own LED shows what state the system is in — idle, watering, or resting.

The naive version of this project is three lines: read the sensor, and if it says dry, turn the pump on. That says nothing about what happens if the sensor is lying — and a cheap resistive soil probe lies in exactly one direction that matters. Continuous exposure to wet soil corrodes its bare metal prongs, a well-documented failure of this sensor type, and a corroded probe does not report "unsure." It settles at one electrical extreme and stays there — which, on this project's default wiring, reads as "bone dry," forever, whether or not the soil is actually drowning. Feed that into the naive loop and the pump simply never turns off. This project exists to stop that: a hard per-cycle ceiling on watering time, and an independent cooldown that ignores the sensor entirely afterward — two safeguards, both required, and the README traces through exactly why one alone still floods the pot.

What you will learn

  • Design a sensor fault to fail safe, not fail wet, and prove the difference with real numbers
  • Understand why one safeguard alone can re-arm itself on the same bad input and stop meaning anything
  • Combine a hard ceiling with an independent cooldown so the two together are actually bounded
  • Smooth a noisy analog reading with a rolling average instead of trusting a single sample
  • Schedule two independent millis() timers on every loop pass with no delay() anywhere

Before you start

  • Arduino basics — setup, loop, and reading a pin
  • The Arduino IDE, or Priodemy Labs if you have no board
  • Optional hardware: an UNO, a soil moisture sensor, and a relay or transistor to drive a pump

New to Arduino? The free Arduino course covers everything this project assumes.

Academic integrity notice

These projects are provided for learning, experimentation and reference. Understand the code, modify it for your own requirements, and acknowledge external work according to your institution’s academic policies. Priodemy does not supply work to be submitted as your own.