The problem
The client, IoTSmartFarm, wanted to cut wasted water in a greenhouse. We had to measure air temperature, humidity, soil moisture and light for a potted plant, water it automatically, send the data to the cloud, and fit everything in a 5 by 5 by 10 inch volume using only the kit parts, with no adhesives.
What I did
I modeled the enclosure and assembly in SolidWorks, sliced and printed it, wired the ESP32, sensors and pump, and wrote and debugged the firmware.
- Enclosure. One printed part, all friction fits. A shared wall keeps the water bottle on the wet side and the pump and electronics on the other. Concept 1 won a weighted comparison (stability 40%, assembly 30%, printability 20%, access 10%) with a score of 8.6.
- Wiring. DHT11 for temperature and humidity, a capacitive soil sensor, a photocell divider for light, and the pump on its own driver.
- Firmware. Reads every 10 minutes off
millis(), converts to °F, %, and lux from the lab calibration curve, and publishes each value to its own MQTT topic.
How it works
Once a day the pump runs long enough for about 20 mL. On top of that, if soil moisture drops below 30% it runs an extra cycle, then waits until moisture climbs back past 40% before it can fire again. That band stops it from chattering around one threshold.
The bug I’m proudest of fixing
On the bench, every time the pump turned on, the other readings slammed to their max or min. The motor was dragging the shared 5 V rail and throwing noise into the sensors. Moving the sensors to 3.3 V and leaving only the pump on 5 V fixed it at the source.
Result
After a board replacement and rewiring, the system ran for about five days in the lab, kept soil moisture in its band, and published clean data apart from one marked single-point power blip.