In today’s world of technology and sustainability, the intersection of art and science presents an opportunity for meaningful innovation. The Importance of Life is an interactive environmental art installation that incorporates IoT technologies, such as ESP32 microcontrollers, to highlight the essential role of water and natural resources in maintaining ecosystems. This installation integrates a modular gardening system powered by automation, offering not only artistic insight but also a scalable framework for smart irrigation and automated plant care.
With over a decade of experience programming microcontrollers, I specialize in designing and implementing automation solutions for remote monitoring systems. My expertise includes projects such as my nomination as Greece’s representative at the 26th EU Contest for Young Scientists in 2014, where I presented research on the “Design and Implementation of an Automated Ultrasonic System for Remote Monitoring and Recording of Plant Growth Dynamics”.
This guide provides an in-depth exploration of the design, development, and key components of the ESP32 gardening system, serving as a step-by-step roadmap for building a customized automated environmental control system. Whether you are an artist, engineer, or hobbyist, this resource is designed to help you combine IoT gardening systems with sustainability, transforming how technology interacts with nature.
Overview of the Modular ESP32 Gardening System
Have you ever wished your garden could manage itself? Implementing an automated irrigation system with ESP32 makes this a reality. This system simplifies watering and enables real-time environmental monitoring, ensuring your garden thrives with minimal effort.
The ESP32 system is central to my interactive art installation, The Importance of Life and that is the reason I am developing it! This installation highlights the critical importance of water and its role in sustaining life. By integrating the same technology used in this modular system—such as real-time monitoring of soil moisture, temperature, and humidity—the installation creates a controlled microenvironment for a single plant.
In the art installation, the plant’s conditions are continuously monitored, and the data is used to generate dynamic visual art, reflecting both its current state and historical growth patterns. The ESP32 gardening system not only powers the automation within the installation but also serves as a prototype for scalable, sustainable plant care in real-world applications. My motivation for creating this system is rooted in blending art and technology to foster a deeper understanding of sustainability and our connection to the environment.
Monitoring Key Environmental Factors
The core of this system is its ability to track critical environmental conditions, including soil moisture, temperature, humidity, and water pH levels. Equipped with components such as the ESP32 soil moisture sensor, DHT11/DHT22 for temperature and humidity, and a pH meter, the system collects valuable data to optimize watering schedules. This ensures efficient water usage while enhancing plant growth and health.
Automating Garden Maintenance with ESP32-Controlled Systems
Let technology manage the heavy lifting with an ESP32 automated watering system. From water pumps and grow lights to misting systems, the ESP32 can handle various gardening tasks with precision. By integrating relays and solenoid valves, the system automates equipment operation—activating the water supply when soil moisture levels drop below the desired threshold.
This setup relies on smart control programmed with C++, ensuring reliable and efficient operation. For guidance on integrating mobile app functionality into your system, explore my ESP32 irrigation mobile app tutorial, which offers practical programming tips to enhance your automated plant care system.
Efficient Communication with ESP-NOW
ESP-NOW provides a seamless way for ESP32 devices to exchange data without congesting your Wi-Fi network. The ESP32 microcontrollers communicate directly, with sensor units sending environmental data to a central “boss” unit for processing. This ensures efficient and uninterrupted data flow while keeping your network resources free for other tasks. For a detailed guide, explore my tutorial on ESP32 irrigation Wi-Fi control.
Centralized Management with Node.js
At the heart of the system is a Node.js server, managing data flow, storing information in a MySQL database, and providing actionable insights for smarter plant care. This hub enables real-time monitoring and decision-making, making your garden’s ecosystem truly interconnected. For step-by-step instructions on setting up a database for your ESP32 gardening system, refer to our comprehensive ESP32 MySQL database setup guide.
Intuitive Monitoring with a ReactJS Dashboard
The system comes full circle with a sleek ReactJS dashboard, offering a clear and user-friendly interface for monitoring your garden. This dashboard provides real-time updates, historical data logs, and alerts for potential issues like dry soil or temperature spikes. It combines functionality with visual appeal, ensuring you can manage your garden effortlessly.
By integrating real-time monitoring, automated controls, and a responsive interface, this system acts as a high-tech assistant for your garden. It manages the tough tasks, allowing you to focus on enjoying a thriving, well-maintained environment.
Components Required for the ESP32 Gardening System
To bring your ESP32 irrigation system to life, you’ll need the right components. Each plays a critical role in automating plant care, ensuring your garden stays lush with minimal effort.
Microcontrollers
LilyGo T-Display S3 ESP32S3
This acts as the central processing unit for both the master and module units. Its built-in display and robust processing power make it ideal for handling sensors and controllers.
Sensors
Soil moisture sensors for monitoring water levels
These monitor soil hydration levels, ensuring plants get just the right amount of water. For setup, refer to my guide on ESP32 soil moisture sensor setup.
DHT11/DHT22 for temperature and humidity measurements
These handle temperature and humidity measurements, essential for environmental monitoring. Learn more in my guide on ESP32 temperature sensor wiring.
Ultrasonic distance sensor for plant growth tracking
Used for tracking plant growth by measuring height with precision.
pH sensors for monitoring water acidity
Monitor soil or water acidity to optimize plant health. Check my ESP32 pH monitoring system guide for installation tips.
Controllers
Relays to control grow lights, fans, and pumps
Control equipment such as grow lights, fans, and pumps. Explore my ESP32 automation guide for wiring and programming instructions.
Solenoid valves for automated irrigation
Automate water distribution with precision. Refer to my recommendations in best solenoid valves for ESP32.
Mist generators for humidity control
Manage humidity by adding a misting system to your setup. See my ESP32 misting system tutorial for details.
Software and Tools
Node.js for server-side data storage and communication
A Node.js server handles data storage and communication. Use it alongside MySQL to log sensor data effectively. See our ESP32 MySQL database setup guide for step-by-step instructions.
MySQL for logging sensor data
Enables long-term data storage for historical analysis.
ReactJS for the user interface
Develop a professional-grade dashboard for monitoring live and historical data. Learn more in my real-time dashboard guide.
SquareLine Studio for ESP32 UI development
Design intuitive user interfaces directly on the ESP32 display.
WebSockets for real-time communication
Ensure real-time data synchronization between ESP32 modules and the server.
Additional Materials
Power supplies
Ensure consistent and reliable power for your system components.
3D printed enclosures for outdoor setups
Protect your hardware with weatherproof enclosures, perfect for outdoor setups.
Wiring the ESP32 Modules
Once you’ve gathered your components, follow our tutorials on ESP32 irrigation wiring diagrams and ESP32 irrigation Wi-Fi control to complete your setup. With these tools, your automated irrigation system with ESP32 will be ready to transform your garden into a self-sustaining ecosystem.
Connecting the Capacitive Soil Moisture Sensor to ESP32
The capacitive soil moisture sensor measures soil hydration levels, letting you know when your plants need watering. Follow these simple steps to connect it to your ESP32:
Sensor Pin | ESP32 Pin |
---|---|
VCC | 3.3V |
GND | GND |
Analog Output | ADC (ex: GPIO34) |
- Power Supply: Connect the VCC pin on the sensor to the 3.3V pin on the ESP32. This powers the sensor.
- Ground: Attach the GND pin of the sensor to a GND pin on the ESP32. A stable ground connection is essential for reliable operation.
- Analog Output: Link the sensor’s Analog Output pin to an ADC pin on the ESP32, such as GPIO34. This allows the ESP32 to read soil moisture data.
For additional details on wiring, calibration, and programming, explore my comprehensive ESP32 soil moisture sensor setup guide. This resource covers everything you need to get your sensor working flawlessly.
Connecting the Ultrasonic Sensor to ESP32
Ultrasonic sensors are excellent tools for tracking plant growth or monitoring water levels in your irrigation system. Here’s how to wire it up to your ESP32 for accurate measurements.
Sensor Pin | ESP32 Pin |
---|---|
VCC | 5V |
GND | GND |
TRIG | GPIO13 |
ECHO | GPIO14 |
- Power Supply: Connect the VCC pin of the ultrasonic sensor to the 5V pin on the ESP32 to supply power.
- Ground: Attach the GND pin on the sensor to a GND pin on the ESP32 for a stable ground connection.
- Trigger Pin: Link the TRIG pin on the sensor to a GPIO pin on the ESP32, such as GPIO13. This pin sends out ultrasonic pulses.
- Echo Pin: Connect the ECHO pin on the sensor to another GPIO pin on the ESP32, like GPIO14, to receive the reflected signals.
This configuration enables the ESP32 to send and receive ultrasonic signals, allowing you to measure distances for various applications. For more details on setup and code examples, refer to my full guide on ESP32 ultrasonic sensor integration.
Attaching Relays to ESP32 for Device Control (Master Unit)
Relays are essential for automating devices like grow lights, fans, or water pumps in your ESP32 system. Here’s how to connect them for reliable operation.
Relay Pin | ESP32 Pin |
---|---|
VCC | 5V |
GND | GND |
IN | GPIO15 |
- Power to Relay: Connect the VCC pin on the relay module to the 5V pin on the ESP32 to provide power.
- Ground: Attach the GND pin of the relay module to a GND pin on the ESP32 for a stable ground connection.
- Input Signal: Link the IN pin on the relay module to a GPIO pin on the ESP32, such as GPIO15. This allows the ESP32 to control the relay’s switching.
- Controlled Device: Connect the COM (Common) terminal on the relay to the power line of your device (e.g., a water pump).
To automate the relay operation for tasks like watering schedules or environmental adjustments, explore our guide on ESP32 watering schedule programming. It covers step-by-step instructions to program relays effectively for smart control.
Independent Operation of ESP32 Modules
ESP32 modules are versatile enough to function independently, managing localized tasks like monitoring soil moisture, temperature, and humidity. Here’s how they operate solo and in harmony with a master unit.
- Independent Monitoring: Each ESP32 module can operate autonomously by directly connecting sensors such as: Soil Moisture Sensors for localized water level checks, Temperature and Humidity Sensors for monitoring microclimates. In this mode, each module collects and processes data independently, allowing for precise, modular operation.
- Communication with the Master Unit: When synchronized operation is needed, the modules can communicate with a central master node via ESP-NOW: Sensor data, like soil moisture levels or environmental conditions, is transmitted wirelessly to the master unit. The master node processes the data and determines actions, such as activating sprinklers or adjusting irrigation schedules. This distributed approach allows for efficient real-time environmental monitoring while minimizing reliance on external networks.
To ensure accurate readings, proper calibration is essential. Fine-tune your setup with our guide on ESP32 moisture sensor calibration, which provides detailed steps for optimal sensor accuracy.
By combining independent module operation with seamless ESP-NOW communication, your ESP32 automated irrigation system can function as a reliable and scalable solution for smart gardening.
Communication Between Modules and the Master Unit
Establishing effective communication between ESP32 modules and the master unit is key to creating a responsive and efficient automated irrigation system. Here’s how ESP-NOW enables seamless data exchange for real-time decision-making.
ESP-NOW Overview
ESP-NOW, developed by Espressif, is a lightweight communication protocol designed specifically for ESP32 devices. It enables fast, wireless data transfer over short distances without the need for a traditional Wi-Fi network, making it ideal for IoT gardening systems.
Key Features of ESP-NOW
- Low-Latency Communication: Data transmission is near-instant, ensuring real-time environmental updates from sensors to the master unit.
- Energy Efficiency: Designed for low power consumption, ESP-NOW is an excellent choice for low-power systems or devices powered by solar panels.
- Multi-Device Support: Supports multiple simultaneous connections, allowing several ESP32 modules to communicate with a single master unit.
How Data Flows
Modules equipped with sensors such as soil moisture sensors for monitoring hydration levels, temperature sensors for tracking microclimate conditions, and pH sensors for assessing soil or water acidity, collect critical environmental data. Using ESP-NOW, this data is transmitted wirelessly to the master unit, which processes it to determine necessary actions, such as activating sprinklers or pumps. If required, the master unit sends commands back to the modules, ensuring synchronized operation for efficient plant care.
Sensor data is collected by each module and transmitted to the master unit.
Module | Sensors | Data Collected |
---|---|---|
Module 1 | Soil moisture sensor | Soil moisture |
Module 2 | DHT11 | temperature, humidity |
Each ESP32 module operates independently, collecting data from connected sensors and transmitting it to the master unit via ESP-NOW. For instance, Module 1 gathers soil moisture data using a soil moisture sensor. Meanwhile, Module 2 collects information on temperature, and humidity through an DHT11 sensor. This distributed data collection ensures that the master unit receives comprehensive environmental data for efficient processing and action.
The master unit processes the collected data from the ESP32 modules and transmits it to a Node.js server for storage.
The server functions as a centralized database, allowing you to access and analyze the information anytime to monitor and address your garden’s needs effectively. For insights on programming your master unit, refer to the section on ESP32 watering schedule programming to enhance system functionality.
Configuring ESP-NOW for Your ESP32 System
Follow these steps to set up ESP-NOW and enable seamless communication between your ESP32 modules and the master unit.
- Install the ESP-IDF SDK: Ensure you have the ESP-IDF development framework installed. Refer to Espressif’s installation guide for setup instructions.
- Include Necessary Libraries: In your coding environment (Arduino IDE or ESP-IDF), include the libraries needed for ESP-NOW:
#include <esp_now.h>
#include <WiFi.h>
- Initialize ESP-NOW: Set up ESP-NOW for sending and receiving data:
void setup() {
WiFi.mode(WIFI_STA); // Configure as a Wi-Fi station
if (esp_now_init() != ESP_OK) {
Serial.println("Error initializing ESP-NOW");
return;
}
}
- Register Callback Functions: Define callback functions to handle sent and received data:
// Called when data is sent
void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) {
Serial.println(status == ESP_NOW_SEND_SUCCESS ? "Sent Success" : "Sent Failure");
}
// Called when data is received
void OnDataRecv(const uint8_t *mac, const uint8_t *incomingData, int len) {
Serial.print("Bytes received: ");
Serial.println(len);
}
void setup() {
esp_now_register_send_cb(OnDataSent);
esp_now_register_recv_cb(OnDataRecv);
}
- Add Peer Devices: Allow the ESP32 to communicate with specific peer devices by adding their MAC addresses:
void addPeer(uint8_t *peer_addr) {
esp_now_peer_info_t peerInfo;
memset(&peerInfo, 0, sizeof(peerInfo)); // Clear the struct
memcpy(peerInfo.peer_addr, peer_addr, 6); // Set peer MAC address
peerInfo.channel = 0;
peerInfo.encrypt = false; // No encryption for simplicity
if (esp_now_add_peer(&peerInfo) != ESP_OK) {
Serial.println("Failed to add peer");
return;
}
}
By using ESP-NOW, your modules can efficiently exchange sensor data like soil moisture levels, temperature, and plant growth metrics. For sensor-specific setup, refer to our ESP32 soil moisture sensor setup guide. If you’re integrating external APIs or extending functionality, explore our ESP32 irrigation Wi-Fi control guide for advanced tips.
Setting Up a Node.js Server for Data Storage and Real-Time Monitoring
To manage and store sensor data from your ESP32 irrigation system, setting up a Node.js server is the way to go. Here’s how to get everything installed and running.
Installing Node.js
Before diving in, ensure Node.js and essential libraries are installed.
Install Node.js and Required Libraries
- Download Node.js: Visit the official Node.js website and download the appropriate installer for your operating system. Follow the installation instructions.
- Install Required Libraries: Open your terminal or command prompt and run the following commands to install key libraries:
Express for creating a web server:npm install express
WebSocket for real-time data communication:npm install ws
MySQL for database management:npm install mysql
Database Setup
To store incoming data from your ESP32 modules, set up a MySQL database:
Create a MySQL Database to Store Sensor Data
- Install MySQL: Download and install MySQL from the official MySQL website.
- Create a Database:
Open your terminal and log in to MySQL:mysql -u root -p
Run the following commands to create a database and table: CREATEDATABASE ESP32_Irrigation;
Use the new database and create a table for sensor data:
USE ESP32_Irrigation;
CREATE TABLE SensorData (
id INT AUTO_INCREMENT PRIMARY KEY,
timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
sensor_type VARCHAR(50),
value FLOAT
);
WebSocket Communication
Enable real-time data updates from your ESP32 modules to the server using WebSocket.
Implement WebSockets for Real-Time Data Updates
Create the Server:
const express = require('express');
const WebSocket = require('ws');
const mysql = require('mysql');
const app = express();
const wss = new WebSocket.Server({ port: 8080 });
const db = mysql.createConnection({
host: 'localhost',
user: 'root',
password: '',
database: 'ESP32_Irrigation'
});
db.connect((err) => {
if (err) throw err;
console.log('Connected to MySQL');
});
wss.on('connection', (ws) => {
ws.on('message', (message) => {
const data = JSON.parse(message);
const query = "INSERT INTO SensorData (sensor_type, value) VALUES (?, ?)";
db.query(query, [data.sensor_type, data.value], (err, result) => {
if (err) throw err;
console.log('Data inserted');
});
ws.send('Data received');
});
});
app.listen(3000, () => {
console.log('Server running on port 3000');
});
Concurrent Connections
This setup supports multiple ESP32 modules communicating with the server simultaneously, ensuring smooth and real-time data flow.
Building the Monitoring Dashboard with ReactJS
Create a vibrant and user-friendly ReactJS dashboard to monitor your ESP32 irrigation system. Here’s how to implement the essential features step-by-step.
Key Features
Real-Time Monitoring: Stay Updated Instantly
Enable real-time monitoring of your ESP32 modules using WebSockets to display data such as soil moisture, temperature, and humidity as it arrives. Updates occur every 30 seconds, ensuring the dashboard remains current with live environmental metrics. By leveraging the WebSocket API, you can seamlessly integrate data streams into your React app, allowing for dynamic updates to the user interface without the need for manual refreshes. This provides an efficient and continuous flow of critical information for effective garden management.
Historical Logs: Dive into Trends
Store historical sensor data in a MySQL database and visualize trends using Chart.js. This enables the display of data in various formats such as line, bar, or pie charts, providing clear insights into environmental changes. Users can filter metrics by specific time spans, such as the last week or last month, to track trends like soil moisture fluctuations, temperature variations, or humidity patterns. This functionality ensures a comprehensive view of historical data, supporting informed decision-making for garden management.
Metric | Time Span | Sampling Interval |
---|---|---|
Soil Moisture (%) | Last 90 days | Every 30 seconds |
Temperature (°C) | Last week | Every hour |
Humidity (%) | Last month | Every hour |
Alerts: Never Miss a Critical Update
Implement an alert system to notify users when critical thresholds are breached, such as triggering an alert if soil moisture drops below 20%. Leverage API integrations to deliver notifications directly to the dashboard, email, or mobile devices for instant updates. Configure alert rules and thresholds on the server side, and use WebSocket updates or REST APIs to relay these alerts to the ReactJS dashboard, ensuring users are always informed and can take timely action to maintain optimal conditions.
Automating Environmental Control with the Master Unit
Automation simplifies plant care, and the ESP32 makes environmental control both efficient and effortless. By combining sensors, microcontrollers, and automation logic, your garden becomes a self-regulating ecosystem.
Automation Logic
Smart environmental control starts with data-driven decisions. Sensors monitor conditions like soil moisture, and the ESP32 takes action based on predefined thresholds:
Keeping Cool When Temperatures Rise
When greenhouse temperatures exceed 85°F, a DHT11 or DHT22 sensor signals the ESP32 to activate fans, reducing heat and maintaining a plant-friendly environment. For setup details, visit our guide on ESP32 DHT22 sensor setup.
Smart Lighting for Optimal Growth
Using a light sensor or a scheduled routine, the ESP32 automates grow lights, ensuring consistent illumination. It can power lights on at sunrise, off at sunset, or adjust brightness based on ambient light levels. Learn more in our ESP32 grow light automation guide.
Programming the Master Unit
Harnessing ESP32 GPIO Pins
Connecting relays to the ESP32 GPIO pins allows you to control devices like pumps, fans, and grow lights effortlessly. Here’s a simple configuration for your setup:
Function | GPIO Pin | Device |
---|---|---|
Soil Moisture Activation | GPIO 2 | Water Pump |
Temperature Control | GPIO 4 | Cooling Fans |
Light Control | GPIO 5 | Grow Lights |
Using C++ to Define Automation Logic
The ESP32 relies on C++ programming to determine when to activate devices. Here’s a sample snippet to manage your water pump based on soil moisture levels:
#define SOIL_MOISTURE_SENSOR_PIN 34
#define WATER_PUMP_PIN 2
void setup() {
pinMode(WATER_PUMP_PIN, OUTPUT);
digitalWrite(WATER_PUMP_PIN, LOW); // Ensure pump is off initially
}
void loop() {
int soilMoistureValue = analogRead(SOIL_MOISTURE_SENSOR_PIN);
if (soilMoistureValue < 300) {
digitalWrite(WATER_PUMP_PIN, HIGH); // Turn on water pump
} else {
digitalWrite(WATER_PUMP_PIN, LOW); // Turn off water pump
}
delay(1000); // Check moisture levels every second
}
This logic activates the pump when soil moisture falls below a threshold and turns it off when conditions are met. Adjust the threshold (e.g., 300) based on your soil moisture sensor’s calibration.
Additional Tools for Automation
For further customization:
- Explore ESP32 watering schedule programming to set up timed operations.
- Use the ESP32 real-time dashboard for monitoring system performance.
- Log and analyze data with ESP32 climate data logging for informed adjustments.
With the ESP32, you gain precise control over your garden’s environment, ensuring healthy and thriving plants with minimal effort.
Scaling the System with Extra Features
Ready to upgrade your ESP32 irrigation system? Adding advanced sensors and control features can supercharge your garden’s performance, turning it into a high-tech powerhouse of efficiency and growth.
Adding New Sensors: Expanding Monitoring Capabilities
Boost your system’s intelligence with these additional sensors:
- CO2 Sensors: Monitor carbon dioxide levels to ensure plants have enough for optimal growth. Think of it as your garden’s breathalyzer. For setup instructions, refer to our ESP32 CO2 sensor setup guide.
- Light Sensors: Measure the light intensity reaching your plants, helping you balance natural sunlight and grow lights to maximize photosynthesis. These sensors can fine-tune your lighting strategy for consistent results.
Quick Sensor Comparison:
Sensor Type | What’s it Measure? | Usual Range |
---|---|---|
Soil Moisture Sensor | Wetness levels in soil | 0-100% |
CO2 Sensor | Carbon dioxide concentration | 0-5000 ppm |
Light Intensity Sensor | Brightness (Lux) | 0-200,000 Lux |
Amping Up Control Features
Enhance your ESP32 irrigation system with advanced control features to create a garden that practically takes care of itself. Here’s how to level up:
- Relays and Solenoids: Relays are perfect for automating grow lights, fans, and pumps, providing precise on/off control to make your system more responsive. Solenoid valves are ideal for fine-tuning irrigation, enabling precision watering based on sensor feedback. Check out our curated list of top solenoid valves for ESP32 for recommendations.
- Mist Generators: Adjust humidity levels with mist generators to keep your plants thriving in the perfect microclimate. For a step-by-step guide, visit our ESP32 mist maker setup.
Advanced Control Features:
Control Feature | Functionality | Learn More Here |
---|---|---|
Cooling Fans | Keeps temperatures in check | ESP32 greenhouse fan guide |
Grow Light Automation | Automates smart lighting | ESP32 light show guide |
Nutrient Dosing | Delivers nutrients on schedule | ESP32 nutrition system |
Plugging in External APIs (Weather Wizards!)
Plugging into external APIs like weather services can elevate your system, enabling it to sync with nature effortlessly. By integrating weather APIs, your setup can adjust watering schedules based on forecasted rainfall or temperature changes, making it smarter and more efficient.
Explore more guides to maximize your garden’s potential:
- ESP32 smart watering schedule
- ESP32 soil sensing secrets
- ESP32 climate smarty pants
- ESP32 real-time plant watch
- ESP32 plant progress profiler
With these sensors and API integrations, your plants will thrive no matter the weather.
Conclusion
The ESP32 modular gardening system is not just a technical innovation—it’s a blend of art, technology, and sustainability. Whether you’re creating an interactive installation or fine-tuning your home garden, this system provides limitless opportunities for automation and creative expression.
These tutorials will guide you step-by-step in building your own IoT-powered gardening system, seamlessly integrating technology with nature.
Subscribe
Join Steve’s Newsletter & connect with a community of art enthousiasts, new media artists & collectors exploring the intersection of art and technology.
Join Konnekt, Steve’s exploration of human behavior, where artistic research intersects with technology and AI, digital media, and new media art. Read how technology-driven creative processes offer insights into our perceptions of self and society.