Open Colorimeter CircuitPython Firmware

Update on the Open Colorimeter CircuitPython firmware

Open Colorimeter CircuitPython Firmware

Lately we have been working almost exclusively on the Open Colorimeter project and sharing project updates. This week is no exception! We have been mainly working on the Open Colorimeter firmware over the past week and so this update will focus on sharing images and video so you can keep up-to-date with our progress!

Firmware

The firmware for the Open Colorimeter is programmed using CircuitPython which is a version of the Python programming language designed to run on microcontrollers. CircuitPython is very easy to use and allows for extremely rapid firmware development. The Open Colorimeter firmware is open source and free to use and download from our GitHub repository. It is currently still in active development but you can check it out here at the link below!

The Open Colorimeter will be shipped ready-to-use and pre-programmed with the latest firmware, so you do not need to be a programmer to use it! However, we know many of you will want to customize the instrument -- one of the main advantages of using Open Hardware – so we have some notes further down on customizing the firmware.

Open Colorimeter User Instructions

There are 4 main sets of navigation buttons on the Open Colorimeter:

  • Blank: Also known as Calibration. Use this with a blank reference (no signal) to set the measurement background before sample measurements. A cuvette with distilled water is commonly used as the blank reference
  • Menu: Currently the open colorimeter's default measurement mode is absorbance. Use this button to switch to a different measurement mode, for example transmittance or a measurement like ammonia, lead etc.
  • Menu navigation: Use these buttons to navigate through the Menu
  • Gain and Integration time: Sets the gain and integration time of the internal amplifiers for the photodiode channels allowing the user to control the sensitivity of the device

Currently the firmware is set-up to first show a splashscreen (left image) before it launches into the Absorbance screen (right image).

The Menu button takes you to the main menu where you can change the measurement mode to transmittance or a measurement like phosphate, calcium, nitrate etc.


Here are a couple of short videos showing the Open Colorimeter in action. The first video shows calibration/blanking using a water filled cuvette followed by an absorbance measurement. The second video highlights the menu and navigation.

0:00
/
0:00
/

Customizing firmware and adding calibrations

When programming with CircuitPython your development board will show up as a USB drive on your host computer called CIRCUITPY. To upload custom firmware you simply copy your modified Python .py files to this drive. In addition we are developing our firmware so that custom calibrations can also be added by copying a custom calibrations file to the CIRCUITPY drive.  This will enable users to easily customize their colorimeter without needing any special software or build environment.

The custom calibrations will be called "calibrations.json" and will be written using JSON (Javascript Object Notation) which is a light weight human readable data interchange format.  CircuitPython comes with a built-in JSON parser making this file format easy to use with our  firmware. An example of the structure of the "calibrations.json" file is shown below.

{
  "Ammonia API": {
    "units": "ppm",
    "led": "630",
    "fit_type": "polynomial",
    "fit_coef": [
      1.0128521350438369,
      1.890930808804952,
      0.0
    ],
    "range": {
      "min": 0.0,
      "max": 2.0
    }
  },
  "FD&C Blue 1": {
    "units": "mg/L",
    "led": "630",
    "fit_type": "polynomial",
    "fit_coef": [
      9.657673193787982,
      0.0
    ],
    "range": {
      "min": 0.0,
      "max": 0.81
    }
  },
  "Nitrate API": {
    "units": "ppm",
    "led": "520",
    "fit_type": "polynomial",
    "fit_coef": [
      0.32039213453320625,
      34.032597696304,
      0.0
    ],
    "range": {
      "min": 0.0,
      "max": 1.47
    }
  },
  "Nitrite API": {
    "units": "ppm",
    "led": "520",
    "fit_type": "polynomial",
    "fit_coef": [
      0.13111937060865314,
      1.2591439203550079,
      0.0
    ],
    "range": {
      "min": 0.0,
      "max": 1.4
    }
  }
}
These are example data for demonstrating the structure of the calibrations file 

In the examples above, we show example calibrations for four tests: Ammonia,  FD&C Blue 1, Ammonia, Nitrate, and Nitrate. Each test in the calibration file specifies

  • the units (e.g. mg/L or ppm)
  • test wavelength
  • fit type (e.g. linear or polynomial)
  • fit coefficients
  • test range (the absorbance and max and min concentrations)
Next steps: We are currently working on adding support for custom calibrations to the Open Colorimeter firmware using the calibration.json files shown above. We are also working on finishing the User Manual and online documentation.