Automatic dusk-to-dawn light
Lights switch on by themselves at dusk and off again in the morning.
Shop by category
Shop all componentsCombine the soil sensor with a relay and a pump so the plant waters itself whenever the soil dries out. The relay is an electrically operated switch: a tiny current from D7 closes a pair of heavy contacts that carry the pump's much larger current. The Arduino and the pump therefore share no power at all, only a common ground reference. Most relay modules are active-LOW, meaning digitalWrite(relay, LOW) is what turns the pump on. Two thresholds are used rather than one: watering starts below 30% and stops above 60%, so the pump does not chatter on and off around a single boundary.
Keep water away from the Nano and test the pump and tube over a tray first.
Charge 18650 cells only in a proper Li-ion charger and never short the holder's wires.
Every part for this build comes in the Geekobot Explorer Kit box, a Geekobot exclusive, together with the parts for all 61 projects, from a first blinking LED to a smart fan and a reaction game. The wiring below is the kit's own wiring.
Tick anything you already have and the total updates.
The brain of every Explorer Kit project
Male-to-female and female-to-female leads for the modules
16x2 LCD with I2C backpack: four wires, two lines of text
Soil moisture sensor: the reading falls as the soil gets wetter
L298N board: here only its 5V regulator is used, to feed the pump
Nano I/O shield from the kit: every pin has its own S, V, G header, so modules plug in with jumpers
Follow the colours: red is power, dark grey is ground, blue is a signal.
The pump runs at 5V from the L298N's on-board regulator, which is fed by the 2 x 18650 pack. The relay switches that 5V; the Nano only drives the relay.
explorer_kit_22_plant_watering.inoVerify & upload in Electrolark#include <Wire.h>
#include <LiquidCrystal_I2C.h>
int soilPin = A0;
int relayPin = 7;
int dryLevel = 30; // Start watering below this
int wetLevel = 60; // Stop watering above this
bool pumpOn = false;
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup()
{
pinMode(relayPin, OUTPUT);
digitalWrite(relayPin, HIGH); // Relay is active LOW - pump OFF
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Auto Watering");
delay(2000);
lcd.clear();
}
void loop()
{
int raw = analogRead(soilPin);
int moisture = map(raw, 1023, 300, 0, 100);
moisture = constrain(moisture, 0, 100);
if (moisture < dryLevel)
{
pumpOn = true;
}
if (moisture > wetLevel)
{
pumpOn = false;
}
if (pumpOn)
{
digitalWrite(relayPin, LOW); // Pump ON
}
else
{
digitalWrite(relayPin, HIGH); // Pump OFF
}
lcd.setCursor(0, 0);
lcd.print("Moisture: ");
lcd.print(moisture);
lcd.print("% ");
lcd.setCursor(0, 1);
if (pumpOn)
{
lcd.print("Pump: WATERING ");
}
else
{
lcd.print("Pump: IDLE ");
}
delay(1000);
}
Use the kit's mini-USB cable, install the CH340 driver on Windows if no port appears, pick Tools > Board > Arduino Nano and try Tools > Processor > ATmega328P (Old Bootloader) if the upload times out.
Turn the small contrast pot on the back of the I2C board. If still blank, change 0x27 in the sketch to 0x3F.
Note the reading in dry air and in a glass of water, then put those two numbers into the map() line of the sketch.
These relay modules are active LOW: writing LOW switches them on. The sketch already does this, so check IN goes to the right pin.
The relay is an electrically operated switch: a tiny current from D7 closes a pair of heavy contacts that carry the pump's much larger current. The Arduino and the pump therefore share no power at all, only a common ground reference. Most relay modules are active-LOW, meaning digitalWrite(relay, LOW) is what turns the pump on. Two thresholds are used rather than one: watering starts below 30% and stops above 60%, so the pump does not chatter on and off around a single boundary.
Damp soil: Moisture: 65% / Pump: IDLE. Soil dries below 30%: the relay clicks and Pump: WATERING appears. Once moisture passes 60% the relay clicks off again.
Yes. It is project 22 of 61 in the Geekobot Explorer Kit, in level 5 (Smart automation). Every part on the list comes in the kit box, and you can also buy the parts one by one from the list above.
No. Every Explorer Kit project is wired on the Nano I/O shield and the breadboard with jumper wires.
11 parts: Generic Nano CH340 Development Board (Soldered), USB Cable, Dupont Jumper Wires (40 pcs), LCD1602 16x2 Character LCD Display, Capacitive Soil Moisture Sensor – 3.3V/5V Analog Output, PH2.54-3P Interface, 5V Relay Module with Optocoupler, Mini Submersible Water Pump 3–6V, L298N Dual H-Bridge Motor Driver Module, Arduino Nano IO Expansion Shield (328P Compatible), 18650 Battery Holder, plus 1 more. On this page you can tick the parts you already have and add only the rest to your cart.
It is a intermediate project and takes about 1 hour. The build on this page has 7 steps.
No. This page has the complete, tested code (explorer_kit_22_plant_watering.ino).
About ₹1,284 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Relay control and threshold logic; Hysteresis, two thresholds instead of one; Powering a load from a separate supply; Why a common ground is essential.
Keep water away from the Nano and test the pump and tube over a tray first. Charge 18650 cells only in a proper Li-ion charger and never short the holder's wires.
Lights switch on by themselves at dusk and off again in the morning.
A precise thermostat that keeps tropical fish at a steady 25–26 °C.
Starts the pump when the tank runs low and stops it when it is full.
Tap a hidden pad to switch a lamp on or off, even through a wooden desk.
Lessons are free to read. Maker (₹499/month) and Pro add quizzes, worked problems and certificates, paid with your Geekobot account. See plans
Learning project. Check every circuit and the datasheet of each part before you power it up.