I received a surprise package yesterday from Farnell. It turned out to be a Nicla Sense ME board. I assume that this is a result of asking a question during Enrico's recent webinar since I haven't made a project proposal for the Better World with Arduino contest. In any case it was a pleasant surprise .
The Cheat Sheet is a great resource - the first thing that I tried is the obligatory RGB Blinky...
Then I went on to trying the Standalone example to display the sensors in the Serial Monitor. That all worked as expected, so I added the output from the Bosch Sensortec Environmental Cluster (BSEC) Software library in order to see the voc_eq and co2_eq values. That unfortunately did not work - compiled and uploaded fine, but all I got were "0" values. That surprised me because I had seen that javagoza had already demonstrated CO2 measurements.
It turns out that the sensor in the Nicla Sense ME is using a legacy address - so I needed to change that in the program.
Here are the definitions from the SensorID.h file:
SENSOR_ID_BSEC = 115, /* BSEC 1.x output */
SENSOR_ID_BSEC_LEGACY = 171, /* BSEC 1.x output (legacy, deprecated) */
I also needed to change the default data length in the SensorTypes.h file from 10 to 30:
Here is the original definition:
#define SENSOR_DATA_FIXED_LENGTH (10)
And the comment from the SensorBSEC.h file:
If the default size of SENSOR_DATA_FIXED_LENGTH is used (10 bytes), some fields of BSEC might be always 0.
With those changes, I started to get non-zero values - but they weren't changing. I haven't played with air quality sensors much and did not realize that these Bosch sensors require about 5 minutes to stabilize. After 4 minutes or so I saw the accuracy value go from 0 to 1 and I started seeing the air quality values change. I haven't seen the accuracy go above 1, so I need to do some additional reading as I think that indicates that the sensor couldn't calibrate.
The IAQ accuracy is reflects the current state of the background calibration process, such as:
- IAQ Accuracy=0 could either mean:
- BSEC was just started, and the sensor is stabilizing (this lasts normally 5min in LP mode or 20min in ULP mode),
- there was a timing violation (i.e. BSEC was called too early or too late), which should be indicated by a warning/error flag by BSEC,
- IAQ Accuracy=1 means the background history of BSEC is uncertain. This typically means the gas sensor data was too stable for BSEC to clearly define its references,
- IAQ Accuracy=2 means BSEC found a new calibration data and is currently calibrating,
- IAQ Accuracy=3 means BSEC calibrated successfully.
Here's an abbreviated Serial Monitor output:
19:41:05.651 -> acceleration: XYZ values - X: -3788 Y: 348 Z: 1598 19:41:05.651 -> gyroscope: XYZ values - X: 0 Y: -3 Z: -5 19:41:05.651 -> temperature: 27.920 19:41:05.651 -> gas: 10853.000 19:41:05.651 -> rotation: Quaternion values - X: 0.047 Y: 0.551 Z: 0.007 W: 0.833 Accuracy: 3.142 19:41:05.651 -> BSEC info: BSEC output values - iaq: 25 iaq_s: 25 b_voc_eq: 0.50 co2_eq: 500 accuracy: 0 comp_t: 27.83 comp_h: 31.76 comp_g: 4 . . . 19:45:45.951 -> acceleration: XYZ values - X: -3782 Y: 355 Z: 1590 19:45:45.951 -> gyroscope: XYZ values - X: 1 Y: -2 Z: 0 19:45:45.951 -> temperature: 28.260 19:45:45.951 -> gas: 10764.000 19:45:45.951 -> rotation: Quaternion values - X: 0.046 Y: 0.552 Z: 0.008 W: 0.832 Accuracy: 3.142 19:45:45.951 -> BSEC info: BSEC output values - iaq: 25 iaq_s: 25 b_voc_eq: 0.50 co2_eq: 500 accuracy: 1 comp_t: 28.21 comp_h: 31.18 comp_g: 4 . . . 19:45:51.935 -> acceleration: XYZ values - X: -3771 Y: 351 Z: 1581 19:45:51.935 -> gyroscope: XYZ values - X: -1 Y: -2 Z: 0 19:45:51.935 -> temperature: 28.300 19:45:51.935 -> gas: 9890.000 19:45:51.935 -> rotation: Quaternion values - X: 0.046 Y: 0.552 Z: 0.008 W: 0.832 Accuracy: 3.142 19:45:51.935 -> BSEC info: BSEC output values - iaq: 55 iaq_s: 38 b_voc_eq: 0.61 co2_eq: 552 accuracy: 1 comp_t: 28.23 comp_h: 31.13 comp_g: 4 19:45:52.963 -> acceleration: XYZ values - X: -3786 Y: 354 Z: 1596 19:45:52.963 -> gyroscope: XYZ values - X: 0 Y: -6 Z: 0 19:45:52.963 -> temperature: 28.320 19:45:52.963 -> gas: 10071.000 19:45:52.963 -> rotation: Quaternion values - X: 0.046 Y: 0.552 Z: 0.008 W: 0.832 Accuracy: 3.142 19:45:52.963 -> BSEC info: BSEC output values - iaq: 55 iaq_s: 38 b_voc_eq: 0.61 co2_eq: 552 accuracy: 1 comp_t: 28.23 comp_h: 31.13 comp_g: 4 19:45:53.945 -> acceleration: XYZ values - X: -3762 Y: 352 Z: 1567 19:45:53.945 -> gyroscope: XYZ values - X: 4 Y: 1 Z: 2 19:45:53.945 -> temperature: 28.340 19:45:53.945 -> gas: 10370.000 19:45:53.945 -> rotation: Quaternion values - X: 0.046 Y: 0.552 Z: 0.008 W: 0.832 Accuracy: 3.142 19:45:53.945 -> BSEC info: BSEC output values - iaq: 55 iaq_s: 38 b_voc_eq: 0.61 co2_eq: 552 accuracy: 1 comp_t: 28.23 comp_h: 31.13 comp_g: 4 19:45:54.966 -> acceleration: XYZ values - X: -3756 Y: 354 Z: 1584 19:45:54.966 -> gyroscope: XYZ values - X: 0 Y: 1 Z: 0 19:45:54.966 -> temperature: 28.350 19:45:54.966 -> gas: 10622.000 19:45:54.966 -> rotation: Quaternion values - X: 0.046 Y: 0.552 Z: 0.008 W: 0.832 Accuracy: 3.142 19:45:54.966 -> BSEC info: BSEC output values - iaq: 53 iaq_s: 37 b_voc_eq: 0.60 co2_eq: 550 accuracy: 1 comp_t: 28.28 comp_h: 31.05 comp_g: 4 . . . 19:50:54.227 -> acceleration: XYZ values - X: -3775 Y: 358 Z: 1573 19:50:54.227 -> gyroscope: XYZ values - X: -4 Y: 0 Z: -1 19:50:54.227 -> temperature: 28.410 19:50:54.227 -> gas: 10687.000 19:50:54.227 -> rotation: Quaternion values - X: 0.046 Y: 0.553 Z: 0.008 W: 0.832 Accuracy: 3.142 19:50:54.227 -> BSEC info: BSEC output values - iaq: 42 iaq_s: 32 b_voc_eq: 0.56 co2_eq: 530 accuracy: 1 comp_t: 28.35 comp_h: 31.04 comp_g: 4 19:50:55.207 -> acceleration: XYZ values - X: -3774 Y: 355 Z: 1587 19:50:55.207 -> gyroscope: XYZ values - X: -4 Y: -1 Z: -1 19:50:55.207 -> temperature: 28.410 19:50:55.207 -> gas: 10720.000 19:50:55.207 -> rotation: Quaternion values - X: 0.046 Y: 0.553 Z: 0.008 W: 0.832 Accuracy: 3.142 19:50:55.207 -> BSEC info: BSEC output values - iaq: 41 iaq_s: 32 b_voc_eq: 0.56 co2_eq: 529 accuracy: 1 comp_t: 28.35 comp_h: 31.05 comp_g: 4 . . . 19:55:54.504 -> acceleration: XYZ values - X: -3767 Y: 370 Z: 1536 19:55:54.504 -> gyroscope: XYZ values - X: -5 Y: -2 Z: -2 19:55:54.504 -> temperature: 28.110 19:55:54.504 -> gas: 10989.000 19:55:54.504 -> rotation: Quaternion values - X: 0.046 Y: 0.557 Z: 0.012 W: 0.829 Accuracy: 3.142 19:55:54.504 -> BSEC info: BSEC output values - iaq: 27 iaq_s: 25 b_voc_eq: 0.51 co2_eq: 503 accuracy: 1 comp_t: 28.06 comp_h: 31.17 comp_g: 4 19:55:55.490 -> acceleration: XYZ values - X: -3802 Y: 358 Z: 1540 19:55:55.490 -> gyroscope: XYZ values - X: 1 Y: 1 Z: 2 19:55:55.490 -> temperature: 28.110 19:55:55.490 -> gas: 11071.000 19:55:55.490 -> rotation: Quaternion values - X: 0.046 Y: 0.557 Z: 0.012 W: 0.829 Accuracy: 3.142 19:55:55.490 -> BSEC info: BSEC output values - iaq: 25 iaq_s: 25 b_voc_eq: 0.50 co2_eq: 501 accuracy: 1 comp_t: 28.05 comp_h: 31.17 comp_g: 4 19:55:56.491 -> acceleration: XYZ values - X: -3794 Y: 367 Z: 1548
Now, I can follow along Enrico's Workshops with some hardware. Maybe I can get a project done for the contest.