Build it step by step
0 of 7 doneRead raw values first
Temporarily print or blink out the raw reading in dry and in watered soil to get your two numbers.
Set DRY_LIMIT
Pick a value between them.
Wire the board
Power from 2 AA to the 5V pin, sensor power on P1, signal on P2, LED on P0.
Upload
Plug the Digispark in when the IDE asks. It has a 5 second bootloader wait at power-up.
Test
Leave the sensor in dry soil. After about a minute the LED blinks twice, and keeps doing it each minute.
Water it
The blinking stops after the next reading.
Measure sleep current
Put a multimeter in series with the battery. It should fall to a few hundred microamps or less once the power LED is removed.
How do you build a sapling watering reminder?
A tiny ATtiny85 board with a soil sensor blinks a red LED when a potted sapling is dry and sleeps most of the time so two AA cells last for months. You need Digispark ATtiny85 USB board, Capacitive Soil Moisture Module, LED 5 mm red, Resistor 330 Ω, Battery holder 2 × AA, AA alkaline battery × 2 and Jumper wires male to male (40 pcs, 20 cm). It takes 7 steps and about 90 minutes.
- Level
- Beginner
- Time
- About 90 min
- Parts
- 7
Parts list
- Development BoardsBuy
- SensorsBuy
- SemiconductorsBuyLED 5 mm red × 1
- PassivesBuyResistor 330 Ω × 1
- PowerBuy
- BatteriesBuy
- PrototypingBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| Battery holder + | Digispark 5V pin (bypasses the on-board regulator) | 3 V from 2 AA cells |
| Battery holder - | Digispark GND | Ground |
| Soil sensor VCC | Digispark P1 | Powered only while reading |
| Soil sensor GND | Digispark GND | Ground |
| Soil sensor AOUT | Digispark P2 (analog input) | Moisture signal |
| Red LED anode | Digispark P0 through 330 Ω | Reminder |
| Red LED cathode | Digispark GND | Return |
Code
Arduino IDE with the ATTinyCore or Digistump AVR board package, board "Digispark (Default - 16.5mhz)". Upload with the board's USB when asked. The sensor is read with the ADC reference at the supply, so with 3 V the readings differ from those at 5 V, so read your own values for dry and wet soil and set DRY_LIMIT between them. A Digispark's power LED and regulator waste current, so remove the LED for real months of battery life, and measure the sleep current with a multimeter.
Runs on a virtual Digispark ATtiny85 in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
#include <avr/sleep.h>
#include <avr/wdt.h>
#include <avr/interrupt.h>
const byte LED = 0, SENSOR_POWER = 1, SENSOR_IN = A1; // P0, P1, P2 on the Digispark
const int DRY_LIMIT = 600; // set from your own readings: higher means drier
const byte WAKES_PER_READING = 7; // about one reading a minute with 8 s sleeps
volatile byte wakes = 0;
ISR(WDT_vect) { wakes++; }
void sleep8s() {
MCUSR &= ~_BV(WDRF);
WDTCR = _BV(WDCE) | _BV(WDE);
WDTCR = _BV(WDIE) | _BV(WDP3) | _BV(WDP0); // 8 second interrupt, no reset
ADCSRA &= ~_BV(ADEN); // turn the ADC off to save power
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable();
sleep_cpu();
sleep_disable();
ADCSRA |= _BV(ADEN);
}
void setup() {
pinMode(LED, OUTPUT);
pinMode(SENSOR_POWER, OUTPUT);
}
void loop() {
sleep8s();
if (wakes >= WAKES_PER_READING) {
wakes = 0;
digitalWrite(SENSOR_POWER, HIGH);
delay(100); // let the sensor settle
int v = analogRead(SENSOR_IN);
digitalWrite(SENSOR_POWER, LOW);
if (v > DRY_LIMIT) { // dry: two short blinks
for (byte i = 0; i < 2; i++) { digitalWrite(LED, HIGH); delay(80); digitalWrite(LED, LOW); delay(150); }
}
}
}Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Dry soil | Two blinks about once a minute |
| Watered | No blinks |
| Sleep current | Under 0.5 mA after removing the power LED |
| Battery life | Months, from the sleep current and the cell capacity |
If it does not work
LED never blinks
DRY_LIMIT is too high or too low for your 3 V readings. Check the numbers.
Sensor corrodes
It must be powered only while reading, as in the code.
Board resets constantly
The supply is too low. Use fresh cells.
Cannot upload
Replug the board after clicking upload. The bootloader waits only a few seconds.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the sapling watering reminder?
Digispark ATtiny85 USB board, Capacitive Soil Moisture Module, LED 5 mm red, Resistor 330 Ω, Battery holder 2 × AA, AA alkaline battery × 2 and Jumper wires male to male (40 pcs, 20 cm).
How long does the sapling watering reminder take to build?
About 90 minutes for a beginner maker, in 7 steps.
How do I know the sapling watering reminder works?
Dry soil: Two blinks about once a minute. Watered: No blinks. Sleep current: Under 0.5 mA after removing the power LED.
LED never blinks: what should I check?
DRY_LIMIT is too high or too low for your 3 V readings. Check the numbers.
Sensor corrodes: what should I check?
It must be powered only while reading, as in the code.
Board resets constantly: what should I check?
The supply is too low. Use fresh cells.
Cannot upload: what should I check?
Replug the board after clicking upload. The bootloader waits only a few seconds.
