Open MingyaoLiu opened 1 year ago
Hi @MingyaoLiu to initialize correctly the bsec2 and bme688 device you need to execute the next code:
#include "bsec2.h"
static i2c_t i2c;
static bsec2_t bsec2;
void app_main(void) {
/* I2C parameters to configure the BME68x device */
i2c.i2c_conf.mode = I2C_MODE_MASTER;
i2c.i2c_conf.sda_io_num = GPIO_NUM_18;
i2c.i2c_conf.scl_io_num = GPIO_NUM_19;
i2c.i2c_conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
i2c.i2c_conf.scl_pullup_en = GPIO_PULLUP_ENABLE;
i2c.i2c_conf.master.clk_speed = 400000;
i2c.i2c_addr = BME68X_I2C_ADDR_LOW;
i2c.i2c_num = I2C_NUM_0;
/* Initialize the library and interfaces */
if (!bsec2_init(&bsec2, (void *)&i2c, BME68X_I2C_INTF)) {
bsec_check_status(&bsec2);
}
/* Check the version of BSEC */
ESP_LOGI(TAG,"\bBSEC library version %d.%d.%d.%d", bsec2.version.major, bsec2.version.minor, bsec2.version.major_bugfix, bsec2.version.minor_bugfix);
}
The i2c_t
variable must be global and you can change the I2C GPIOS pins.
Something important is that BSEC does not support ESP32-C6, for now they only have the precompiled library for ESP32, ESP32-S2, ESP32-S3 and ESP32-C3. You can check it in https://github.com/boschsensortec/Bosch-BSEC2-Library
I see, I will test on esp32c3 for now, and see if I can get it working. Thanks for the help
@mauriciobarroso may I ask a really stupid question? What's the difference between the bme68x_lib and bsec2 lib? I can see bsec2 lib is based on bme68x_lib, but do I have to use the bsec2 lib? Is it possible to just use bme68x_lib to get readings off sensor? Is IAQ something only possible with the bsec2 lib?
Hi @MingyaoLiu, bme68x_lib is the libraty to interact with the physical sensor while bsec2 is the library to perform IA algoritms based on the bme688 raw data. If you only need the raw data from bme688 (temperature, humidity, pressure and gas resistance) you can use the bme688_lib, but if you need more relevant data (IAQ, VOC, CO2 and gas selectivity) you must use the bsec2 library. In my opinion, the only reason I would buy the bme688 is to use the BSEC2 library, in any other case I would buy any other cheaper sensor.
Hello, I just got a BME688 and a ESP32C6 wroom board, so I'm using the latest master on esp-idf to have support for esp32c6. I tried to do something like this in app main:
Then in the task I'm doing requestion data from bme688 with:
but im getting I2C error, so I looked into the I2C stuff and it seems to using the wrong i2c number and/or i2c address?
Sorry my code is super messy, I'm quite new to the esp-idf stuff and also bme688, so everything seems quite difficult for me, I wonder if you can point me in the right direction on how to properly use this? Thanks