Plant watering helperTinkerPieCircuit tutorial 24 of 24 · Intermediate · 20 minutes
Use a soil moisture sensor to tell you when a plant is thirsty.
Open this circuit in TinkerPieCircuit (free, runs in your browser)
What you will learn
- Reading a soil moisture sensor
- Why wetter soil gives a lower number
- Choosing a threshold
Parts
Steps
Wire the sensor
VCC →
3V3, GND →GND, AOUT →P11.Wire the lights
S1→ red LED,S2→ green LED. Join both LED (−) legs to one 220 Ω resistor, then toGND.Pick a threshold
Dry soil gives a high number. If the reading is above 2800, the plant is thirsty.
Test
Press ▶ Start and drag the sensor slider. Low wetness lights red, high wetness lights green.
The code
function setup() {
pinMode(S1, OUTPUT);
pinMode(S2, OUTPUT);
}
function loop() {
const reading = analogRead(P11);
Serial.println("soil reading = " + reading);
if (reading > 2800) {
digitalWrite(S1, HIGH);
digitalWrite(S2, LOW);
} else {
digitalWrite(S1, LOW);
digitalWrite(S2, HIGH);
}
delay(200);
}
Copy this into the Code tab. It is Arduino-style JavaScript. The real board uses the same pin names (S1, P10…) in TinkerPie Studio.
How it works
Water between the two probes changes how well the soil conducts, which changes the sensor voltage. Choosing a threshold turns a number into a yes or no decision.
Challenge: Add a buzzer that beeps once when the soil first becomes dry.