Introduction
Automatic Plant Watering System: Maintaining a healthy garden or farm can be time-consuming, especially with a busy schedule. Plants need consistent and timely watering, but what if you could automate the process while also saving on electricity costs and ensuring that watering happens at the right time of day? A solar-powered automatic plant watering system with light detection is the perfect solution. It ensures your plants get the right amount of water, preferably during the evening or low-light conditions, making the process more efficient and plant-friendly.
In this article, you’ll learn:
- What a solar-powered automatic plant watering system with light detection is
- How it works
- The benefits of using solar energy and light-based control
- The step-by-step process to build one yourself
- Key components required
- FAQs and tips for efficient performance
What is a Solar-Powered Automatic Plant Watering System with Light Detection?
A solar-powered automatic plant watering system with light detection is an irrigation setup that uses solar energy to power a water pump, which supplies water to plants based on both soil moisture and light intensity. The system uses a light-dependent resistor (LDR) to detect daylight and ensures that watering only occurs in the evening or low-light conditions, which helps prevent water evaporation and promotes better soil absorption.
Key Features:
- Automatic watering: Ensures plants receive the right amount of water at the right time.
- Solar-powered: Uses renewable energy, making it cost-effective and eco-friendly.
- Smart monitoring: Uses soil moisture and light sensors for precise watering.
- Remote control: With IoT integration, you can control and monitor the system from your smartphone.
Why Add Light Detection to the System?
Watering at the Right Time:
- Watering plants during the evening or low-light conditions minimizes water evaporation.
- Plants absorb water more efficiently when temperatures are lower.
Energy and Water Efficiency:
- Prevents unnecessary daytime watering.
- Conserves water by irrigating only when needed.
Improved Plant Health:
- Watering during cooler times reduces plant stress.
- Prevents sunburn caused by water droplets acting as magnifying lenses.
Components Required for a DIY Solar-Powered Automatic Plant Watering System with Light Detection
To build this DIY solar-powered automatic irrigation system, you’ll need the following components:
1. Solar Panel
- Rating: 10W–30W solar panel (based on the pump’s power requirement)
- Purpose: Converts sunlight into electrical energy.
2. Rechargeable Battery
- Rating: 12V 7Ah or higher
- Purpose: Stores solar energy to run the system during cloudy weather or nighttime.
3. Water Pump
- Type: DC submersible or diaphragm pump
- Flow rate: 1-3 liters per minute (LPM), based on plant requirements
4. Soil Moisture Sensor
- Function: Detects soil moisture level and triggers the pump when needed.
- Type: Capacitive or resistive moisture sensor
5. Microcontroller (NodeMCU or Arduino)
- Purpose: Controls the system operation and automates the process.
- Connectivity: IoT-enabled with Wi-Fi (optional)

6. Light-Dependent Resistor (LDR)
- Purpose: Detects light intensity.
- Function: Ensures the system only waters plants in low-light conditions.
7. Motor Driver
- Type: L298N or relay module or Transistor
- Purpose: Controls the water pump operation based on the microcontroller signal.
8. Water Pipes and Drippers
- Purpose: Delivers water to the plants efficiently.
9. Blynk Application (Optional for IoT Control)
- Purpose: Controls the system from your smartphone via Wi-Fi.
How to Build a Solar-Powered Automatic Plant Watering System with Light Detection
A simple explanation of how to connect the hardware components to your NodeMCU (ESP8266) based on the code you’re using is illustrated in the table and figures given below.
Summary of Components and Their Pins in Code:
Component | NodeMCU Pin in Code | Type of Signal | Description |
---|---|---|---|
Soil Moisture Sensor | A0 | Analog | Reads moisture level |
LDR (Light Sensor) | D6 (GPIO12) | Digital | Detects light/dark |
Water Pump (via Relay or Transistor) | D5 (GPIO14) | Digital Output | Turns pump ON/OFF |
1. Soil Moisture Sensor Connection:
Typical moisture sensor has 3 pins:
- VCC → Connect to 3.3V (or 5V depending on your module)
- GND → Connect to GND
- AOUT (Analog Output) → Connect to A0 of NodeMCU
This reads soil moisture level as an analog value between 0–1023.
2. LDR (Light Dependent Resistor) Connection:
Use it in a voltage divider configuration with a resistor (say 10kΩ).
Wiring:
- One side of LDR → 3.3V
- Other side of LDR → D6 and 10kΩ resistor
- The other end of resistor → GND
This way, when it’s dark, voltage at D6 goes LOW (0) and when it’s bright, it goes HIGH (1).

