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 GPIO25 closes a pair of heavy contacts that carry the pump's much larger current. The ESP32 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.
The ESP32 is a 3.3V board: never connect a 5V signal straight to a GPIO pin.
Keep water away from the ESP32 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 Titan Kit box, a Geekobot exclusive, together with the parts for all 120 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.
ESP32 DevKit V1 (38-pin): the brain of every Titan Kit project, with Wi-Fi and Bluetooth
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 changes as the soil gets wetter
L298N board: its on-board regulator turns the 7.4V pack into 5V for the motor
ESP32 expansion board from the kit: every GPIO has its own S, V, G header
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, fed by the 2 x 18650 pack. The relay switches that 5V; the ESP32 only drives the relay.
titan_kit_022_automatic_plant_watering.inoVerify & upload in Electrolark#include <Wire.h>
#include <LiquidCrystal_I2C.h>
int soilPin = 34;
int relayPin = 25;
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()
{
analogReadResolution(10); // ESP32 is 12-bit; use 0-1023 like the examples
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 a micro-USB data cable (some cables only charge), install the CP210x or CH340 driver if no port appears, pick Tools > Board > ESP32 Dev Module and hold the BOOT button on the board until the upload starts.
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 GPIO.
The relay is an electrically operated switch: a tiny current from GPIO25 closes a pair of heavy contacts that carry the pump's much larger current. The ESP32 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 120 in the Geekobot Titan 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 Titan Kit project is wired on the ESP32 expansion board and the breadboard with jumper wires.
11 parts: ESP32-WROOM-32 38-Pin Development Board, 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, ESP32 38-Pin Expansion Board, 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 8 steps.
No. This page has the complete, tested code (titan_kit_022_automatic_plant_watering.ino).
About ₹1,533 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.
The ESP32 is a 3.3V board: never connect a 5V signal straight to a GPIO pin. Keep water away from the ESP32 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.