Vermicompost bin moisture keeper
Build it step by step
0 of 7 doneCalibrate
Print the raw reading in dry bedding and in damp bedding and choose DRY_RAW between them.
Wire the pump
Pump through the relay's COM and NO from the AA pack, with the flyback diode.
Wire the electronics
Sensor on A0, relay on D7, LED on D13.
Test the spray
Temporarily lower DRY_RAW so it triggers, and check the pump runs for 2 seconds.
Fit the nozzle
Run the tube to a drip nozzle above the bedding, with the reservoir below or beside the bin.
Set it up
Return DRY_RAW and put the sensor in the middle of the bedding.
Watch for a day
Check moisture and that the bedding is damp, not soaked.
How do you build a vermicompost bin moisture keeper?
A soil sensor in a worm bin sprays a little water when the bedding gets too dry, keeping worms healthy in summer. You need Arduino Nano, Capacitive Soil Moisture Module, Relay Module 5V, Mini submersible water pump (3 to 6 V), Rectifier Diode 1N4007, LED 5 mm red, Resistor 220 Ω, Battery holder 4 × AA with switch, AA alkaline battery × 4 and Jumper wires male to male (40 pcs, 20 cm). It takes 7 steps and about 60 minutes.
- Level
- Beginner
- Time
- About 60 min
- Parts
- 10
Parts list
- Development BoardsBuyArduino Nano × 1
- SensorsBuy
- InterfacesBuyRelay Module 5V × 1
- Motors & ActuatorsBuy
- SemiconductorsBuy
- SemiconductorsBuyLED 5 mm red × 1
- PassivesBuyResistor 220 Ω × 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 |
|---|---|---|
| Soil sensor VCC, GND, AOUT | Nano 5V, GND, A0 | Moisture reading |
| Relay module VCC and GND | Nano 5V and GND | Supply |
| Relay module IN | Nano D7 | Pump control |
| Pump + | AA pack + through the relay COM and NO | Switched 6 V |
| Pump - | AA pack - | Return |
| 1N4007 across the pump | Cathode on pump +, anode on pump - | Flyback diode |
| Status LED anode | Nano D13 through 220 Ω | Lit while spraying |
| AA pack | Nano VIN and GND | Power for everything |
Code
Arduino IDE, board "Arduino Nano" (processor ATmega328P, or ATmega328P (Old Bootloader) for clones). No libraries. Calibrate the sensor by reading it in dry bedding and in damp bedding with the serial monitor, then set DRY_RAW between those values. Use a drip nozzle so the water spreads over a large area, and keep the water reservoir small so a fault cannot flood the bin. If your relay is active-high, swap the HIGH and LOW writes.
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 byte SOIL = A0, RELAY = 7, LED = 13;
const int DRY_RAW = 520; // capacitive sensors read higher when drier: set from your own tests
const unsigned long SPRAY_MS = 2000; // 2 seconds of water
const unsigned long WAIT_MS = 30UL * 60UL * 1000UL; // wait 30 minutes before checking again
unsigned long lastSpray = 0;
void setup() {
pinMode(RELAY, OUTPUT); digitalWrite(RELAY, HIGH); // most relay modules are active low
pinMode(LED, OUTPUT);
}
void loop() {
long sum = 0;
for (byte i = 0; i < 16; i++) { sum += analogRead(SOIL); delay(10); }
int raw = sum / 16;
if (raw > DRY_RAW && (lastSpray == 0 || millis() - lastSpray > WAIT_MS)) {
digitalWrite(LED, HIGH);
digitalWrite(RELAY, LOW); // pump on
delay(SPRAY_MS);
digitalWrite(RELAY, HIGH); // pump off
digitalWrite(LED, LOW);
lastSpray = millis();
}
delay(1000);
}Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Dry bedding | Pump runs for 2 seconds |
| Damp bedding | Pump stays off |
| After a spray | No more spraying for 30 minutes |
| Sensor lifted out | Reads dry and sprays once only |
If it does not work
Pump never runs
Check the relay wiring and that it clicks when you lower DRY_RAW.
Pump runs but no water
Tube kinked or the pump is dry. Prime it.
Over-watering
Increase the wait or shorten the spray.
Sensor reads strangely
The board's coating must be intact and only the probe tip in the bedding.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the vermicompost bin moisture keeper?
Arduino Nano, Capacitive Soil Moisture Module, Relay Module 5V, Mini submersible water pump (3 to 6 V), Rectifier Diode 1N4007, LED 5 mm red, Resistor 220 Ω, Battery holder 4 × AA with switch, AA alkaline battery × 4 and Jumper wires male to male (40 pcs, 20 cm).
How long does the vermicompost bin moisture keeper take to build?
About 60 minutes for a beginner maker, in 7 steps.
How do I know the vermicompost bin moisture keeper works?
Dry bedding: Pump runs for 2 seconds. Damp bedding: Pump stays off. After a spray: No more spraying for 30 minutes.
Pump never runs: what should I check?
Check the relay wiring and that it clicks when you lower DRY_RAW.
Pump runs but no water: what should I check?
Tube kinked or the pump is dry. Prime it.
Over-watering: what should I check?
Increase the wait or shorten the spray.
Sensor reads strangely: what should I check?
The board's coating must be intact and only the probe tip in the bedding.