3. Water Pump Connection (Important – Use Relay or Transistor):
If using a relay module:
- Relay IN pin → Connect to D5
- Relay VCC → 3.3V or 5V (based on relay)
- Relay GND → GND
- Connect your water pump power wire through the relay (NO & COM)
If using a transistor circuit (for a small 5V pump):
- Use an NPN transistor (like 2N2222 or TIP120) to switch the pump
- Pump’s positive terminal → 5V or external supply
- Pump’s negative terminal → Transistor collector
- Emitter → GND
- Base → D5 through a 220Ω resistor
- Don’t forget to put a flyback diode (1N4007) across pump terminals

Power Supply:
NodeMCU can be powered by USB while testing, but this project is powered using solar panel. A 7.5V 5000 mAh rechargeable battery has been used in this project. Battery is being charged using Solar cell therefore a charge controller has also been used. The overall circuitry of this power supply system is shown below:

- Connect the charge controller output to the rechargeable battery.
- Ensure proper polarity (+ and -) connections to prevent damage.
- Verify that the battery is getting charged when sunlight is available.
Final Connection Recap:
NodeMCU Pin | Connects To |
---|---|
A0 | Soil Moisture Sensor AOUT |
D6 (GPIO12) | LDR voltage divider midpoint |
D5 (GPIO14) | Relay IN or transistor base |
3.3V / 5V | Sensor/Relay VCC (based on rating) |
GND | All component GNDs |

Microcontroller Programming for Automatic Plant Watering System
- Write the code to read both the moisture sensor and LDR values.
- Water the plants only if:
- Soil moisture is low (dry)
- Light intensity is below the threshold (evening or low-light conditions)
- Add a delay to prevent frequent pump switching.
Sample Arduino Code for NodeMCU and Soil Moisture Sensor with LDR Integration:
#define MOISTURE_PIN A0 // Moisture sensor connected to analog pin
#define LDR_PIN 6 // LDR connected to digital pin
#define PUMP_PIN 5 // Water pump connected to digital pin
// Thresholds
#define MOISTURE_THRESHOLD 500 // Adjust as needed (lower value = more moisture)
#define LDR_THRESHOLD 1 // 0 = dark, 1 = light
void setup() {
Serial.begin(9600);
pinMode(LDR_PIN, INPUT);
pinMode(PUMP_PIN, OUTPUT);
digitalWrite(PUMP_PIN, LOW); // Make sure pump is off at start
}
void loop() {
int moisture = analogRead(MOISTURE_PIN); // Read moisture level
int ldrValue = digitalRead(LDR_PIN); // Read LDR value (0 = dark)
// Print values to Serial Monitor
Serial.print("Moisture: ");
Serial.print(moisture);
Serial.print(" | LDR: ");
Serial.println(ldrValue == 0 ? "Dark" : "Light");
// Turn on pump only if it's dark and soil is dry
if (ldrValue == 0 && moisture > MOISTURE_THRESHOLD) {
digitalWrite(PUMP_PIN, HIGH);
Serial.println("Pump ON");
} else {
digitalWrite(PUMP_PIN, LOW);
Serial.println("Pump OFF");
}
delay(1000); // Wait 1 second before reading again
}
IoT Integration (Optional) of Automatic Plant Watering System
- Install the Blynk app on your smartphone.
- Use the NodeMCU board to connect the system to Wi-Fi.
- Monitor and control the irrigation system remotely.

