Used to create calibration data for Barista

Dependencies:   ColorDetectorV2 mbed

Capsule Calibrator

The default mbed Device Server (NSP or mDS) configuration is used by an instance of the web app (Barista) here: http://barista-test.cloudapp.net:4005.

In main.cpp, find the following lines:

/************************
* Modify parameters below
************************/
#define COLOR_SENSOR_SCL I2C_SCL
#define COLOR_SENSOR_SDA I2C_SDA
 
#define NUM_RUNS_PER_CAPSULE 20
#define NUM_CAPSULES 5
 
const char* capsules[] = {
    "decaffeinato_intenso",
    "vivalto_lungo",
    "roma",
    "livanto",
    "arpeggio"
};
 
/************************
* Stop editing here
************************/

Edit COLOR_SENSOR_SCL and COLOR_SENSOR_SDA to the appropriate I2C pins on your mbed platform.

Edit NUM_RUNS_PER_CAPSULE to change the number of repetitions needed per capsule. In general, this should be left at the default to ensure consistent detection.

Edit NUM_CAPSULES to match the number of different types of capsules you wish to detect.

Edit capsules[] to change the types of capsules that you wish to calibrate.

Calibration Process

Compile the project and program your mbed.

Open up a serial terminal (like PuTTY). Configure the serial connection for your mbed's serial port and set the baud rate to 115200.

Also, configure your terminal to log all of the output to a file.

Open the connection and reset your mbed.

You will now be prompted to push your first capsule through the sensor. Choose the correct capsule based on the last name printed to the console. When you have completed all of the repetitions for a particular capsule, it will print out the name of the next capsule. Proceed to push this capsule through the sensor to continue the calibration process. Repeat this until no more capsule names are printed to the terminal.

Close your terminal.

Preparing the Calibration File

Open the log file that your terminal created. Some terminal programs (including PuTTY) print extra information at the top of the file. Remove this now. The first line should read:

module.exports = {

Save and rename the file to all-data.js.

Uploading the Calibration File

Now that the calibration file has been prepared, you need to upload it to your instance of Barista. Copy and replace /classification/all-data.js in your Barista installation. When this is done, restart Barista for the changes to take effect.