05-11-2020 02:16 PM
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,
Chris
Configuration YAML:
esphome:
name: multisensor_1
platform: ESP32
board: nodemcu-32s
includes:
- 'CE_BSEC.h'
libraries:
- 'BSEC Software Library'
i2c:
sda: 21
scl: 22
scan: True
id: id_i2c
sensor:
## this is the BOSCH Implementation
- platform: custom
lambda: |-
auto IAQSensor = new CE_BSEC();
App.register_component(IAQSensor);
return { IAQSensor->TSensor, IAQSensor->PSensor, IAQSensor->HSensor, IAQSensor->AQSensor };
sensors:
- 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 {
public:
// 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;
TSensor->publish_state(Temp);
float Press = iaqSensor.pressure;
PSensor->publish_state(Press);
float Hum = iaqSensor.humidity;
HSensor->publish_state(Hum);
float Qual = iaqSensor.iaq;
AQSensor->publish_state(Qual);
}
};
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
Solved! Go to Solution.
05-11-2020 03:18 PM
UPDATE:
Compiles successfully after adding
build_flags = -I .piolibdeps/multisensor_1/BSEC\ Software\ Library_ID6979/src/inc -L .piolibdeps/multisensor_1/BSEC\ Software\ Library_ID6979/src/esp32 -lalgobsec
to "platformio.ini" as suggested in another thread here.
Thank you anyways 🙂
Cheers,
Chris
06-03-2020 05:33 PM
I am using the same code with Node MCU /ESP8266 board
While compiling in ESPhome i get the following error
Linking /data/bme680_boshcode/.pioenvs/bme680_boshcode/firmware.elf/root/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: cannot find -lalgobseccollect2: error: ld returned 1 exit status*** [/data/bme680_boshcode/.pioenvs/bme680_boshcode/firmware.elf] Error 1========================== [FAILED] Took 2.15 seconds ==========================
how do I resolve?
06-04-2020 05:21 PM
It seems that your are using a different board (ESP8266) than above (ESP32), so you may want to create your own topic/thread.
We would probably need more information to debug your issue, for example your custom build_flags and confirm that your paths are valid (your could check this other thread too), a log of your compiler/linker command, etc. Note that in Arduino, there are extra changes that need to be applied to the file eagle.app.v6.common.ld.h in the ESP8266 SDK as described here, since we are not familiar with PlatformIO I don't know if this applies to your tools.
06-24-2020 11:26 AM
Hello,
Thanks for the tips with it i am able to compile. However i not able to get value with the custom component this is my log :
[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
I dont understand why i change the i2c_adress to 0x76, and my BME680 is working if i use the platform BME680.
Do you have any idea ?
Regards,