Arduino Code for NodeMCU with Blynk Integration:
#define BLYNK_TEMPLATE_ID "XXXXXXXXXXX"
#define BLYNK_TEMPLATE_NAME "XXXXXXXXXXXXX"
#define BLYNK_AUTH_TOKEN "XXXXXXXXXXXXXXXXXXXXXXXXX"
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char ssid[] = "XXXXXX";
char pass[] = "XXXXXXXXXX";
#define MOISTURE_PIN A0 // Moisture sensor on analog pin
#define LDR_PIN D6 // LDR on digital pin
#define PUMP_PIN D5 // Water pump control pin
// Thresholds
#define MOISTURE_THRESHOLD 500 // Lower = more moisture
#define LDR_THRESHOLD 1 // LDR goes LOW in the evening
BlynkTimer timer;
void setup() {
Serial.begin(9600);
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
pinMode(LDR_PIN, INPUT);
pinMode(PUMP_PIN, OUTPUT);
digitalWrite(PUMP_PIN, LOW);
timer.setInterval(1000L, readSensors); // Read sensors every second
}
void readSensors() {
int moisture = analogRead(MOISTURE_PIN); // Read moisture sensor
int ldrValue = digitalRead(LDR_PIN); // Read LDR (0 = dark, 1 = light)
// Display sensor values on Serial Monitor
Serial.print("Moisture: ");
Serial.print(moisture);
Serial.print(" | LDR: ");
Serial.println(ldrValue == 0 ? "Dark" : "Light");
// Send data to Blynk
Blynk.virtualWrite(V0, moisture);
Blynk.virtualWrite(V1, ldrValue);
// Watering logic: only in the evening and if soil is dry
if (ldrValue == 0 && moisture > MOISTURE_THRESHOLD) {
digitalWrite(PUMP_PIN, HIGH);
Serial.println("Pump ON");
} else {
digitalWrite(PUMP_PIN, LOW);
Serial.println("Pump OFF");
}
}
void loop() {
Blynk.run();
timer.run();
}
Testing and Calibration
- Test the system to ensure the pump activates only during low light and dry soil conditions.
- Calibrate the moisture and light thresholds according to your plant’s needs.
- Check the solar panel’s charging efficiency and battery backup.

Benefits of Solar-Powered Automatic Irrigation with Light Detection
- Water Conservation:
- Watering during low-light conditions prevents evaporation.
- Energy Efficiency:
- Solar power reduces electricity dependency.
- Cost Savings:
- Cuts down energy bills and reduces labor costs.
- Remote Accessibility:
- IoT-enabled systems allow you to monitor and control the setup remotely.
- Improved Plant Health:
- Consistent, timely watering boosts plant growth and health.
Tips for Optimal Performance
- Use a higher-capacity solar panel for larger farms.
- Protect the electronics with a waterproof enclosure.
- Clean the solar panel regularly for better efficiency.
- Calibrate the LDR threshold based on your local sunset time.
- Use a drip irrigation system for efficient water distribution.
FAQs
1. Can this system be used for large-scale farming?
- Yes, you can scale it by adding more solar panels, pumps, and sensors.
2. What happens on cloudy days?
- The battery backup powers the system even when sunlight is limited.
3. Is the LDR sensitive to indoor lighting?
- Yes, LDRs detect artificial light as well. Ensure the system is placed outdoors.
Conclusion
A solar-powered automatic plant watering system with light detection is a smart, eco-friendly, and cost-effective solution for maintaining healthy plants. By combining moisture sensing with light detection, it ensures your plants receive water at the most effective time of day, promoting better growth and water efficiency.
Get started today and enjoy a smarter, greener garden with automated solar-powered irrigation!