Once upon a time, in the magical world of Saint-Cyr-l'Ecole, was a roof.
The wonderful king of the Netherlands, Yann Douze the 3rd, ordered 4 fellow slaves of EI-SE4 to build an autonomous irrigation system to save his buddy Jérome Wayne from wasting his time watering crops and go save the night 🦇
Being slaves, they started working hard day and night to satisfy their master, and came up with a system that blends innovation with autonomy, and Agriculture with Fashion and Flow, which gave birth to AgriFlow.
The system was a marvel to behold, with its intricate water channels. Word spread quickly about AgriFlow's success, and neighboring kingdoms sent envoys to witness the magical blend of agriculture and fashion. As the fame of the autonomous irrigation system grew, King Yann Douze the 3rd became a revered figure among rulers, known for his innovative approach to both agriculture and technological advancements.
The mission 🦸🏻The holy grail was to come up with a system that combines autonomy, accuracy and customizability. The system had to autonomously measure environmental variables such as air humidity and temperature, soil moisture and temperature and luminosity and wirelessly send them to our hand-crafted website. It also had to make smart decisions to start (or stop) irrigation based on the measured values, all the while making sure it consumed as little energy as possible and harvested as much environmental energy as possible.
Preamble 👨🏻💻We have imposed some constraints upon ourselves to facilitate the workflow and ensure bugs were either avoided or caught as early as possible:
- We went with an Object-Oriented programming style for the Arduino code to make the code modular and easier to read
- We chose not to use dynamic memory allocation ("malloc"/"new" ) and went with static allocation to prevent memory leaks that would hang the program
- We chose to make one main PCB connected to multiple smaller PCBs to make our components more modular
- We ran tests on our system across days before the deadline to make sure it was stable (which helped us catch 2 memory leaks)
We used Trello to organize our tasks, and connected it to our Excel Sheets to automate our managerial tools.
Finally, we ensured that we gave the right task to the right person, and ran several tasks in parallel to go fast.
Step 1: Building the website 🌐The first step was to build a website that would acquire the data sent by our device and beautifully display it on an intuitive interface.
To achieve this, we chose Laravel as the framework of choice for the backend, with Livewire to connect the backend to the frontend with ease, and JavaScript to react to user inputs.
Upon visiting the website, it first shows you a list of your devices, sorted by their status (online/offline).
You can then click on a device to view the measured values, and control the irrigation.
We can also control the frequency of measurement directly from the dashboard by easily sending a downlink to the device without much effort on the user-end.
Breadboards are an easy way to quickly prototype a working version. After ordering and receiving the components needed, we created C++ classes for each of our sensors that is either custom or encapsulates the sensor's manufacturer library code.
This way, we had a normalized interface that is the same for all of our sensors, mainly the common measure() method that returns a given sensor's measured value.
With all the sensors now standardized, we created a 4 classes to simplify sending sending and receiving LoRaWAN packets:
- Bits, which allows us to easily write bits that span on multiple elements of a uint8 array, which allowed us to optimize the amount of bytes used to send and receive packets
- UplinkPacket, which uses the Bits class and provides several helper functions to create an uplink LoRaWAN packet (consisting of a uint8 array), such as writing the temperature, humidity and luminosity
- DownlinkPacket, which uses the Bits class and provides several helper functions to decode downlink LoRaWAN packets (consisting of a uint8 array), such as reading the current date and time, triggering or pausing irrigation, etc...
- LoRaWAN, which provides several functions that move boilerplate code outside of the main file, and allows us to easily connect(), send(UplinkPacket*), and listen(DownlinkPacket*) to data via LoRaWAN, and makes use of the UplinkPacket and DownlinkPacket classes as a standardized way of sending and receiving packets
Now able to send and receive real measurements via LoRaWAN, we added a TPL5110 to our circuitry right before our sensors to reduce power usage, and created a C++ class to control it via the Arduino.
The last part to finish the basics of the project was to test our solenoid valve, which in the first draft consisted of a normally closed (NC) valve that required constant power to stay open. It consumed 1.5 Amps@12V (with a 3.7V to 12V booster) and was less than ideal for a battery-powered system. But we tested it nonetheless and got it to work well.
Now that we've gotten most of our project's main objectives done, we decided to add an F-RAM component to store Arduino configurations in the event of a power loss, and restore them when power is restored.
We connected the F-RAM to our Arduino, wrote a library that uses Arduino's Wire class for the I2C communication, and tested our library to see if we could read and write to the F-RAM. Mission accomplished!
We then created a Configuration class to abstract the F-RAM class to human readable functions (to store and restore the date and time, forced or paused irrigation, etc...).
Finally, we optimized the prototype's power consumption by using the ArduinoLowPower library and putting the Arduino to sleep whenever it is idle. We also disabled some pins such as the luminosity sensor's pin (which saved 4 milliamps) and the Murata chip pins (which saved about 10 milliamps).
Step 3: Finalizing the project 🤸🏻♂️In this crucial phase, the team took additional steps to ensure the robustness and practicality of the AgriFlow system, making it ready for real-world deployment.
In the initial prototype, a normally closed (NC) solenoid valve was employed, requiring constant power to stay open. Recognizing the high power consumption and its unsuitability for a battery-powered system, the team made a strategic decision to switch to a solenoid latching valve.
The adoption of a solenoid latching valve marked a significant improvement in energy efficiency. Unlike the continuously powered NC solenoid valve, the solenoid latching valve only required power during the brief moments of opening or closing and only needed 3.3V to function. This change contributed to a substantial reduction in power consumption and dropped consumption to 450 mA@3.3V, aligning with the project's emphasis on autonomy and energy efficiency.
To enhance the system's reliability and reduce the risk of electrical interference, the team transitioned from breadboards to a custom-designed Printed Circuit Board (PCB) using KiCad.
This involved creating an electronic schematic of the whole system:
And then connecting the components via traces, making sure to reduce the PCB size and reduce the number of vias used:
Recognizing the need to protect the AgriFlow system from environmental elements, the team selected a waterproof protective plastic box. This box served as a shield against moisture, dust, and other external factors that could potentially affect the system's performance. Carefully positioned holes were drilled in the waterproof protective plastic box to allow the passage of wires while maintaining the enclosure's water-resistant properties. This meticulous process ensured a secure and weatherproof housing for the internal components.
The wiring inside the protective box was organized and secured to prevent tangling or damage. Wire lengths were reduced to their bare-minimum to make the whole system cleaner and more pleasant to look at.
To further enhance the system's sustainability, the team introduced a water turbine as an innovative power source. The water turbine was strategically positioned within the irrigation system, capturing the flow of water and converting it into electrical energy during irrigation phases. Thanks to the turbine, we were able to go from energy loss during irrigation phases (when the NC solenoid valve was being used) to an energy gain during irrigation phases (with the latching solenoid valve and water turbine). The team then applied several layers of silicone to the box containing the irrigation modules to waterproof it and prevent any water damage to the electronic components inside.
Finally, we 3D printed a mounting piece for our solar panel, and a battery holder to secure the battery in-place.
The solar panel was glued and water-sealed onto a plastic piece. Then, the 3D printed connector was screwed into the plastic piece using threaded inserts, and fixed on a steel rod using superglue. The steel rod was pierced so it can be securely mounted on a pole using ropes and plastic cable ties (since we did not have the permission to use screws to fix the panel).
On the 18th of December 2023, we went to Sorbonne University's Campus at Saint-Cyr-l'Ecole to install our irrigation system. We started by placing the system on an elevated roof to prevent inundations and inserted the sensors into the soil.
We then connected the faucet to our water turbine, and our solenoid valve to the irrigation set, which we placed on the outline of the terrain. We then made holes into the hose to let the water spray out and into the soil.
Since the hose wasn't long enough, we had to improvise and create a dirty but working hose connector:
We also fixed our system with ropes (just in case there were very strong winds!):
We went back home, had a cup of hot chocolate, and monitored our system through our website.
Day after day, it became clearer to us that our system was a success. The battery was always maintained at 90+% and all of the measured data was accurate!
In the enchanting world of Saint-Cyr-l'Ecole, the AgriFlow project has emerged as a beacon of innovation, seamlessly blending technology, agriculture, and a touch of magic. From the inception of the idea to the final touches, the journey has been filled with challenges, creativity, and a commitment to excellence.
As the AgriFlow project takes its place in the agricultural landscape of Saint-Cyr-l'Ecole, we extend our gratitude to the readers who have followed this magical journey. Your interest and curiosity have been our constant companions, and we hope that the AgriFlow system brings as much joy to you as it does to the inhabitants of the magical kingdom.
In closing, let the fields of Saint-Cyr-l'Ecole flourish with the bounties of AgriFlow, where innovation and nature dance together in harmony. Thank you for joining us on this adventure, and may your own endeavors be filled with prosperity and success.
Comments
Please log in or sign up to comment.