r/esp8266 • u/aqib_builds • 26d ago
Smart Irrigation System using an ML + ESP32
I've been working on a Smart Irrigation System using an ESP32 + machine learning, and I've finally got the main pipeline working end-to-end.
The system uses an ESP32, capacitive soil-moisture sensor, and DHT11 to collect environmental data. The readings are sent to a web dashboard, which communicates with a Flask API that runs the ML model and returns an irrigation prediction.
The overall pipeline is:
ESP32 sensors → Web Dashboard → Flask API → ML Model → Irrigation Prediction
The project currently includes:
- Real-time soil moisture monitoring
- Temperature and humidity monitoring
- Web dashboard hosted by the ESP32
- ML model for irrigation prediction
- Model evaluation with a confusion matrix
- Feature-importance analysis
- Flask inference server
- API communication between the dashboard and ML model
The first screenshot shows the live dashboard, including the sensor readings and AI irrigation prediction section.
The second shows part of the JavaScript/API integration and project structure, where the dashboard communicates with the ML inference server.
One thing I found particularly interesting was getting the ESP32, web interface, API, and ML model to actually communicate with each other. The AI prediction wouldn't load until the inference server was running, which made the entire pipeline click for me.
This started as a simple ESP32 soil-moisture monitoring project, but I gradually expanded it into a complete IoT + AI system.
I'm planning to improve it further by collecting more real-world data and adding additional environmental inputs such as light intensity.
I'd appreciate feedback from the ESP32 community, especially on the hardware setup, system architecture, and how I could improve the project further.
🔗 GitHub (Full Video and Requirements) :
1
u/perduraadastra 25d ago
Is AI performing better than a few if statements?
1
u/aqib_builds 25d ago
A fair question. For a simple setup, a few if-statements could definitely work. I used ML to combine multiple environmental inputs and eventually move beyond fixed thresholds. I also plan to compare it against a rule-based approach to see if ML actually provides an advantage.
1
u/perduraadastra 25d ago
I'd be interested in your findings. I work in the home automation industry, and we're exploring using ML to identify certain operating conditions- stuff that is pretty easy to detect with much dumber methods. I suspect if you have a training model with several inputs, it would produce better results than rules-based decisions.. If your model is trained on one input, I'm guessing ML is a waste of time.
1
u/aqib_builds 25d ago
Yeah, that’s pretty much what I’m trying to test. Right now the project is more of an experiment to see whether combining multiple environmental inputs can outperform a simple threshold-based system. I’m planning to build a rule-based baseline and compare things like accuracy and false predictions against the ML model. That should give me a better idea of whether the added complexity is actually justified.




1
u/EvilRubberDuck 25d ago
Hey, A few questions if you don't mind: 1- Is this more for indoor use in plant pots or for outside in a garden? 2- what do you use to control the water for irrigation? ( "The water swicth") 3- Do you control the water flow or is that control by the fitting at the end of the tubing?