alexh-name / bsec_bme680_linux

Read the BME680 sensor with the BSEC library on Linux (e.g. Raspberry Pi)
Other
88 stars 48 forks source link

CO2 equiv #17

Closed bsimmo closed 5 years ago

bsimmo commented 5 years ago

Is anyone getting any readings from the C02 equiv (or Breath) ? I'm using a Pi Zero.

My IAQ is going through calibration (I've had it sat for an hour or so in a room, now I have a bottle of 90% propanone for the high IAQ calibration half hour as per the BSEC instructions.

While IAQ is now ramping up (still at level1 - calibration required) CO2 is just 0.00 as though nothing is being return from the BSEC calcs.

P.S. @alexh-name both CO2 and Breath are in 'ppm' (from comment in bsec_datatypes.h)

alexh-name commented 5 years ago

Hi, my fully calibrated sensor also doesn't return CO2 or VOC equivalents. However BME680 was never specified to have that ability. My guess is that the feature isn't ready or that it's not meant to be working with BME680.

bsimmo commented 5 years ago

It is part of its capabilities iirc (I remember reading about it, breathalysers and CO2 monitors) Also, the code is there in the files, it is part of the virtual sensors iirc (so runs through the BSEC, much like IAQ). I'm wondering if something has just been missed with a setting being made, unfortunately i've not quite followed the C code enough to understand. I'm no C programmer.

Perhaps not though. As a side Bosch have moved to a community forum https://community.bosch-sensortec.com/t5/Bosch-Sensortec-Community/ct-p/bst_community Away from GitHub, I think it was being moved yesterday as there was only 3 posts, the third was the post about save state linked from here. I'll have a scan there and see what crops up.

On Tue, 19 Feb 2019, 8:48 am Alex H. <notifications@github.com wrote:

Hi, my fully calibrated sensor also doesn't return CO2 or VOC equivalents. However BME680 was never specified to have that ability. My guess is that the feature isn't ready or that it's not meant to be working with BME680.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/alexh-name/bsec_bme680_linux/issues/17#issuecomment-465041993, or mute the thread https://github.com/notifications/unsubscribe-auth/ALALtyEggQ5aIJ-Ky0cCfIdYGPF0ysvdks5vO7pXgaJpZM4bBPKM .

alexh-name commented 5 years ago

It is part of its capabilities iirc (I remember reading about it, breathalysers and CO2 monitors)

Could you cite that? I was looking for implementations using BME680 and didn't find any. Also the datasheet explicitly states that the BME680 can't even detect CO2. Maybe we might get an estimate equivalent of ppm values (the code comments also call them that).

Also, the code is there in the files, it is part of the virtual sensors iirc (so runs through the BSEC, much like IAQ).

Well sure the BSEC library has code for the equivalents, but BSEC is not necessarily exclusive to the BME680 sensor.

I'm wondering if something has just been missed with a setting being made, unfortunately i've not quite followed the C code enough to understand. I'm no C programmer.

In terms of settings there isn't much leeway. There is the sample rate (LP, ULP or ULP_MEASUREMENT_ON_DEMAND) and then the configs for supply voltage, interval between bsec_sensor_control() calls and days of data to be considered for the calibration. Former is set when calling bsec_iot_init(), latter are set by reading one of the configs in the ./config directory of the BSEC package.

bsimmo commented 5 years ago

unfortunately anything/everything useful has been stripped from githubs comment/issues :-( and the main BME680 page seems to be way out of date again and cannot find it, but it was there. not even the breathalyser is mentioned anymore.

It is a calculated CO2 equivalent or eCO2, the BSEC does it, it does not measure it. Given the VOC is a complete mix of VOC's

Anyway, if I find anything I'll post back up. unfortunately a lot of google leads to github which has now gone.

I don't need it, but it's a nice to have for Air Quality.

On Tue, 19 Feb 2019 at 10:00, Alex H. notifications@github.com wrote:

It is part of its capabilities iirc (I remember reading about it, breathalysers and CO2 monitors)

Could you cite that? I was looking for implementations using BME680 and didn't find any. Also the datasheet https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BME680-DS001.pdf explicitly states that the BME680 can't even detect CO2. Maybe we might get an estimate equivalent of ppm values (the code comments also call them that).

Also, the code is there in the files, it is part of the virtual sensors iirc (so runs through the BSEC, much like IAQ).

Well sure the BSEC library has code for the equivalents, but BSEC is not necessarily exclusive to the BME680 sensor.

I'm wondering if something has just been missed with a setting being made, unfortunately i've not quite followed the C code enough to understand. I'm no C programmer.

In terms of settings there isn't much leeway. There is the sample rate (LP, ULP or ULP_MEASUREMENT_ON_DEMAND) and then the configs for supply voltage, interval between bsec_sensor_control() calls and days of data to be considered for the calibration. Former is set when calling bsec_iot_init() https://github.com/alexh-name/bsec_bme680_linux/blob/master/bsec_bme680.c#L333, latter are set by reading one of the configs in the ./config directory of the BSEC package.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/alexh-name/bsec_bme680_linux/issues/17#issuecomment-465066441, or mute the thread https://github.com/notifications/unsubscribe-auth/ALALtzb_vmPPLJ1DfDGdJ_FYVTsWJ2TWks5vO8s6gaJpZM4bBPKM .

bsimmo commented 5 years ago

The BSEC is targeted at BME680 at the moment. Look at algo/bin/Normal_version/RaspberryPI/PiZero_ArmV6-32bits/bsec_datatypes.h It all about the BME680 . Anyway, posted on the new forums as may as well ask them that should know.

I wonder if it's

define BSEC_OUTPUT_INCLUDED (1210863) /!< bitfield that indicates which outputs are included in the solution /

and the correct bitfield needs setting?

and in the BST-BME680- Integration PDF (bundled with the BSEC), you'll find it on pg 42/43

skl commented 5 years ago

In bsec_bme680_linux/src/BSEC_1.4.7.2_Generic_Release_20190122/examples/bsec_integration.c try the following changes:

At top of file near /* local macro definitions */ change: #define NUM_USED_OUTPUTS 8

to #define NUM_USED_OUTPUTS 10

Then in bme680_bsec_update_subscription() function body, change from:

    requested_virtual_sensors[0].sensor_id = BSEC_OUTPUT_IAQ;
    requested_virtual_sensors[0].sample_rate = sample_rate;
    requested_virtual_sensors[1].sensor_id = BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_TEMPERATURE;
    requested_virtual_sensors[1].sample_rate = sample_rate;
    requested_virtual_sensors[2].sensor_id = BSEC_OUTPUT_RAW_PRESSURE;
    requested_virtual_sensors[2].sample_rate = sample_rate;
    requested_virtual_sensors[3].sensor_id = BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_HUMIDITY;
    requested_virtual_sensors[3].sample_rate = sample_rate;
    requested_virtual_sensors[4].sensor_id = BSEC_OUTPUT_RAW_GAS;
    requested_virtual_sensors[4].sample_rate = sample_rate;
    requested_virtual_sensors[5].sensor_id = BSEC_OUTPUT_RAW_TEMPERATURE;
    requested_virtual_sensors[5].sample_rate = sample_rate;
    requested_virtual_sensors[6].sensor_id = BSEC_OUTPUT_RAW_HUMIDITY;
    requested_virtual_sensors[6].sample_rate = sample_rate;
    requested_virtual_sensors[7].sensor_id = BSEC_OUTPUT_STATIC_IAQ;
    requested_virtual_sensors[7].sample_rate = sample_rate;

to:

    requested_virtual_sensors[0].sensor_id = BSEC_OUTPUT_IAQ;
    requested_virtual_sensors[0].sample_rate = sample_rate;
    requested_virtual_sensors[1].sensor_id = BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_TEMPERATURE;
    requested_virtual_sensors[1].sample_rate = sample_rate;
    requested_virtual_sensors[2].sensor_id = BSEC_OUTPUT_RAW_PRESSURE;
    requested_virtual_sensors[2].sample_rate = sample_rate;
    requested_virtual_sensors[3].sensor_id = BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_HUMIDITY;
    requested_virtual_sensors[3].sample_rate = sample_rate;
    requested_virtual_sensors[4].sensor_id = BSEC_OUTPUT_RAW_GAS;
    requested_virtual_sensors[4].sample_rate = sample_rate;
    requested_virtual_sensors[5].sensor_id = BSEC_OUTPUT_RAW_TEMPERATURE;
    requested_virtual_sensors[5].sample_rate = sample_rate;
    requested_virtual_sensors[6].sensor_id = BSEC_OUTPUT_RAW_HUMIDITY;
    requested_virtual_sensors[6].sample_rate = sample_rate;
    requested_virtual_sensors[7].sensor_id = BSEC_OUTPUT_STATIC_IAQ;
    requested_virtual_sensors[7].sample_rate = sample_rate;

    requested_virtual_sensors[8].sensor_id = BSEC_OUTPUT_CO2_EQUIVALENT;
    requested_virtual_sensors[8].sample_rate = sample_rate;
    requested_virtual_sensors[9].sensor_id = BSEC_OUTPUT_BREATH_VOC_EQUIVALENT;
    requested_virtual_sensors[9].sample_rate = sample_rate;

Then uncomment the relevant lines in output_ready() of bsec_bme680_linux/bsec_bme680.c:

  printf(",[CO2 eq.]: %.2f", co2_equivalent);
  printf(",[Breath VOC eq.]: %.2f", breath_voc_equivalent);

Recompile and you should have two additional populated fields on the end of each output line.

Source: https://community.bosch-sensortec.com/t5/MEMS-sensors-forum/BME680-BSEC-eCO2/m-p/5919

bsimmo commented 5 years ago

I'll give that ago. I had increased from 8 to 10 after the reply on the Bosch community forum, but not tried the rest.

On Tue, 26 Feb 2019, 1:35 pm Stephen Lang, notifications@github.com wrote:

In bsec_bme680_linux/src/BSEC_1.4.7.2_Generic_Release_20190122/examples/bsec_integration.c try the following changes:

At top of file near / local macro definitions / change:

define NUM_USED_OUTPUTS 8

to

define NUM_USED_OUTPUTS 10

Then in bme680_bsec_update_subscription() function body, add 4 lines - before:

requested_virtual_sensors[0].sensor_id = BSEC_OUTPUT_IAQ;
requested_virtual_sensors[0].sample_rate = sample_rate;
requested_virtual_sensors[1].sensor_id = BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_TEMPERATURE;
requested_virtual_sensors[1].sample_rate = sample_rate;
requested_virtual_sensors[2].sensor_id = BSEC_OUTPUT_RAW_PRESSURE;
requested_virtual_sensors[2].sample_rate = sample_rate;
requested_virtual_sensors[3].sensor_id = BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_HUMIDITY;
requested_virtual_sensors[3].sample_rate = sample_rate;
requested_virtual_sensors[4].sensor_id = BSEC_OUTPUT_RAW_GAS;
requested_virtual_sensors[4].sample_rate = sample_rate;
requested_virtual_sensors[5].sensor_id = BSEC_OUTPUT_RAW_TEMPERATURE;
requested_virtual_sensors[5].sample_rate = sample_rate;
requested_virtual_sensors[6].sensor_id = BSEC_OUTPUT_RAW_HUMIDITY;
requested_virtual_sensors[6].sample_rate = sample_rate;
requested_virtual_sensors[7].sensor_id = BSEC_OUTPUT_STATIC_IAQ;
requested_virtual_sensors[7].sample_rate = sample_rate;

after:

requested_virtual_sensors[0].sensor_id = BSEC_OUTPUT_IAQ;
requested_virtual_sensors[0].sample_rate = sample_rate;
requested_virtual_sensors[1].sensor_id = BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_TEMPERATURE;
requested_virtual_sensors[1].sample_rate = sample_rate;
requested_virtual_sensors[2].sensor_id = BSEC_OUTPUT_RAW_PRESSURE;
requested_virtual_sensors[2].sample_rate = sample_rate;
requested_virtual_sensors[3].sensor_id = BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_HUMIDITY;
requested_virtual_sensors[3].sample_rate = sample_rate;
requested_virtual_sensors[4].sensor_id = BSEC_OUTPUT_RAW_GAS;
requested_virtual_sensors[4].sample_rate = sample_rate;
requested_virtual_sensors[5].sensor_id = BSEC_OUTPUT_RAW_TEMPERATURE;
requested_virtual_sensors[5].sample_rate = sample_rate;
requested_virtual_sensors[6].sensor_id = BSEC_OUTPUT_RAW_HUMIDITY;
requested_virtual_sensors[6].sample_rate = sample_rate;
requested_virtual_sensors[7].sensor_id = BSEC_OUTPUT_STATIC_IAQ;
requested_virtual_sensors[7].sample_rate = sample_rate;

requested_virtual_sensors[8].sensor_id = BSEC_OUTPUT_CO2_EQUIVALENT;
requested_virtual_sensors[8].sample_rate = sample_rate;
requested_virtual_sensors[9].sensor_id = BSEC_OUTPUT_BREATH_VOC_EQUIVALENT;
requested_virtual_sensors[9].sample_rate = sample_rate;

Then uncomment the relevant lines in output_ready() of bsec_bme680_linux/bsec_bme680.c:

printf(",[CO2 eq.]: %.2f", co2_equivalent); printf(",[Breath VOC eq.]: %.2f", breath_voc_equivalent);

Recompile and you should have two additional populated fields on the end of each output line.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/alexh-name/bsec_bme680_linux/issues/17#issuecomment-467439958, or mute the thread https://github.com/notifications/unsubscribe-auth/ALALtykYL79zcxpAjkUGJuWQUbgDfv0oks5vRTgmgaJpZM4bBPKM .

alexh-name commented 5 years ago

Thanks for pointing out. 16c501b1eb7db24637e3dc1482182a065f50b05d integrates this.