Revolutionary setup system with production-ready optimization
Automated irrigation with IoT connectivity and modular design
Revolutionary improvements that make smart farming accessible to everyone
Choose from 5 pre-configured options for instant deployment
Production-optimized firmware with debug cleanup
ESP32 pinout diagram with connection examples
Advanced error handling and production deployment guides
Run the hardware test code to verify all connections and components are working properly.
Choose from 5 pre-configured setup types - complete configuration in just 30 seconds!
Use our dedicated configuration guides for comprehensive setup options
Choose between offline or online version and upload to your ESP32.
Intelligent watering based on soil moisture levels with configurable thresholds.
Optional LDR sensor for ambient light detection with configurable thresholds for day/night cycles.
WiFi connectivity with dual cloud service integration (ThingSpeak & Adafruit IO).
Watchdog timer, emergency stop, and pump runtime protection.
Flexible display options and configurable sensor combinations.
smart_farming/
├── MainCode/ # Main smart farming system
│ ├── offline/ # Offline version (standalone)
│ │ ├── offline.ino # Main offline sketch
│ │ ├── config.h # Offline configuration
│ │ └── README.md # Offline documentation
│ ├── online/ # Online version (IoT with cloud)
│ │ ├── online.ino # Main online sketch
│ │ ├── config.h # Online configuration
│ │ └── README.md # Online documentation
│ └── README.md # Main code documentation
├── TestCode/ # Testing and validation
│ ├── hardware/ # Hardware testing
│ │ ├── hardware_test.ino # Comprehensive hardware test
│ │ └── README.md # Hardware test documentation
│ ├── communication/ # Communication testing
│ │ ├── communication.ino # Communication test suite
│ │ └── README.md # Communication test documentation
│ └── README.md # Test code documentation
├── docs/ # Web documentation
│ ├── index.html # Main documentation page
│ ├── styles.css # Custom CSS styles
│ ├── script.js # Interactive JavaScript
│ └── README.md # Documentation guide
├── configuration.md # Comprehensive configuration guide
├── wiring_diagram.md # Wiring instructions with Mermaid
├── libraries.txt # Required Arduino libraries
├── LICENSE # MIT License
└── README.md # Main documentation
Game-changing innovations that make smart farming accessible to everyone
Automatically disables faulty DHT sensors and performs periodic health checks for automatic recovery
Creates local WiFi network when internet fails, ensuring continuous control
Saves critical settings and state across power failures and reboots
Advanced sensor validation, automatic recovery, and comprehensive error logging
Real-time system health monitoring with detailed status indicators
Bulletproof WiFi reconnection and cloud service recovery
ESP32-WROOM-32 or similar
Main controller with WiFi and ADC support
Analog capacitive sensor
0-3.3V output range
5V SPDT relay
Pump control with current handling
12V DC submersible
Irrigation system
5V/3.3V adapter
Minimum 2A capacity
DHT11 or DHT22
Light Dependent Resistor
1602 or 2004 I2C
Status indicators
Menu control
Safety button
Official ESP32 development board pinout diagram for easy hardware connections:
ESP32 Development Board - Pin Configuration
// Serial Output Settings
#define SERIAL_OUTPUT_ENABLED true // Enable/disable serial output
#define SERIAL_BAUD_RATE 115200 // Serial communication speed
Full debugging output with detailed status messages
No serial output for optimal performance
Essential serial output for remote debugging
Comprehensive guide to all configuration parameters available in config.h files for both offline and online versions.
Controls serial communication output for debugging and monitoring. When enabled, provides detailed system status and sensor readings via serial port.
Configures the display type and I2C address for the LCD screen. Supports various LCD sizes and I2C addresses.
Configures manual control interface. Supports rotary encoder for menu navigation and system control.
Configures sensor pins and types for temperature, humidity, soil moisture, and light detection.
Configures actuator pins for water pump and status LED indicators.
Controls IoT cloud services integration. Can disable individual services or all services for web UI only mode.
Sets threshold values for automatic irrigation and system alerts based on sensor readings.
Configures timing intervals for system operations, sensor readings, and display updates.
Connect all sensors, actuators, and display components according to the wiring diagram.
TestCode/hardware/hardware_test.ino
Test WiFi and cloud connectivity (for online version only).
TestCode/communication/communication.ino
Install Arduino IDE and required libraries for the smart farming system.
Arduino IDE 2.0+ | ESP32 Board Package | Required Libraries
Configure system parameters according to your hardware setup and requirements.
MainCode/offline/config.h # For offline versionMainCode/online/config.h # For online version
// Enable serial output
#define SERIAL_OUTPUT_ENABLED true
#define SERIAL_BAUD_RATE 115200
// Enable display and control
#define DISPLAY_TYPE DISPLAY_LCD_1602
#define CONTROL_TYPE CONTROL_ROTARY_ENCODER
// Fast intervals for testing
#define SENSOR_READ_INTERVAL 1000
#define DISPLAY_UPDATE_INTERVAL 2000
// Disable serial for production
#define SERIAL_OUTPUT_ENABLED false
// Headless operation
#define DISPLAY_TYPE DISPLAY_NONE
#define CONTROL_TYPE CONTROL_NONE
// Longer intervals for efficiency
#define SENSOR_READ_INTERVAL 2000
#define DISPLAY_UPDATE_INTERVAL 3000
Upload the appropriate sketch to your ESP32 board.
MainCode/offline/offline.ino # For offline versionMainCode/online/online.ino # For online version
Test all system functions including sensors, actuators, and connectivity.
TestCode/system/system_test.ino
Use configurable serial output or web interface to monitor system operation.
Serial Monitor (if enabled) | Web Interface (online version)
💡 Tip: Disable serial output in production for better performance and power efficiency.
Check wiring connections and pin assignments in config.h
Verify I2C address and display type configuration
Check credentials and network availability
Adjust sensor reading and display update intervals for your needs
Turn off serial output and unused sensors in production
Use web interface to monitor system performance and memory
Start by running the hardware test code to verify all connections and components.
TestCode/hardware/hardware_test.ino
Test WiFi and cloud connectivity (for online version only).
TestCode/communication/communication.ino
Install all required libraries via Arduino IDE Library Manager.
See libraries.txt for complete list
Open the appropriate sketch file for your chosen version.
MainCode/offline/offline.ino # For offline versionMainCode/online/online.ino # For online versionTestCode/hardware/hardware_test.ino # For hardware testingTestCode/communication/communication.ino # For communication testing
Edit the configuration file to match your hardware setup and requirements.
MainCode/offline/config.h # For offline versionMainCode/online/config.h # For online version
These examples are taken directly from the actual config.h files and can be copied to your configuration.
// Basic offline configuration - Copy to MainCode/offline/config.h
// Display Configuration
#define DISPLAY_TYPE DISPLAY_LCD_1602
#define LCD_ADDRESS 0x27
// Control Configuration (no manual control)
#define CONTROL_TYPE CONTROL_NONE
// Sensor Configuration
#define DHT_SENSOR_TYPE DHT_TYPE_22
#define DHT_PIN 5
#define SOIL_MOISTURE_PIN 36
// Irrigation Settings
#define SOIL_MOISTURE_THRESHOLD 30
#define IRRIGATION_DURATION 5000
#define MAX_DAILY_IRRIGATIONS 10
// System Settings
#define SERIAL_OUTPUT_ENABLED true
#define WATCHDOG_ENABLED true
Best for: Basic automated irrigation with DHT22 sensor and LCD display
// Advanced offline configuration - Copy to MainCode/offline/config.h
// Display Configuration (larger display)
#define DISPLAY_TYPE DISPLAY_LCD_2004
#define LCD_ADDRESS 0x27
// Control Configuration (rotary encoder for menu)
#define CONTROL_TYPE CONTROL_ROTARY_ENCODER
#define ENCODER_CLK_PIN 16
#define ENCODER_DT_PIN 17
#define ENCODER_SW_PIN 4
// Sensor Configuration (all sensors)
#define DHT_SENSOR_TYPE DHT_TYPE_22
#define DHT_PIN 5
#define SOIL_MOISTURE_PIN 36
#define LDR_SENSOR_TYPE LDR_TYPE_ENABLED
#define LDR_PIN 39
// Safety Features
#define WATCHDOG_ENABLED true
#define EMERGENCY_STOP_ENABLED true
#define PUMP_RUNTIME_PROTECTION true
Best for: Full-featured offline system with manual control and all sensors
// Basic online configuration - Copy to MainCode/online/config.h
// WiFi Configuration
#define WIFI_SSID "YOUR_WIFI_SSID"
#define WIFI_PASSWORD "YOUR_WIFI_PASSWORD"
// IoT Services
#define IOT_SERVICES_ENABLED true
#define THINGSPEAK_ENABLED true
#define THINGSPEAK_API_KEY "YOUR_API_KEY"
#define ADAFRUIT_IO_ENABLED false
// Display & Sensors (same as offline)
#define DISPLAY_TYPE DISPLAY_LCD_1602
#define DHT_SENSOR_TYPE DHT_TYPE_22
#define DHT_PIN 5
#define SOIL_MOISTURE_PIN 36
// LED Configuration
#define LED_GREEN_PIN 18 // System OK
#define LED_RED_PIN 23 // Pump Active
#define LED_BLUE_PIN 2 // WiFi Connected
Best for: WiFi-enabled monitoring with ThingSpeak data logging
// Web UI only configuration - Copy to MainCode/online/config.h
// WiFi Configuration
#define WIFI_SSID "YOUR_WIFI_SSID"
#define WIFI_PASSWORD "YOUR_WIFI_PASSWORD"
// IoT Services (web UI only mode)
#define IOT_SERVICES_ENABLED false
#define WEB_UI_ONLY_MODE true
// Web Server Configuration
#define WEB_SERVER_PORT 80
#define ENABLE_WEB_AUTH true
#define WEB_USERNAME "admin"
#define WEB_PASSWORD "smartfarm123"
// Control Configuration
#define CONTROL_TYPE CONTROL_ROTARY_ENCODER
#define ENCODER_CLK_PIN 16
#define ENCODER_DT_PIN 17
#define ENCODER_SW_PIN 4
Best for: Local network monitoring without external cloud dependencies
#define SERIAL_OUTPUT_ENABLED true#define IOT_SERVICES_ENABLED true#define DISPLAY_TYPE DISPLAY_LCD_1602#define CONTROL_TYPE CONTROL_ROTARY_ENCODER#define DHT_SENSOR_TYPE DHT22Choose between offline or online version and upload to your ESP32.
MainCode/offline/offline.ino # For offline versionMainCode/online/online.ino # For online version
Use configurable serial output or web interface to monitor system operation.
Serial Monitor (115200 baud) or Web Interface
💡 Tip: Disable serial output (SERIAL_OUTPUT_ENABLED false) for production deployments to improve performance.
🌐 IoT Services: Set WEB_UI_ONLY_MODE true to disable all IoT services and use only the built-in web interface.
/api/status
Get current system status and sensor readings
{
"systemOK": true,
"soilMoisture": 45,
"temperature": 25.3,
"humidity": 60.2,
"pumpActive": false,
"uptime": 3600
}
/api/pump
Control pump manually
{
"action": "start" | "stop",
"duration": 30
}
/api/config
Get current system configuration
/api/config
Update system configuration
Report issues and contribute
Comprehensive guides and examples
MIT License - Free to use and modify