Skip to content
Snippets Groups Projects

BSEC support

Merged schneider requested to merge schneider/bsec into master

Adds basic Bosch BSEC support.

BSEC is a proprietary library from Bosch which uses the BME680 to calculate an estimation of an "Indoor Air Quality". It takes complete control of the BME680 and performs a measurement every 3 seconds. This consumes about 0.9 mA on the 1.8 V rail. A later iteration of this driver might also allow to change the interval to 300 seconds to save energy.

Two configuration options are introduced. One to enable the driver (as it is a binary blob) and one to enable the debug prints of the driver. If the library is active, calls to the BME680 API will stop using the sensor directly and return a subset of the data gathered by the BSEC library.

You can use this https://phyphox.org/ "experiment" to access the data:

download__1_

cwNiWbhBMDGanPdkseSkGBCn

In addition the pycardium BME680 API and the BLE Environmental Sensing Service have been extended.

Edited by schneider

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • schneider added 1 commit

    added 1 commit

    Compare with previous version

  • schneider added 1 commit

    added 1 commit

    • 95f12974 - feat(bsec): add option to set a static temperature offset

    Compare with previous version

  • schneider added 2 commits

    added 2 commits

    • 2921f6cd - feat(ble): Add ESS and Temperature UUIDs
    • fa161009 - feat(ble): Add Evironmental Sensing Service

    Compare with previous version

  • schneider added 4 commits

    added 4 commits

    • 567b9278 - fix(ble): Don't write PeerSignCounter if it didn't change
    • 2806729c - fix(ess): Show how to update a characteristic without a callback
    • 7fce48d8 - chore(ess): Introduce ess.h
    • 65309724 - feat(ess): add notification support for temperature

    Compare with previous version

  • schneider added 1 commit

    added 1 commit

    Compare with previous version

  • schneider added 3 commits

    added 3 commits

    • f7213f77 - feat(ess): Add humidity characteristic
    • 9983c0b8 - fix(ess): Correctly handle negative temperatures
    • a4bb7de9 - feat(ess): Add pressure characteristic

    Compare with previous version

  • schneider added 33 commits

    added 33 commits

    • a4bb7de9...f79bd076 - 3 commits from branch master
    • b445fb54 - feat(bme680): Add BSEC library
    • e07c0bc5 - chore(bsec): code style
    • 2057cad7 - fix(bme680): Use the hw locks
    • 7e7b0ea4 - fix(bsec): Prevent current time overflow
    • 665d5219 - feat(bsec): Apply default configuration if there is no config file
    • d55b76fa - fix(bsec): add task handle for debugging in gdb
    • 0f9cf902 - chore(bsec): Apply code style
    • 15ff5f28 - feat(bme680): Act as shim if BSEC is active
    • 18737852 - feat(bsec): Cleanup.
    • ca4b3263 - refact(bme680): Use more granular locks. Sleep using FreeRTOS
    • e96bb6ba - fix(bsec): Reduce stack usage by calling init before stating the task
    • f5e82519 - fix(bsec): Reduce stack usage by reusing a buffer
    • 5728cb49 - fix(bsec): More accurate statements about stack usage
    • 9066f066 - fix(bsec): Enable CO2 and total breath VOC outputs
    • 1271b8b5 - fix(bme680): Check for NULL pointer as mentioned in docs
    • 4bd1020a - fix(bsec): Read CO2 and total breath voc into cache
    • c6b951e9 - feat(bsec): Initial BSEC API
    • 60044f63 - feat(bsec): Add config options
    • a3d73139 - chore(bsec): Style fixes
    • 7e04fb99 - feat(bsec): add option to set a static temperature offset
    • 9ee18efd - feat(ble): Add ESS and Temperature UUIDs
    • 4b49d265 - feat(ble): Add Evironmental Sensing Service
    • 8dfb292e - fix(ess): Show how to update a characteristic without a callback
    • a1681c2d - chore(ess): Introduce ess.h
    • a2975784 - feat(ess): add notification support for temperature
    • 557d748e - chore(ess): Code style
    • 666ea48c - feat(ess): Add humidity characteristic
    • 637c8e65 - fix(ess): Correctly handle negative temperatures
    • cafc7846 - feat(ess): Add pressure characteristic
    • 0eaac9ca - chore(ess): Fix c&p comment

    Compare with previous version

  • How to enable notifications on a characteristic using bluepy: https://github.com/IanHarvey/bluepy/issues/53#issuecomment-276103617

  • added 3-Epicardium label

    • Resolved by schneider

      Better linking between the different pages of the documentation. @rahix I think I need your support here.

      I suggest this:

      diff --git a/Documentation/card10-cfg.rst b/Documentation/card10-cfg.rst
      index 8c4f12178487..6ad3261945f3 100644
      --- a/Documentation/card10-cfg.rst
      +++ b/Documentation/card10-cfg.rst
      @@ -43,7 +43,7 @@ Option name     Type       Description
       --------------- ---------- -----------
       ``default_app`` String     Full path to the exectutable file of the default application. If this option is not set,``apps/analog_clock/__init__.py`` is used.
       --------------- ---------- -----------
      -``bsec_enable`` Boolean    Activate the Bosch :ref:`BSEC` binary blob to compute an Indoor Air Quality indication.
      +``bsec_enable`` Boolean    Activate the Bosch :ref:`bsec_api` binary blob to compute an Indoor Air Quality indication.
       --------------- ---------- -----------
       ``bsec_debug``  Boolean    Turn on debug output of the BSEC system. Prints each meaurement on the console.
       --------------- ---------- -----------
      diff --git a/epicardium/epicardium.h b/epicardium/epicardium.h
      index a17880a14595..581c803d0207 100644
      --- a/epicardium/epicardium.h
      +++ b/epicardium/epicardium.h
      @@ -874,6 +874,19 @@ API(API_BME680_GET_DATA, int epic_bme680_read_sensors(
              struct bme680_sensor_data *data
       ));
       
      +/**
      + * .. _bsec_api:
      + *
      + * BSEC
      + * ----
      + * The Bosch BSEC libary allows to compute an indoor air
      + * qualtiy (IAQ)metric as well as CO2 and VOC content
      + * equivalents using the gas sensor of the BME680.
      + *
      + * As it is a proprietary binary blob, it has to be enabled using
      + * the ``bsec_enabled`` configuration option (see :ref:`card10_cfg`).
      + */
      +
       /**
        * BSEC Sensor Data
        */
      @@ -955,8 +968,6 @@ struct bsec_sensor_data {
       };
       
       /**
      - *
      - * .. _BSEC:
        * Get the current BME680 data filtered by Bosch BSEC library
        *
        * The Bosch BSEC libary allows to compute an indoor air
      @@ -964,7 +975,7 @@ struct bsec_sensor_data {
        * equivalents using the gas sensor of the BME680.
        *
        * As it is a proprietary binary blob, it has to be enabled using
      - * the ``bsec_enabled`` configuration option (see <link to config>).
      + * the ``bsec_enabled`` configuration option (see :ref:`card10_cfg`).
        *
        * The sample rate is currently fixed to one sample every 3 seconds.
        * Querying the sensor more often will return cached data.

      (Note that your label .. _BSEC: did not work because it was not followed by a heading)

  • For reference:

    --- /tmp/old	2020-06-02 20:10:43.843559585 +0200
    +++ /tmp/new	2020-06-02 20:10:53.596972355 +0200
    @@ -1,4 +1,4 @@
        text	   data	    bss	    dec	    hex	filename
       54652	      0	  42608	  97260	  17bec	build/bootloader/bootloader.elf
    - 284660	   2080	 124964	 411704	  64838	build/epicardium/epicardium.elf
    + 325552	   2108	 126284	 453944	  6ed38	build/epicardium/epicardium.elf
    - 204380	    140	    648	 205168	  32170	build/pycardium/pycardium.elf
    + 204388	    140	    648	 205176	  32178	build/pycardium/pycardium.elf

    = +10% size increase in Epicardium

  • schneider added 105 commits

    added 105 commits

    • 0eaac9ca...b6832e3f - 75 commits from branch master
    • 6db2663b - feat(bme680): Add BSEC library
    • 503bb097 - chore(bsec): code style
    • 53a4fa1a - fix(bme680): Use the hw locks
    • f531d9a0 - fix(bsec): Prevent current time overflow
    • 39fec8b2 - feat(bsec): Apply default configuration if there is no config file
    • 66fb8969 - fix(bsec): add task handle for debugging in gdb
    • 5c9aac7f - chore(bsec): Apply code style
    • bb781a57 - feat(bme680): Act as shim if BSEC is active
    • 48c346ba - feat(bsec): Cleanup.
    • 0ce4428c - refact(bme680): Use more granular locks. Sleep using FreeRTOS
    • c85837a8 - fix(bsec): Reduce stack usage by calling init before stating the task
    • 0212c458 - fix(bsec): Reduce stack usage by reusing a buffer
    • b40fff35 - fix(bsec): More accurate statements about stack usage
    • c65370cf - fix(bsec): Enable CO2 and total breath VOC outputs
    • e154e38d - fix(bme680): Check for NULL pointer as mentioned in docs
    • 7252a660 - fix(bsec): Read CO2 and total breath voc into cache
    • f07a2059 - feat(bsec): Initial BSEC API
    • c37b513b - feat(bsec): Add config options
    • 6d0c5cfd - chore(bsec): Style fixes
    • eb662bdb - feat(bsec): add option to set a static temperature offset
    • f643197a - feat(ble): Add ESS and Temperature UUIDs
    • 6939d74f - feat(ble): Add Evironmental Sensing Service
    • 511272bc - fix(ess): Show how to update a characteristic without a callback
    • 08cdb590 - chore(ess): Introduce ess.h
    • 884cfaa3 - feat(ess): add notification support for temperature
    • d39f60eb - chore(ess): Code style
    • 08da2c38 - feat(ess): Add humidity characteristic
    • 75493581 - fix(ess): Correctly handle negative temperatures
    • 41e2c5bf - feat(ess): Add pressure characteristic
    • 8064c107 - chore(ess): Fix c&p comment

    Compare with previous version

  • schneider added 60 commits

    added 60 commits

    • 8064c107...73fbb3eb - 30 commits from branch master
    • 88bce548 - feat(bme680): Add BSEC library
    • 5178b40f - chore(bsec): code style
    • 73aeab00 - fix(bme680): Use the hw locks
    • 81a0dfd9 - fix(bsec): Prevent current time overflow
    • b1d8c90f - feat(bsec): Apply default configuration if there is no config file
    • 0067b425 - fix(bsec): add task handle for debugging in gdb
    • c3adb051 - chore(bsec): Apply code style
    • edae2b62 - feat(bme680): Act as shim if BSEC is active
    • dc667a78 - feat(bsec): Cleanup.
    • 32ab7c9d - refact(bme680): Use more granular locks. Sleep using FreeRTOS
    • 58d5957d - fix(bsec): Reduce stack usage by calling init before stating the task
    • b725b9b7 - fix(bsec): Reduce stack usage by reusing a buffer
    • 26b4c48a - fix(bsec): More accurate statements about stack usage
    • e7abedd6 - fix(bsec): Enable CO2 and total breath VOC outputs
    • e35422b2 - fix(bme680): Check for NULL pointer as mentioned in docs
    • 3e8e7f9e - fix(bsec): Read CO2 and total breath voc into cache
    • 1e17ca69 - feat(bsec): Initial BSEC API
    • ef7a2051 - feat(bsec): Add config options
    • 98ef2d08 - chore(bsec): Style fixes
    • 17ad6de3 - feat(bsec): add option to set a static temperature offset
    • 140d199d - feat(ble): Add ESS and Temperature UUIDs
    • 3e3e8f76 - feat(ble): Add Evironmental Sensing Service
    • efe075b2 - fix(ess): Show how to update a characteristic without a callback
    • 24a74952 - chore(ess): Introduce ess.h
    • b6b1ace8 - feat(ess): add notification support for temperature
    • 423809ff - chore(ess): Code style
    • 9ccab3a9 - feat(ess): Add humidity characteristic
    • c5c808f4 - fix(ess): Correctly handle negative temperatures
    • 0d2f61e8 - feat(ess): Add pressure characteristic
    • e9a8397f - chore(ess): Fix c&p comment

    Compare with previous version

  • schneider added 126 commits

    added 126 commits

    • e9a8397f...15cff341 - 96 commits from branch master
    • 02b31d04 - feat(bme680): Add BSEC library
    • 41b62608 - chore(bsec): code style
    • af166f67 - fix(bme680): Use the hw locks
    • 03cb769b - fix(bsec): Prevent current time overflow
    • a5ea413e - feat(bsec): Apply default configuration if there is no config file
    • c50bcc8e - fix(bsec): add task handle for debugging in gdb
    • e4c28396 - chore(bsec): Apply code style
    • 760f064e - feat(bme680): Act as shim if BSEC is active
    • c895ab71 - feat(bsec): Cleanup.
    • f6d70023 - refact(bme680): Use more granular locks. Sleep using FreeRTOS
    • 24c8fce4 - fix(bsec): Reduce stack usage by calling init before stating the task
    • 439006fb - fix(bsec): Reduce stack usage by reusing a buffer
    • 7ff25b00 - fix(bsec): More accurate statements about stack usage
    • 2950994f - fix(bsec): Enable CO2 and total breath VOC outputs
    • f0828f1c - fix(bme680): Check for NULL pointer as mentioned in docs
    • 40c12405 - fix(bsec): Read CO2 and total breath voc into cache
    • 856af200 - feat(bsec): Initial BSEC API
    • 0d98a0dd - feat(bsec): Add config options
    • 9908ca17 - chore(bsec): Style fixes
    • 4ffc23c2 - feat(bsec): add option to set a static temperature offset
    • 98f8c115 - feat(ble): Add ESS and Temperature UUIDs
    • 0c799b71 - feat(ble): Add Evironmental Sensing Service
    • 315869fd - fix(ess): Show how to update a characteristic without a callback
    • e4525654 - chore(ess): Introduce ess.h
    • d332129c - feat(ess): add notification support for temperature
    • 89b0fa4d - chore(ess): Code style
    • 3159bc6b - feat(ess): Add humidity characteristic
    • fd3e60f2 - fix(ess): Correctly handle negative temperatures
    • d35e31f7 - feat(ess): Add pressure characteristic
    • 30f89fe9 - chore(ess): Fix c&p comment

    Compare with previous version

  • schneider added 42 commits

    added 42 commits

    • 30f89fe9...2525f133 - 12 commits from branch master
    • 746efe52 - feat(bme680): Add BSEC library
    • 329b8e7e - chore(bsec): code style
    • cf33b9b0 - fix(bme680): Use the hw locks
    • eae39783 - fix(bsec): Prevent current time overflow
    • d28baf2b - feat(bsec): Apply default configuration if there is no config file
    • e0b8b645 - fix(bsec): add task handle for debugging in gdb
    • 824e77e8 - chore(bsec): Apply code style
    • 32e126eb - feat(bme680): Act as shim if BSEC is active
    • 411b5eed - feat(bsec): Cleanup.
    • cdbc7b17 - refact(bme680): Use more granular locks. Sleep using FreeRTOS
    • e6c3ba13 - fix(bsec): Reduce stack usage by calling init before stating the task
    • d86cdbb2 - fix(bsec): Reduce stack usage by reusing a buffer
    • 9c350133 - fix(bsec): More accurate statements about stack usage
    • 0c8805a8 - fix(bsec): Enable CO2 and total breath VOC outputs
    • ac2e9776 - fix(bme680): Check for NULL pointer as mentioned in docs
    • 6d7cb771 - fix(bsec): Read CO2 and total breath voc into cache
    • a7241c6e - feat(bsec): Initial BSEC API
    • d1bfa57a - feat(bsec): Add config options
    • 535f2c52 - chore(bsec): Style fixes
    • 634a70d7 - feat(bsec): add option to set a static temperature offset
    • ac5069b8 - feat(ble): Add ESS and Temperature UUIDs
    • 1e25cb76 - feat(ble): Add Evironmental Sensing Service
    • 937fde1a - fix(ess): Show how to update a characteristic without a callback
    • f21ff7aa - chore(ess): Introduce ess.h
    • 0ee33180 - feat(ess): add notification support for temperature
    • a5c837e2 - chore(ess): Code style
    • 8fcd5ee5 - feat(ess): Add humidity characteristic
    • f0395dd2 - fix(ess): Correctly handle negative temperatures
    • 659e9dec - feat(ess): Add pressure characteristic
    • c1da2c2e - chore(ess): Fix c&p comment

    Compare with previous version

  • schneider added 1 commit

    added 1 commit

    Compare with previous version

  • schneider resolved all threads

    resolved all threads

  • schneider changed the description

    changed the description

  • schneider marked this merge request as draft

    marked this merge request as draft

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
Please register or sign in to reply
Loading