Hackers needed: help run 2.0 software on 1.0 HW


Hey fellow farmers,
I’m working on making it possible to upgrade the Food Computer 1.0 to 2.0.

So far, I’ve tested the new software on the Raspberry Pi 2 Model B, with Arduino Mega. I’ve also configured and tested firmware for 3 of the 6 sensors on the v1:

[x]  dht22 - air temp / humidity
[x]  gc0011 - co2
[ ]  dFrobot - ph
[ ]  dFrobot - ec
[x]  ds18b20  - water temp
[ ]  tsl2561 - light

You can see the progress here:


This is where we could use help. We need firmware for the other 3.

Mostly this means digging up sample code for the sensor, wrapping it in a class and writing a manifest file. The sample code is often available at AdaFruit. There is a repo full of firmware examples that show how this is done.

You’ll want to install openag_brain on Raspberry Pi 2 Model B. This script takes care of configuring a development environment.

Totally happy to mentor anyone who wants to take this on.

Total Beginner in Arduino/ Raspberry PI Programming

Also, I should point out that you don’t need a Food Computer v1 to write sensor firmware. All you need is:

  • A Raspberry Pi 2 Model B
  • An Arduino Mega
  • The sensor (most can be got from AdaFruit or Sparkfun).


Will the version 2 software work on the Raspberry PI 3 Model B? I have a working version 1 FC. I started putting together my next motherboard thinking I would put it on my next FC build which would hopefully use the version 2 code. I have the Raspberry PI 3 Model B, and an Arduino Mega 256 and all the FC version 1 sensors

I’d want to do the work using the Raspberry PI 3 Model B if possible. If using the PI 3 is too much work for now I’ll see if I can buy a PI 2 Model B. I always assumed the lab would use the PI 3 on the V2 FC but maybe I was wrong.


@ferguman yes, it’s fine to run the Raspberry Pi 3 Model B with v2.0 software and v1.0 hardware. Pi 3 will be the new default for v2.0. Having WiFi is awesome!


Hi, Gordon, have what I think is possible code for the Air Temperature and Humidity sensor pro labelled, Am 2302, the one I bought, it’s on my GitHub page, MisterBurnley. Can it be added to your list of sensors ? I couldn’t test it as I didn’t know how to put it on the Platformio site. The only other sensor I have is a light sensor will check through both tomorrow. Didn’t get the other sensors as I wanted to incorporate the version 2 ones into my build.

Just had a look at the dht22 code, the AM2302 should run with that as it’s listed as compatable on Adafruit.


Hello Gordon,

I am willing to help and also to learn, currently I have an incomplete inventory to complete my FCv1 but I already have a DFRobot Ph and EC sensor.

I use to program in C back in the days, willing to bring back the skill.

As the saying “Master teach me Kung-Fu!!!”




Hm. Let me take a look at it this weekend! I’ll see if I or others can help.


Cool! Super excited.


Hey there, very excited to work on this new sensor firmware with you. The first place to start is probably with the example firmware https://github.com/OpenAgInitiative/openag_firmware_examples.

Here’s the basic idea:

  1. A set of JSON documents (“fixtures”) describe the firmware modules, where to find them and how they should be configured for your Food Computer.
  2. These are loaded into the CouchDB database on install.
  3. openag_brain automatically reads the configuration, clones the git repos for your firmware, builds the code, and flashes the Arduino.
  4. openag_brain watches the database for config changes. If anything changes, it automatically re-clones the modules and re-flashes the Arduino.

