My summer at Kijani Grows has been very satisfying, as well as entertaining, so far. I’ve gotten to apply information learned in the classroom to real world problems, which is exactly what I was hoping to do.

Eric put me to work quickly. My first assignment was to create a script that connects to his bluetooth device, read the report it sends every 10 seconds, and save the report in a file. We decided to use Python because it has bluetooth libraries available and because of my familiarity with the language. I downloaded a Python coding environment along with the required libraries using Ubuntu and got started.

The bluetooth device my program connected to is the small board with green LEDs visible at the bottom of the following picture.

The device is designed to monitor small aquaponic gardens like the one shown below. By taking input from sensors, and controlling environmental factors, like the lights or pump, with relays, the amount of work required to maintain a garden is reduced substantially.



Eric set this garden up recently. The garden bed has lettuce sprouts poking up.

Once I had a program receiving the board’s information via bluetooth link, Eric instructed me to create a visualization of it, choosing HTML as the presentation format. He had me set up an Apache server on my Ubuntu operating system, so I could view the website locally as I built it. I made a second Python script that reads the file created by my first script, created HTML code corresponding to the data, and stored it in a file being hosted by the apache server. In addition to displaying the data from the garden controller, Eric wanted me to make the website an interactive remote for the controller. I added buttons to HTML code and modified my original script to send commands to the garden controller when they are pushed. Then, I added the visualization; using HTML tables I created a small image of a garden and a tank.





After seeing my first attempt, Eric asked that I add the flow back pipe (the pipe that allows water to flow from the garden bed back to the fish tank), as well as a fish feeder and a reservoir. I drew up a new set of tables and set about coding them into the page.



Due to numerous visual and functional issues, I aborted my second version. On my 3rd attempt I decided to make code that creates the tables dynamically based upon a set of constants that can be modified (bed height/width, tank height/width, pipe height/width, etc.). In addition I implemented a coloring scheme that allowed for easy manipulation. This was particularly useful because it allowed the visualization to change its colors in response to different data from the garden controller (e.g. a pipe that has water flowing through it is blue).




Once the visualization was good enough, it was time to do away with the raw display, as most users would not use it. I took whatever data wasn’t shown in the visualization and displayed it in the area the report used to reside.

Below are pictures with modified dimension and color constants respectively, to demonstrate the ease of modification.





Once the visualization was complete, Eric moved me on to something different, having me work on his code for the garden controller.  He asked me to add support for commands in the form of a JSON string, and to add cyclic timer functionality. That is, instead of merely telling the garden controller to turn something on or off, I will tell it “turn the pump on for 5 minutes, off for 10 minutes, repeat”, and it will make the cycle autonomously. Using my own arduino kit as a development environment, I added the functionality. The command parsing proved difficult, as an ATMega328p (the microprocessor being used) has only 2 KB of SRAM, I had to use character arrays and pointers instead of String objects that are memory expensive. This particular problem was the most fun and difficult programming challenge I’ve encountered so far at Kijani. Eventually, I got the functionality Eric was looking for. The controller takes in commands in the form of a JSON string, the commands contain information about a particular control’s cycle. The controller maintains this information in non-volatile memory, so cycles will not be forgotten when power is lost. This cyclic capability can be used to turn lights on and off, as shown in the photos below.



Once the garden controller could enact cycles and receive commands to modify them, I added a cycle status section to its report, and returned to my second Python script. I added another area to the visualization web page that displays the cycle information from the board. In the same area, a user can create or modify cycles, and send them to the board.



The next step in the project is to make the visualization accessible to anyone using a garden with one of the bluetooth microcontrollers (it is currently hosted on my computer for development, it isn’t available on the web). This may involve setting up a master web server that will host web pages for many gardens in the area nearby, or an Android application that connects to the bluetooth directly and uses a completely different visualization.

The project is for Eric’s Guns to Gardens program currently being set up at Castlemont High School in East Oakland. There, he is clearing out an old JROTC shooting range and filling it with smart aquaponics gardens. Eric will be teaching classes there, Castlemont students will have the opportunity to learn how to grow food with the gardens, as well as how to build and maintain them. I have been to Castlemont with Eric on two occasions, and I’m excited about the program.

It has been a good summer so far, a lot of work, but also a lot of fun. Eric is fun to work with, and is a good teacher, if you ask the right questions. Hopefully, I can learn some more before Fall arrives and I go back to school.