Hi Support Team,
I want to use the NCS BME68X IAQ driver on nRF5340 DK, a BME680 sensor was connected on the I2C1 bus.
The BSEC lib has been downloaded and put into NCS SDK. But there is a strange compiling error about the sensor device node, I double-checked and can't find the reason, could you help give some guidance? Thank you very much.
1. the Error info:
c:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: app/libapp.a(bme680test.c.obj): in function `z_impl_sensor_channel_get': C:/ncs/v2.5.2/zephyr/include/zephyr/drivers/sensor.h:767: undefined reference to `__device_dts_ord_139' c:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: app/libapp.a(bme680test.c.obj): in function `bme680_read_channels': C:\02_dataLogger\IOTDL\build\IOTDL/../../src/bme680test.c:67: undefined reference to `__device_dts_ord_139'
2. The DTS overlay:
aliases { gassensor = &bme680; }; &i2c1 { status = "okay"; compatible = "nordic,nrf-twim"; pinctrl-0 = <&i2c1_default>; pinctrl-1 = <&i2c1_sleep>; pinctrl-names = "default", "sleep"; bme680:bme680@77 { compatible = "bosch,bme680"; status = "okay"; reg = <0x77>; }; }; &pinctrl { i2c1_default: i2c1_default { group1 { psels = <NRF_PSEL(TWIM_SDA, 1, 2)>, <NRF_PSEL(TWIM_SCL, 1, 3)>; }; }; i2c1_sleep: i2c1_sleep { group1 { psels = <NRF_PSEL(TWIM_SDA, 1, 2)>, <NRF_PSEL(TWIM_SCL, 1, 3)>; low-power-enable; }; }; };
3. prj.conf:
CONFIG_SENSOR=y CONFIG_BME68X_IAQ=y CONFIG_BME680=n CONFIG_SETTINGS=y CONFIG_SETTINGS_NONE=n
4. my code:
bool ret = false; struct sensor_value temp, press, humidity, gas; const struct device *const dev_I2C = DEVICE_DT_GET(DT_ALIAS(i2c1)); if (!device_is_ready(dev_I2C)) { LOG_WRN("%s: I2C device not ready.", dev_I2C->name); return false; } else { LOG_WRN("%s: I2C device ready.", dev_I2C->name); } const struct device *const dev_gassensor = DEVICE_DT_GET_ANY(bosch_bme680); if (!device_is_ready(dev_gassensor)) { LOG_ERR("%s: gas sensor BME680 not ready.", dev_gassensor->name); return false; } else { LOG_WRN("%s: gas sensor BME680 ready.", dev_gassensor->name); } LOG_INF("Found gas sensor device \"%s\", getting gas sensor data with BSEC", dev_gassensor->name); ret = sensor_sample_fetch(dev_gassensor); ret = sensor_channel_get(dev_gassensor, SENSOR_CHAN_AMBIENT_TEMP, &temp); ret = sensor_channel_get(dev_gassensor, SENSOR_CHAN_PRESS, &press); ret = sensor_channel_get(dev_gassensor, SENSOR_CHAN_HUMIDITY, &humidity); ret = sensor_channel_get(dev_gassensor, SENSOR_CHAN_IAQ, &gas); LOG_INF("BME680 BSEC data- T: %d.%06d; P: %d.%06d; H: %d.%06d; G(IAQ): %d.%06d", temp.val1, temp.val2, press.val1, press.val2, humidity.val1, humidity.val2, gas.val1, gas.val2);
In addition, I checked the generated files devicetree_generated.h, zephyr.dts, the bme680 node (139 /soc/peripheral@50000000/i2c@9000/bme680@77) can be found in these files.
Best regards,
Yanpeng Wu