To do this magic, we built a lightweight module system and “package manager” based on Git.

  • Firmware modules are basically a simple wrapper around the C++ code that reads values from the sensor. It’s a class that inherits from a simple base class. The goal is to exposes the same interface for all modules.
  • The firmware_module_type database has records with a Git repository URL for the firmware and a path to the C++ header file.
  • firmware_module database has records that describe the configuration for a particular module instance (this usually means setting the pins the firmware uses on your Arduino.
  • Check out the docs for firmware module configuration and writing database fixtures for more.

My process for writing firmware modules is usually:

  1. Search for open source sensor demo code. This can usually be found on Adafruit, Sparkfun or the supplier’s website.
  2. Get a simple Arduino sketch reading values from the sensor.
  3. Wrap the meat of that sketch in a firmware module.
  4. Push to GitHub

Then, you can start playing with the module in openag_brain. On your Raspberry Pi with Arduino connected, clone your module

cd my_module
openag firmware run_module -p csv -t upload

This will flash the Arduino with your firmware module in isolation and dump the result to a CSV file.

Once that’s all working, you can write a fixture for the actual module config.

Developer docs: How to edit and test a PFC2 firmware module

Hi, have clean openag_brain install but when started I get an error: no module named, openag.couch, any ideas as to what is missing ?


@JohnB can you paste the full traceback? Also, what hardware are you using and how did you install? Via one of our scripts?


Working on Raspberry Pi2 B Armv7 rev 5 (v7l). Used the link you posted to the install script, didn’t work last night around tf2_ros package, removed the 20-default.list file and tried again today and it finished Ok. There were some warnings about liboost conflict, so.1.54.0 with so.1.55.0 but it carried on.
Can’t find my Forum password so can’t paste from the pi, this is the traceback

rosrun openag_brain main -f default
File “/home/pi/catkin_ws/src/openag_brain/scripts/main”, line 10, in module
from openag.couch import Server
ImportError: No module named openag.couch

Update: not sure I mentioned that I have two sd cards set up, the first has the setup for the brain as it has been progressing and was working, at least it was storing the images from my playstation 3 usb cam. Lost track of the brain updates so resorted to installing the docker image on that card which worked apart from storing the usb images, not sure about the sensors as the code for them is what we are trying to develop.
The second card I setup yesterday and reported the above error.
I’ve returned to the first card and repeated the openag_brain installation(other machines) instructs. ie recreated the catkin_ws , and cloned the repo without, -b ros, as it is reported as not there. everything appears to install, and it reports that all required rosdeps installed successfully.
When I execute rosrun openag_brain main -f default it gives me the same error as above

importError: No module named openag.couch


@gordonb: Thanks much for the feedback. I will try to install the version 2 UI on my PI 3 and then I could perhaps contribute to your effort. At any rate I’ll document any lesson’s learned getting the version 2 software running on a PI 3 (assuming I can do it) and I’ll share that.


Hello Master Gordon,

Thanks for this information… I was already playing with the driver code for this sensors in C on arduino. But when i look at openag code it was in C++ as wrapper. I will read first the information that you provided to have a overview / guideline on how to integrate with openag coding standard.

Hoping to provide any help for this good cause.

Sorry for the late response it’s GMT +8 here in Philippines.

Thanks again,



Running sudo pip install openag should fix this. The long-term fix for this is to add the openag package to rosdistro and then add it as a runtime dependency for openag_brain in the package.xml file.


Have the TSL2561 grove light sensor and been trying to read some data from it using the seeed studio software library flashed into my arduino mega from the arduino ide on my raspberry pi, nothing.
Checked my arduino was working by flashing it with the code for the temperature and humidity sensor code for my am2302 sensor. This worked fine.
Has anyone else tried the TSL2561 sensor and got it working ? If you have then maybe mine is a dud.
Just found the adafruit code and flashed it to the arduino, the sensor gives a readout so I guess it is working.


Hi Dougie, I am right in thinking that I should run sudo pip install in the ~/catkin_ws diectory, and do i need to execute, source ~/catkin_ws/devel/setup.bash, before doing so ?


It shouldn’t matter where you run pip install from because it installs the package globally anyway. Also, it doesn’t matter whether or not the ROS workspace is active when you do it.


Thanks for that, I have executed the code on both cards with the same result, the brain starts up and gets as far as the sensor_persistence_1-10, process then starts walltime warnings.
I only have two sensors plugged into the arduino, the temperature/humidity sensor which I tested using a standalone sketch and know is working and the TSL2561 which is giving the saturated value from the adafruit sketch but, is the sensor that needs an openag driver.
I’ll post the error printout for info purposes ( need to log into the Forum from the pi ), but at this point I’m convinced that the TLS2561 isn’t working. I’ll have a go at connecting it to the arduino without the Grove Base Shield and see if it works. so unless there is something simple I’ve missed no need to spend time on this.

process[master]: started with pid [1376]

setting /run_id to 64e8c858-71ec-11e6-a2b8-b827eb391475
process[rosout-1]: started with pid [1389]
started core service [/rosout]
process[arduino_handler-2]: started with pid [1392]
process[environment_1/recipe_handler_1-3]: started with pid [1393]
process[environment_1/camera_1-4]: started with pid [1394]
process[environment_1/video_writer_1-5]: started with pid [1408]
process[api-6]: started with pid [1410]
process[topic_connector-7]: started with pid [1411]
process[topic_filter-8]: started with pid [1412]
process[image_persistence_1-9]: started with pid [1422]
process[sensor_persistence_1-10]: started with pid [1427]
[WARN] [WallTime: 1472917120.911186] Copyright © 2000-2005 Brian Dean, http://www.bdmicro.com/
[WARN] [WallTime: 1472917120.922600] Copyright © 2007-2009 Joerg Wunsch
[WARN] [WallTime: 1472917121.020952] User configuration file does not exist or is not a regular file, skipping
[WARN] [WallTime: 1472917121.024414] Using Port : /dev/ttyACM0
[WARN] [WallTime: 1472917121.027626] Using Programmer : wiring
[WARN] [WallTime: 1472917121.030677] Overriding Baud Rate : 115200
[WARN] [WallTime: 1472917121.380595] AVR Part : ATmega2560
[WARN] [WallTime: 1472917121.384732] Chip Erase delay : 9000 us
[WARN] [WallTime: 1472917121.388768] PAGEL : PD7
[WARN] [WallTime: 1472917121.400560] BS2 : PA0
[WARN] [WallTime: 1472917121.403637] RESET disposition : dedicated
[WARN] [WallTime: 1472917121.406987] RETRY pulse : SCK
[WARN] [WallTime: 1472917121.410361] serial program mode : yes
[WARN] [WallTime: 1472917121.414032] parallel program mode : yes
[WARN] [WallTime: 1472917121.417544] Timeout : 200
[WARN] [WallTime: 1472917121.421925] StabDelay : 100
[WARN] [WallTime: 1472917121.426129] CmdexeDelay : 25
[WARN] [WallTime: 1472917121.429933] SyncLoops : 32
[WARN] [WallTime: 1472917121.433818] ByteDelay : 0
[WARN] [WallTime: 1472917121.438638] PollIndex : 3
[WARN] [WallTime: 1472917121.441667] PollValue : 0x53
[WARN] [WallTime: 1472917121.444496] Memory Detail :
[WARN] [WallTime: 1472917121.447605] Block Poll Page Polled
[WARN] [WallTime: 1472917121.450710] Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
[WARN] [WallTime: 1472917121.453593] ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
[WARN] [WallTime: 1472917121.456710] eeprom 65 10 8 0 no 4096 8 0 9000 9000 0x00 0x00
[WARN] [WallTime: 1472917121.460341] flash 65 10 256 0 yes 262144 256 1024 4500 4500 0x00 0x00
[WARN] [WallTime: 1472917121.463572] lfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
[WARN] [WallTime: 1472917121.466604] hfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
[WARN] [WallTime: 1472917121.470591] efuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
[WARN] [WallTime: 1472917121.474683] lock 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
[WARN] [WallTime: 1472917121.478755] calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
[WARN] [WallTime: 1472917121.482714] signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
[WARN] [WallTime: 1472917121.487968] Programmer Type : Wiring
[WARN] [WallTime: 1472917121.491204] Description : Wiring
[WARN] [WallTime: 1472917121.494156] Programmer Model: AVRISP
[WARN] [WallTime: 1472917121.497451] Hardware Version: 15
[WARN] [WallTime: 1472917121.501365] Firmware Version Master : 2.10
[WARN] [WallTime: 1472917121.505875] Vtarget : 0.0 V
[WARN] [WallTime: 1472917121.509414] SCK period : 0.1 us
[WARN] [WallTime: 1472917121.514668] Reading | ################################################## | 100% 0.02s
[WARN] [WallTime: 1472917123.430715] Writing | ################################################## | 100% 1.92s
[WARN] [WallTime: 1472917124.851137] Reading | ################################################## | 100% 1.41s


Have you configured firmware modules in the database for your sensor configuration? What happens if you run rostopic list with that script running?