Peirong’s Agritech Project Peirong Li, 6 December 20237 December 2023 Introduction and aim Hydroponic farming is an innovative agricultural practice that enables crop cultivation without the use of soil. Its primary advantages include precise control over environmental conditions, efficient water usage, and minimized labor requirements. This method incorporates various technologies that can be enhanced through automation, leading to improved crop yield and consistency. The core aim of this project is to design and construct a highly efficient ebb and flow hydroponic system. This system will focus on growing small, rapidly maturing plants. These plant types are selected due to their shorter growth cycles and suitability for hydroponic cultivation, making them ideal candidates for demonstrating the effectiveness of the ebb and flow method within an urban farming context. The primary goal is to establish a fully operational hydroponic setup by the semester’s end, leading to successful cultivation and harvest of the chosen plants. Through this project, we aim to explore and document the nuances of tailoring light exposure, managing plant growth, and integrating IoT functionalities to the system. In the following sections including concept drawing, development process, and results, I will guide you through constructing a basic hydroponic system using cost-effective components. Additionally, I will demonstrate how to automate this system leveraging ESP32 and Node-RED. This guide aims to provide my journey of setting up and automating a hydroponic system. Initial concept drawing Development process with pictures showcasing the evolution of the project.Phase 1: Structure DesignIn this initial concept drawing, I envisioned a double-decker ebb-and-flow system in which the bottom tray is a water reservoir, the upper tray houses the plants, and a pump connecting the two by pumping water at a certain interval. Lighting equipment is attached to a larger square metal frame that covers the whole system. Electronics are positioned behind the trays to be more invisible. I started with purchasing basic structural components, including two plastic trays, a pump, and the growing lights and began the building process by assembling the frame. I explored the positioning of the pump, and decided that the pump doesn’t need to be fixed a at a place for easier maintenance. During this step, you should be mindful of the height of the pump so it’s not too big for the tray to stack together. For lighting, I needed to consider two main variables. The first is the spectrum of the light. A better type of growing light is a full spectrum light, which emits photons of all frequencies, similar to natural sun light. Second is PPF, or photosynthetic photon flux, tells you how much photon is produced by the lighting system. This is an important number because the power of the light is not necessarily solely dependent on wattage, but also PPF. I chose a full-spectrum light that has a good amount of PPF, and it came with a solid good quality power supply to ensure reliable operations. Next, I explored ways to attach the lights on the frame, and a simple yet effective method is to use nylon ropes. Other methods can be stable as well, including using a pulley or steel lines. All these methods allow you to adjust the height of the light, but my method requires me to adjust the ropes manually after planting the seedlings. After attaching the lights, I 3D printed a set of pump connectors and drilled holes for them to fit to the trays. Drilling larger holes require a special tool. The higher connector is on top of the pump directly, for pumping in water. The lower one is an output channel that releases water back to the reservoir. For this setup to work, the pump needs to be powerful enough to guarantee that the inflow is bigger than outflow. I also 3D printed some support pillars to support the upper tray. The last step during Phase 1 is to install the seedlings in the growing tray. You could start from seeds, but for time’s sake, I started with lettuce seedlings. I used clay balls as growing medium, to accommodate for the size of the plant. Rockwool would be a better option if growing from seeds. I filled each pot with clay balls, and washed the dirt off the plant carefully using warm water. The seedlings are positioned so that the roots can reach the water. It takes a couple days to a week for the plant to adapt to its new environment, so don’t get frustrated if it looks a bit unhappy. Phase 2: Actuators and electronics, and simple automation The second phase involves some simple automation that lets the system run without constant human activity. The simple automation controls two parts: lighting and pump. For lighting, I used a mechanical timer to set the light on for around 16 hours a day. No coding needed for that. For the pump however, the mechanical timer’s intervals (15min) are too big to precisely control the pump to be on for 2-3 minutes every 4 hours. And that’s where the ESP32 comes in. The ESP32 is a powerful board made for IoT applications. I used a simple millis() code to time the pump so that it fills for 2.5min for every 4 hours. In terms of wiring, I used a single relay to regulate on/off of the pump. During semi-automation, I added nutrients every week, and I used a three-part solution for the plants. Nutrients are added manually. Once this is all done, the next step is to achieve more complex automation and add sensors. Phase 3: Sensors / Full Automation / Coding / Node-Red / Dashboard The final phase is to add sensors and achieve full automation with IoT functions. Before doing any actual coding, I needed to set up MQTT, which is a network communication protocol for IoT devices. I used a free public MQTT broker, HiveMQ, which should be enough for my purposes. Setting up requires a new cluster and login credentials. After setting up MQTT, I wired my ESP32 with multiple relays (pump, lights, and a humudifier), and a DHT22 temperature and humidity sensor. Coding the ESP32 needs a couple of steps, building on a sample MQTT code. First, I changed the WiFi and MQTT credentials to make sure that the ESP32 can connect to the internet and the HiveMQ server. Second, I created the Publish part of the code, where the ESP32 is supposed to publish temperature and humidity readings every second. Third, I managed the Subscribe part of the code, where the ESP32 receives data from the cloud, and executes commands. This part is more complex, in which I needed to first modify the callback function that slices inputs to strings, and then adding in the loop my routine for controlling the actuators. In other words, the ESP32 needs to “listen” constantly if a command is coming in, and turn something on/off accordingly. Furthermore, I used Node-RED to manage the actual automation and handles the flow. To coordinate with the ESP32, I built a flow that triggers lights and pump at a set time, and a dashboard to see readings and control actuators in real-time. After finalizing the Node-RED flow, it was uploaded to a web server, which means that it can be accessed anywhere in the world, as long as there’s internet connection. You might not want to look at a computer or phone screen all the time, so as a bonus, I added a small OLED screen to the system that allows you to see temperature and humidity readings physically. Results and reflection Here we are at the end, and the project basically meets the original goal: to establish a fully operational hydroponic setup by the semester’s end, and to have successful cultivation. The system took around 6 weeks to build and improve, and it costs around 600rmb. The lettuce seedlings grew close to mature in less than 4 weeks, making the system very efficient. With the good result, there are still some room for improvements. First, add air circulation. The benefit of placing the system indoor is to have a controlled climate. But that means there’s much less air circulation compared to traditional farming. During the process, some leafs were slightly burned due to the heat emitted by the light. Air circulation solves that problem by bringing the heat away. Also, some breeze improves the quality of the plant, making it tastes more crispy. Second, to achieve true full automation, we can add a nutrient dispensing system that pumps a certain amount of nutrients every once in a while. The dispensers need to have a pump that dumps an exact amount of liquid desired. Third, more sensors. A LDR light sensor can coordinate with the growing light to save energy when there’s enough natural lighting. A vibration sensor can determine if the pump is functioning properly. TDS and pH sensors monitor water quality, and a water level sensor tells us when to add water. Last but not least, power consumption monitoring. The system consumes a fair amount of electricity, primarily from the light. Monitoring the total amount of power used can give us a better sense of the cost of energy, adding to other costs for a full picture. Final pictures: Appendix A: Plant Growing Progression (week 1,2,3,4) By Peirong Li Projects