Bosch Sensortec Community

    Showing results for 
    Search instead for 
    Did you mean: 

    BME680 on ESPHome using Bosch's BSEC library

    BME680 on ESPHome using Bosch's BSEC library

    Occasional Visitor

    Dear all,

    I am trying to integrate a Bosch BME680 sensor running on the precompiled, closed source "BSEC" library as a custom sensor for ESPHome for an ESP32 for getting an IAQ reading instead of the resistance reading only. In other words, I do not want to use the ESPHome-driver for the sensor but the precompiled Bosch BSEC library wrapped in a custom ESPHome sensor component.

    However, I cannot get ESPHome to compile/link the libraries correctly. What am I missing here?

    Thank you very much for getting me kickstarted with with the precompiled library on ESPHome.

    Best regards,



    Configuration YAML:

      name: multisensor_1
      platform: ESP32 
      board: nodemcu-32s
        - 'CE_BSEC.h'
        - 'BSEC Software Library'
      sda: 21
      scl: 22
      scan: True
      id: id_i2c
    ## this is the BOSCH Implementation
      - platform: custom
        lambda: |-
          auto IAQSensor = new CE_BSEC();
          return { IAQSensor->TSensor, IAQSensor->PSensor, IAQSensor->HSensor, IAQSensor->AQSensor };
        -  name: "BME680 Temperature"
           unit_of_measurement: 'V'
           accuracy_decimals: 1
        -  name: "BME680 Pressure"
           unit_of_measurement: 'hPa'
           accuracy_decimals: 1
        -  name: "BME680 relative Humidity"
           unit_of_measurement: '%'
           accuracy_decimals: 1
        -  name: "BME680 IAQ"
           accuracy_decimals: 1


    Custom sensor CE_BSEC.h

    #include "esphome.h"
    #include "bsec.h"
    class CE_BSEC : public PollingComponent, public Sensor {
      // constructor
      Bsec iaqSensor;
      Sensor *TSensor = new Sensor();
      Sensor *PSensor = new Sensor();
      Sensor *HSensor = new Sensor();
      Sensor *AQSensor = new Sensor();
      CE_BSEC() : PollingComponent(60000) { }
      void setup() override {
        // This will be called by App.setup()
        iaqSensor.begin(0x77, Wire);
      void update() override {
        float Temp = iaqSensor.temperature;
        float Press = iaqSensor.pressure;
        float Hum = iaqSensor.humidity;
        float Qual = iaqSensor.iaq;


    Compiling .pioenvs/multisensor_1/src/main.cpp.o
    Linking .pioenvs/multisensor_1/firmware.elf
    .pioenvs/multisensor_1/lib0fa/libBSEC Software Library_ID6979.a(bsec.cpp.o):(.literal._ZN4Bsec11beginCommonEv+0x4): undefined reference to `bsec_init'
    .pioenvs/multisensor_1/lib0fa/libBSEC Software Library_ID6979.a(bsec.cpp.o):(.literal._ZN4Bsec11beginCommonEv+0x8): undefined reference to `bsec_get_version'
    .pioenvs/multisensor_1/lib0fa/libBSEC Software Library_ID6979.a(bsec.cpp.o): In function `Bsec::beginCommon()':
    /config/multisensor_1/.piolibdeps/multisensor_1/BSEC Software Library_ID6979/src/bsec.cpp:257: undefined reference to `bsec_init'
    .pioenvs/multisensor_1/lib0fa/libBSEC Software Library_ID6979.a(bsec.cpp.o): In function `Bsec::getVersion()':
    /config/multisensor_1/.piolibdeps/multisensor_1/BSEC Software Library_ID6979/src/bsec.cpp:257: undefined reference to `bsec_get_version'
    collect2: error: ld returned 1 exit status
    *** [.pioenvs/multisensor_1/firmware.elf] Error 1


    18 REPLIES 18

    Community Moderator
    Community Moderator

    @KKox_ wrote:
    [11:21:00][V][sensor:013]: 'BME680 Temperature': Received new state 0.000000
    [11:21:00][D][sensor:092]: 'BME680 Temperature': Sending state 0.00000 V with 1 decimals of accuracy
    [11:21:00][VV][api.service:120]: send_sensor_state_response: SensorStateResponse {  key: 3640870636  state: 0  missing_state: NO}
    [11:21:00][V][sensor:013]: 'BME680 Pressure': Received new state 0.000000
    [11:21:00][D][sensor:092]: 'BME680 Pressure': Sending state 0.00000 hPa with 1 decimals of accuracy
    [11:21:00][VV][api.service:120]: send_sensor_state_response: SensorStateResponse {  key: 1365279611  state: 0  missing_state: NO}
    [11:21:00][V][sensor:013]: 'BME680 relative Humidity': Received new state 0.000000
    [11:21:00][D][sensor:092]: 'BME680 relative Humidity': Sending state 0.00000 % with 1 decimals of accuracy
    [11:21:00][VV][api.service:120]: send_sensor_state_response: SensorStateResponse {  key: 1973480034  state: 0  missing_state: NO}
    [11:21:00][V][sensor:013]: 'BME680 IAQ': Received new state 0.000000
    [11:21:00][D][sensor:092]: 'BME680 IAQ': Sending state 0.00000  with 1 decimals of accuracy
    [11:21:00][VV][api.service:120]: send_sensor_state_response: SensorStateResponse {  key: 2104753181  state: 0  missing_state: NO

    From your description it isn't clear if you are not able to get proper data from the BME680 or from BSEC, or if the issue comes from something else in your project or platform setup.

    @KKox_ wrote:

     I dont understand why i change the i2c_adress to 0x76, and my BME680 is working if i use the platform BME680.

    I cannot comment about your platform/project, but I can try to clarify the I²C address behavior of the BME680. In I²C mode, the BME680's slave address can take two values: 0x76 or 0x77. The selection is made in hardware, and is based on the value on the SDO pin of the BME680, which must be tied directly to GND or VDDIO:

    • if SDO is tied to GND, the BME680 slave address will be 0x76,
    • if SDO is tied to VDDIO, the BME680 slave address will be 0x77.

    Since the slave address of the BME680 is defined by your hardware connections, you must typically manually inform your software about the decision made and expected address.

    Sorry my explanation was not clear.

    I can get data from my BME680 with ESPhome BME680 default script by defining my BME on 0x76. But using the custom script of this thread i can no get any data. I modify 0x77 by 0x76 but nothing is collected and i dont understand why.. so i tired to get some help from here!



    Just a quick update to let you know that it as not a compilation problem or I2C adresses.

    It is actually working with esphome, i just do the config file by myself i was unable to use expample script from this thread.

    Screenshot_2020-07-08 Aperçu - Home Assistant.png

    I just get a lower  relative humidity (33%) than my xiaomi sensor (37.69%) in the same room, but trends are always the same!

    Thanks for help!



    Occasional Visitor


    were you able to solve this problem of always getting "Sending state 0.00000" ?

    I managed to compile esphome with the BSEC library. However I always get 0 values. Any help is much appriciated. I dont see other issues from the logs.


    I have to custom the main.cpp  before compiling to get values. Its not a problem with BSEC Library but with ESPHOME.