Three pot moisture lights
Three capacitive soil probes show which of three plant pots is dry using a green and red LED for each.
Build it step by step
0 of 8 doneWire the probes
5V, GND and one output each to A0, A1, A2.
Wire the LEDs
Green and red per pot on D2 to D7 through 330 ohm.
Upload the sketch
Three raw numbers print every second.
Calibrate dry
Hold each probe in the air and note the number.
Calibrate wet
Dip each probe to the line in water and note it.
Update the sketch
Put the numbers in DRY and WET.
Place the probes
In the soil up to the line only.
Water one pot
Its LEDs change from red towards green.
How do you build a three pot moisture lights?
Three capacitive soil probes show which of three plant pots is dry using a green and red LED for each. You need Arduino Nano, Capacitive Soil Moisture Module × 3, LED 5 mm red × 3, LED 5 mm green × 3, Resistor 330 Ω × 6 and Breadboard 830 Tie Points. It takes 8 steps and about 75 minutes.
- Level
- Beginner
- Time
- About 75 min
- Parts
- 6
Parts list
- Development BoardsBuyArduino Nano × 1
- SensorsBuy
- SemiconductorsBuyLED 5 mm red × 3
- SemiconductorsBuyLED 5 mm green × 3
- PassivesBuyResistor 330 Ω × 6
- PrototypingBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| Each probe VCC | Nano 5V | Check your module accepts 5 V |
| Each probe GND | Nano GND | Common ground |
| Probe 1 output | Nano A0 | Pot 1 |
| Probe 2 output | Nano A1 | Pot 2 |
| Probe 3 output | Nano A2 | Pot 3 |
| Pot 1 green LED through 330 ohm | Nano D2 to GND | Moist enough |
| Pot 1 red LED through 330 ohm | Nano D3 to GND | Dry |
| Pot 2 green and red LEDs | Nano D4 and D5 | Same, each through 330 ohm |
| Pot 3 green and red LEDs | Nano D6 and D7 | Same, each through 330 ohm |
Code
A capacitive soil probe measures the moisture around it by a change in capacitance, so there is no bare metal in the soil to corrode, unlike the cheap resistive type. On most modules the reading goes down as the soil gets wetter. Every probe is a little different, so each needs its own calibration: read the raw number in dry air and in a glass of water, put those values in the sketch and the code turns every reading into a percentage. Each pot has two LEDs. A green LED alone means the soil is moist, both together mean it is getting dry and needs water soon, and a red LED alone means it is dry. The three probes share one sketch and read in turn. Push the probe into the soil only up to the line marked on the board, because the electronics above it are not waterproof. A coat of clear nail varnish on the exposed edge slows the water creeping in. Different plants like different moisture levels, so treat the thresholds as a starting point and adjust them.
Runs on a virtual Arduino Nano 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).
const int PROBE[3] = {A0, A1, A2};
const int GREEN[3] = {2, 4, 6};
const int RED[3] = {3, 5, 7};
// Raw readings in dry air and in a glass of water, one pair per probe.
// Read them from the serial monitor and replace these numbers.
int DRY[3] = {560, 560, 560};
int WET[3] = {270, 270, 270};
int percent(int i) {
long sum = 0;
for (int k = 0; k < 16; k++) { sum += analogRead(PROBE[i]); delay(2); }
int raw = sum / 16;
int p = map(raw, DRY[i], WET[i], 0, 100); // wet gives a lower reading on these modules
Serial.print(raw); Serial.print(i < 2 ? "," : "\n");
return constrain(p, 0, 100);
}
void setup() {
Serial.begin(9600);
for (int i = 0; i < 3; i++) { pinMode(GREEN[i], OUTPUT); pinMode(RED[i], OUTPUT); }
}
void loop() {
for (int i = 0; i < 3; i++) {
int p = percent(i);
// Above 60 percent: green. 30 to 60: both, meaning water soon. Below 30: red.
digitalWrite(GREEN[i], p >= 30);
digitalWrite(RED[i], p < 60);
}
delay(1000);
}What the serial monitor should show
Open the serial monitor at the baud rate in the code. This is what our simulator prints for a virtual Arduino Nano with its sensors at their default values. Your numbers will follow your real readings, but the format should match.
511,511,512 512,511,511 511,511,512 511,512,512 511,512,511 511,511,512
Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Probe in the air | Red on |
| Probe in water | Green on |
| Damp soil | Both LEDs on |
| Water a dry pot | Moves from red through both to green |
| Probe unplugged | Reads a steady odd value |
If it does not work
All the same reading
Check the output wires on A0, A1, A2.
Reading never changes
Check the power and ground wires.
LEDs the wrong way round
Swap DRY and WET or check the module type.
Numbers jump
Keep the wires short and away from the LEDs.
Probe stops working
Water got into the electronics, keep it above the line.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the three pot moisture lights?
Arduino Nano, Capacitive Soil Moisture Module × 3, LED 5 mm red × 3, LED 5 mm green × 3, Resistor 330 Ω × 6 and Breadboard 830 Tie Points.
How long does the three pot moisture lights take to build?
About 75 minutes for a beginner maker, in 8 steps.
How do I know the three pot moisture lights works?
Probe in the air: Red on. Probe in water: Green on. Damp soil: Both LEDs on.
All the same reading: what should I check?
Check the output wires on A0, A1, A2.
Reading never changes: what should I check?
Check the power and ground wires.
LEDs the wrong way round: what should I check?
Swap DRY and WET or check the module type.
Numbers jump: what should I check?
Keep the wires short and away from the LEDs.
