Raspberry Pi practice problem · Projects
Smart irrigation
HardBudget $30Python · gpiozero
Water a plant without drowning it: a capacitive soil sensor (3.3 V) with AOUT on input A0 of an ADS1115 (I²C, ADDR to ground → 0x48), a pump behind a high-trigger relay on GPIO26, and a red tank empty LED on GPIO17.
The soil is dry while the sensor reads above 2.0 V (wetter soil gives a lower voltage).
- While the soil is moist, check it every 0.5 s.
- When it is dry, water in pulses: pump on for 1 s, then wait 2 s for the water to soak in, then check again.
- If the soil is still dry after 3 pulses in a row, the tank must be empty: stop watering, light the LED and print
Tank emptyonce. Stay like that until the soil reads moist again (then turn the LED off and go back to normal).
The test soil is dry (20 %), moist (70 %) at 5 s, dry (20 %) again at 7 s, and stays dry.