Maker's Fun Duck's Resistive Soil Moisture Sensor Puts an ATtiny13 to Sleep for Longer Life
This CNC-milled PCB acts as a resistive moisture sensor, using tinned electrodes and deep sleep to stave off corrosion.
Pseudonymous maker "Maker's Fun Duck," hereafter simply "Duck," has designed a soil moisture sensor for pot plants which uses the deep sleep mode of a Microchip ATtiny13 microcontroller to boost battery life.
"Moisture-Duck helps you keep track of your plants' soil moisture and alerts you if they need watering," Duck explains. "It utilizes the resistance measurement technique to gauge soil moisture levels. Two probes, in combination with the substrate, constitute a variable resistor.
"Greater soil moisture translates to improved conductivity and decreased electrical resistance. With the addition of a 12k [Ohm] fixed resistor, the system creates a voltage divider. The microcontroller's ADC [Analog to Digital Converter] measures this voltage. The design is inspired by the SparkFun Soil Moisture Sensor."
The resistive sensor wasn't Duck's first shot at keeping their plants alive, though. In a video supporting the project Duck goes through several different approaches for monitoring soil moisture levels — from gravimetric and neutron probes to time-domain transmissometry — before settling on using the simpler capacitive or resistive methods, building prototypes of each with a TI MSP430 and a Microchip ATtiny13 respectively.
It's the resistive version that proved the winner, though, programmed to make noise and light when a poor pot plant is in need of attention. "The device is based on ATtiny13, which spends most of its time in sleep mode and wakes up every eight seconds to take measurements," Duck explains, using the microcontroller's sleep function to prolong battery life. "It can also be activated by pressing the TEST button, and the correct threshold value can be set by turning the potentiometer."
The problem with resistive soil moisture sensors, though, is corrosion. "For continuous measurement, it only takes a few hours [to corrode]," Duck admits. "I have tinned the electrodes, and it takes around three times [longer] to corrode. I only measure [for] a few µsec. Then it goes to deep sleep and [is] woken up by the watchdog timer. Battery lasts a few months. So if I tin the electrodes once in every year or so, it should be fine."
The hardware files and software source code for the sensor are available on GitHub under the reciprocal GNU General Public License 3. Additional information is available in Duck's Reddit post.
Freelance journalist, technical author, hacker, tinkerer, erstwhile sysadmin. For hire: freelance@halfacree.co.uk.