CircuitPython Firmware

CircuitPython 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!

GitHub - iorodeo/open_colorimeter_firmware: Development firmware (circuitpython) for our new stand alone colorimeter
Development firmware (circuitpython) for our new stand alone colorimeter - GitHub - iorodeo/open_colorimeter_firmware: Development firmware (circuitpython) for our new stand alone colorimeter

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.

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.

{ 
    "FD&C Blue1" : { 
        "units"    : "mg/L", 
        "fit_type" : "linear", 
        "fit_coef" : [0.03, 0.0], 
        "range"    : {"min": 0.0, "max": 30.0}, 
        "led"      : 630 
    }, 
    "Ammonnia" : { 
        "units"    : "ppm", 
        "fit_type" : "linear",
        "fit_coef" : [0.125, 0.0], 
        "range"    : {"min": 0.0, "max": 8.0},
        "led"      : 630 
    }, 
    "Nitrate" : { 
        "units"     : "ppm", 
        "fit_type"  : "linear" ,
        "fit_coef"  : [0.01, 0.0], 
        "range"     : {"min": 0.0, "max": 200.0},
        "led"       : 520 
    }
}
These are example data for demonstrating the structure of the calibrations file 

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

  • the units (e.g. mg/L or ppm)
  • fit type (e.g. linear or polynomial)
  • fit coefficients
  • test range (e.g. 0-200ppm)
  • test wavelength