An automated irrigation system using ESP8266 microcontrollers with soil moisture monitoring and intelligent watering control. Available in two versions: Basic IO and WiFi-enabled.
This project consists of two main components with increasing levels of functionality:
A standalone irrigation controller that:
- Monitors soil moisture levels using an analog sensor
- Automatically controls a water pump based on moisture thresholds
- Provides real-time serial monitoring of system status
- Uses simple threshold-based logic for pump control
An enhanced version with networking and cloud capabilities that includes:
- All basic irrigation functionality from the IO module
- WiFi connectivity with web-based configuration portal
- Firebase/Firestore integration for cloud data synchronization
- Real-time data synchronization to the cloud
- Remote configuration and control via Firebase
- Historical data logging and analytics
- Device-specific data paths using MAC address
- Web dashboard integration capabilities
- Data logging and remote monitoring capabilities
- Web server for system status and configuration
- JSON-based configuration management
- Button controls and LED status indicators
- Pump safety features and fault detection
- Microcontroller: ESP8266 (NodeMCU v2/v3)
- Moisture Sensor: Analog soil moisture sensor
- Water Pump: Small DC water pump (5V/12V)
- Pump Driver: ULN2003 or similar relay/driver circuit
- Power Supply: Appropriate for your pump voltage
- Push Button: Momentary push button for manual controls
- Status LED: Single LED for status indication
- WiFi Network: 2.4GHz WiFi network for connectivity
- Pump Control: GPIO D1 (Pin 5) → ULN2003 IN1
- Moisture Sensor: A0 (Analog pin) → Sensor output
- Button (WiFi/Firebase): GPIO D2 (Pin 4) → Button + pull-up resistor
- LED (WiFi/Firebase): GPIO D3 (Pin 0) → LED anode
- Power: 3.3V/5V and GND connections as required
Plant_Watering_System/
├── IO/ # Basic irrigation system
│ ├── platformio.ini # PlatformIO configuration
│ ├── src/
│ │ └── main.cpp # Main irrigation logic
│ ├── include/ # Header files
│ └── lib/ # Local libraries
│
├── Wifi/ # WiFi-enabled version
│ ├── platformio.ini # PlatformIO configuration with WiFi libs
│ ├── src/
│ │ ├── main.cpp # Main application with WiFi
│ │ ├── Config.cpp/h # Configuration management
│ │ ├── ProvisionServer.cpp/h # WiFi provisioning
│ │ └── PortalLogin.cpp/h # Web portal authentication
│ ├── include/ # Header files
│ ├── lib/ # Local libraries
│ ├── HARDWARE_GUIDE.md # Detailed hardware setup
│ ├── QUICK_REFERENCE.md # Quick reference card
│ ├── TESTING_MANUAL.md # Manual testing procedures
│ └── TESTING_SIMULATION.md # Simulation testing guide
│
├── .gitignore # Git ignore rules
├── LICENSE # Project license
└── README.md # This file
- PlatformIO IDE or PlatformIO Core
- ESP8266 development board (NodeMCU recommended)
- Basic electronics components listed above
-
Clone the repository:
git clone https://github.com/190-785/Plant_Watering_System.git cd Plant_Watering_System -
Choose your version:
- For basic functionality: Navigate to
IO/directory - For WiFi features: Navigate to
Wifi/directory
- For basic functionality: Navigate to
-
Build and upload:
# For basic version cd IO pio run --target upload # For WiFi version cd Wifi pio run --target upload
-
Monitor serial output:
pio device monitor
- Power on the device near your plant
- Insert the moisture sensor into the soil
- Position the water pump in your water reservoir
- The system will automatically maintain optimal soil moisture
- Initial Setup: On first boot, the device creates a WiFi access point
- Connect: Join the AP and navigate to the configuration portal
- Configure WiFi: Set WiFi credentials and system parameters
- Firebase Setup (Optional): Create a Firebase project and enable Firestore
- Configure Firebase (Optional): Update
firebaseProjectId,firebaseApiKey, andfirebaseDatabaseURLin the code - Deploy: The system will connect to your network and begin operation, with optional cloud sync
| Feature | IO | WiFi |
|---|---|---|
| Moisture monitoring | ✅ | ✅ |
| Automatic watering | ✅ | ✅ |
| Serial monitoring | ✅ | ✅ |
| Web interface | ❌ | ✅ |
| WiFi connectivity | ❌ | ✅ |
| Button controls | ❌ | ✅ |
| LED status | ❌ | ✅ |
| Pump safety | ❌ | ✅ |
| Data logging | ❌ | ✅ |
| Remote monitoring | ❌ | ✅ |
| Cloud sync | ❌ | ✅ |
| Historical data | ❌ | ✅ |
- Dry Threshold: 480-520 (triggers pump activation)
- Wet Threshold: 420-440 (stops pump operation)
- Pump Runtime: 1-2 seconds per cycle
- Wait Period: 1-2 minutes between pump cycles
- Button Controls: Triple-press (WiFi reset), Long-press (clear fault), Short-press (manual water)
- LED Patterns: 8 different status indicators
- Web Endpoints: Dashboard, status JSON, manual controls
- Safety Features: Pump interval enforcement, fault detection
- Firebase Integration: Real-time cloud synchronization, historical data logging
- Device ID: Auto-generated from MAC address
- Data Paths:
plantData/{deviceId}/structure - Collections: Live status, historical logs, remote config, commands
- Sync Intervals: Status every 10s, config check every 30s
- HARDWARE_GUIDE.md - Complete hardware setup and wiring
- QUICK_REFERENCE.md - Quick reference card for controls and commands
- TESTING_MANUAL.md - Manual testing procedures and checklists
- TESTING_SIMULATION.md - Simulation testing guide
Modify the constants in main.cpp:
constexpr uint16_t DRY_THRESHOLD = 520; // Your dry value
constexpr uint16_t WET_THRESHOLD = 420; // Your wet valueconst unsigned long PUMP_RUN_TIME = 1000; // Pump duration (ms)
const unsigned long PUMP_WAIT_TIME = 60000; // Wait between cycles (ms)- Portal Timeout: 5 minutes for configuration
- WiFi Retry: Smart exponential backoff (1h → 6h → 24h)
- Data Logging: Every 30 seconds when online
Update these values in the WiFi version for cloud features:
String firebaseProjectId = "your-project-id";
String firebaseApiKey = "your-api-key";
String firebaseDatabaseURL = "your-database-url";- Pump not activating: Check wiring and power supply
- Erratic readings: Ensure sensor is properly inserted in soil
- WiFi connection fails: Verify credentials and signal strength
- Continuous pumping: Check sensor calibration and thresholds
- Firebase sync fails: Verify project credentials and permissions
- Portal not appearing: Triple-press button to force portal mode
- LED not responding: Check polarity (long leg to D3, short leg to GND)
- Button not working: Verify D2 connection and pull-up resistor
- Firebase sync fails: Check Firebase credentials and network connectivity
- Device not appearing in Firebase: Verify Firestore security rules
- Firebase commands not working: Check device ID format and collection paths
- Enable serial monitoring for detailed system status
- Check sensor readings manually with multimeter
- Verify pump operation with direct power connection
- Use the testing guides in the WiFi documentation
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the terms specified in the LICENSE file.
- Built using PlatformIO and Arduino framework
- Designed for ESP8266 microcontrollers
- Inspired by the need for automated plant care solutions
- Firebase integration using Firebase Arduino Client Library
Happy Growing! 🌱
Choose your version based on your needs:
- IO: Simple, reliable, offline operation
- WiFi: Network connectivity, remote monitoring, and optional cloud features