Building a Garden for the Cloud

Vernon Pearson
4 min readJun 11, 2018

Two months ago I noticed the Open Agricultural Initiative released the instructions to build a $300 food computer. This is my story on building, coding, and growing with the food computer and deploying it to the cloud in order to track and view its progress on a dashboard.

Top Left: Inside the enclosure with lettuce growing. Top Right: Raspberry Pi, relay, and power strip. The container holding the pool of water and nutrient. Bottom Left: Assembled enclosure. Bottom Middle: Leaves of lettuce cut. Bottom Right: Salad ready for consumption.

Gathering the Materials

The food computer comes with a spreadsheet detailing the materials. Conveniently, half of the parts are on Amazon: click; cart; done. The other half is sourced from Lowe’s. Driving over, I was pleasantly surprised that Lowe’s carried the exact inventory in the spreadsheet, right down to the SKU number. Moreover, the staff was terrific, directing me right to the items. After purchasing everything, the total bill between Amazon and Lowe’s came under budget at $298.92.

Top Left: Assembled PVC enclosure. Top Right: Enclose with mylar wrapped around it. Bottom Left: Cut PVC pipes. Bottom Middle: Container with drilled holes, later to be cut out along the outlined circle.

Assembly

Physical assembly was straightforward and broken down into four categories: 1.) Prepared Parts 2.) Enclosure 3.) Brain Subassembly and 4.) Final Assembly. The only recommendations I have to add are 1.) Use a copper tube cutter with the PVC pipe. The cuts will end up straight and smooth. 2.) Remember to drill inside the circle of the container. 3.) Use a third hand when soldiering 4.) When wiring a relay terminal, use the left and center inputs, forming an open connection. 5.) Give yourself a few (3) extra inches with the extension cord.

Left: Raspberry Pi and Relay. Right Top: Extension cord and led bulb. Right Middle: Component lay on the ceiling and the adapter. Right Bottom: Extension cord and temperature sensor.

Software

I wanted my food computer to connect to the cloud. Python is great as both a language and community and has broad acceptance within academia. And its projects are magical even. However, context switching is expensive and JavaScript is the language of the web. I had plans to write a frontend in react and backend in node. As a result, I had to rewrite the raspberry pi code to javascript/node.

Moving from Python to Node

“If I have seen further than others, it is by standing upon the shoulders of giants.” -Isaac Newton

After glancing at the README and looking at the code, two gaps existed. 1.) Sensor packages and 2.) Handling the event model. A quick search on npm revealed that the JavaScript community had delivered again with sensor packages. As, incredibly, it nearly always does. The eventing model, though, besides needing to be ported over, needed enhancements as well. For instance, events were fired off and handle in multiple portions of the codebase. Moreover, event names were hardcoded and written in multiple locations, making it difficult to manage over time. The solution was Redux, a predictable state container for JavaScript apps. My experience with Redux had been limited to React, leveraging React-Redux to hide the complexity of the library. After reading the documentation with how to handle vanilla javascript and associated best practices, I settled on implementing Moritz Kröger’s solution. Elegant, considering all references to the store are located in the store directory 👍. Following those road blocks and uncertainties, the rest was a simple rewrite.

To the Moon! Oh, Wait, the Cloud

The server is a boilerplate RESTful node application with a mongo datastore. Add a little docker and: Write. Ship. Done.

Left: Chart displaying temperature data Right: Images from webam

The client leverages an open-sourced admin page which has a robust feature set. So robust, in fact, that it took effort to comment out the code that was not required. The two tools that I used for the page were chart.js to display the sensor data and an S3 bucket to store the images from the webcam.

Next Steps and Final Thoughts

Within the first 2 weeks, I immediately noticed that plants were dying on the left side and thriving on the right side. The first takeaway is the side with the exhaust fan grew faster. Moreover, it appears that the circulation fan may have directed hot air onto the plants underneath it, causing heat exhaustion. As a result, I will need to add another exhaust fan to the food computer on the left side of the enclosure.

Top. The circulation fan attach to the left side of the ceiling and the exhaust fan on the side side. Bottom: The lettuce dying on the left container and growing on the right.

After installing the fan, I plan on using the images and TensorFlow to build models that will profile the growth rate of the lettuce plants (i.e. machine learning). Interestingly, the mixed growing success may actually be fortuitous because it provides me with two datasets: 1.) Images of lettuce growing and 2.) Images of lettuce of dying. Finally, I believe that the project was an enormous success. Not only was I able to view and record the progress of the lettuce, I was also able to eat what I grew as well. 😋 If you are looking to easily garden at home, I recommend building yourself a food computer.

--

--