This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

BME280 code update with nRF9160

Hi,

I have a BME280 sensor running normally with the nRF9160 on v1.2.0 firmware. When I updated the firmware to 1.3.1, I had to update the code to run I updated the files but still getting errors is there any updated version. zephyr v2.3. The code is running on v1.2.0 and zephyr v2.1.

[136/155] Building C object zephyr/drivers/sensor/bme280/CMakeFiles/drivers__sensor__bme280.dir/bme280.c.obj
/home/am/nrfmix/zephyr/drivers/sensor/bme280/bme280.c:31:2: warning: #warning "BME280 driver enabled without any devices" [-Wcpp]
 #warning "BME280 driver enabled without any devices"
  ^~~~~~~
/home/am/nrfmix/zephyr/drivers/sensor/bme280/bme280.c:397:39: warning: 'bme280_api_funcs' defined but not used [-Wunused-const-variable=]
 static const struct sensor_driver_api bme280_api_funcs = {
                                       ^~~~~~~~~~~~~~~~
[148/155] Linking C executable zephyr/zephyr_prebuilt.elf
Memory region         Used Size  Region Size  %age Used
           FLASH:       20440 B       976 KB      2.05%
            SRAM:        4128 B       128 KB      3.15%
        IDT_LIST:          72 B         2 KB      3.52%
[155/155] Generating zephyr/merged_domains.hex

#include <zephyr.h>
#include <device.h>
#include <drivers/sensor.h>

void main(void)
{
	struct device *dev = device_get_binding("BME280");

	if (dev == NULL) {
		printk("Could not get BME280 device\n");
		return;
	}

	printk("dev %p name %s\n", dev, dev->config->name);

	while (1) {
		struct sensor_value temp, press, humidity;

		sensor_sample_fetch(dev);
		sensor_channel_get(dev, SENSOR_CHAN_AMBIENT_TEMP, &temp);
		sensor_channel_get(dev, SENSOR_CHAN_PRESS, &press);
		sensor_channel_get(dev, SENSOR_CHAN_HUMIDITY, &humidity);

		printk("temp: %d.%06d; press: %d.%06d; humidity: %d.%06d\n",
		      temp.val1, temp.val2, press.val1, press.val2,
		      humidity.val1, humidity.val2);

		k_sleep(K_MSEC(1000));
	}
}

&i2c3 {
    compatible = "nordic,nrf-twim";
    status = "ok";
    sda-pin = <30>;
    scl-pin = <31>;
    clock-frequency = <I2C_BITRATE_FAST>;
    bme280@76 {
        compatible = "bosch,bme280";
        reg = <0x76>;
        label = "BME280";
    };
};

CONFIG_STDOUT_CONSOLE=y
CONFIG_I2C=y
CONFIG_SENSOR=y
CONFIG_BME280=y
CONFIG_I2C_3=y
CONFIG_SENSOR_LOG_LEVEL_DBG=y
CONFIG_LOG_IMMEDIATE=y
CONFIG_LOG=y

Parents
  • Hello, 

    Comparing your code to the BME280 sensor sample in Zephyr, I see that you do not have the following configuration:

    #define BME280 DT_INST(0, bosch_bme280)
    
    #if DT_NODE_HAS_STATUS(BME280, okay)
    #define BME280_LABEL DT_LABEL(BME280)
    #else
    #error Your devicetree has no enabled nodes with compatible "bosch,bme280"
    #define BME280_LABEL "<none>"
    #endif

    Please look at the sample and make sure to add the same. 

    Kind regards,
    Øyvind

  • @Oyvind adding this config will cause more errors. The code doesn't run in the more advanced firmware version. That's why I altered the code. If you can run the code. please provide the firmware version since it only run on v1.20.

     


  • Can you please provide the errors you are seeing? Difficult for me to determine what's going on.

  • FAILED: CMakeFiles/app.dir/src/main.c.obj 
    ccache /opt/gnuarmemb/bin/arm-none-eabi-gcc -DBUILD_VERSION=v2.3.0-rc1-ncs2 -DEXT_API_MAGIC=0x281ee6de,0xb845acea,23298 -DFIRMWARE_INFO_MAGIC=0x281ee6de,0x8fcebb4c,23298 -DKERNEL -DNRF9160_XXAA -DNRF_TRUSTZONE_NONSECURE -DUSE_PARTITION_MANAGER=1 -D_FORTIFY_SOURCE=2 -D__PROGRAM_START -D__ZEPHYR__=1 -I/home/am/nrfmix/zephyr/include -Izephyr/include/generated -I/home/am/nrfmix/zephyr/soc/arm/nordic_nrf/nrf91 -I/home/am/nrfmix/nrf/include -I/home/am/nrfmix/modules/hal/cmsis/CMSIS/Core/Include -I/home/am/nrfmix/modules/hal/nordic/nrfx -I/home/am/nrfmix/modules/hal/nordic/nrfx/drivers/include -I/home/am/nrfmix/modules/hal/nordic/nrfx/mdk -I/home/am/nrfmix/modules/hal/nordic/. -isystem /home/am/nrfmix/zephyr/lib/libc/minimal/include -isystem /opt/gnuarmemb/bin/../lib/gcc/arm-none-eabi/8.3.1/include -isystem /opt/gnuarmemb/bin/../lib/gcc/arm-none-eabi/8.3.1/include-fixed -Os -imacros/home/am/nrfmix/zephyr/samples/sensor/bme280/build/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -mcpu=cortex-m33 -mthumb -mabi=aapcs -imacros/home/am/nrfmix/zephyr/include/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wno-unused-but-set-variable -Werror=implicit-int -fno-asynchronous-unwind-tables -fno-pie -fno-pic -fno-strict-overflow -fno-reorder-functions -fno-defer-pop -fmacro-prefix-map=/home/am/nrfmix/zephyr/samples/sensor/bme280=CMAKE_SOURCE_DIR -fmacro-prefix-map=/home/am/nrfmix/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/home/am/nrfmix=WEST_TOPDIR -ffunction-sections -fdata-sections -std=c99 -nostdinc -MD -MT CMakeFiles/app.dir/src/main.c.obj -MF CMakeFiles/app.dir/src/main.c.obj.d -o CMakeFiles/app.dir/src/main.c.obj   -c ../src/main.c
    ../src/main.c:17:2: error: #error Your devicetree has no enabled nodes with compatible "bosch,bme280"
     #error Your devicetree has no enabled nodes with compatible "bosch,bme280"
      ^~~~~
    ninja: build stopped: subcommand failed.
    

Reply
  • FAILED: CMakeFiles/app.dir/src/main.c.obj 
    ccache /opt/gnuarmemb/bin/arm-none-eabi-gcc -DBUILD_VERSION=v2.3.0-rc1-ncs2 -DEXT_API_MAGIC=0x281ee6de,0xb845acea,23298 -DFIRMWARE_INFO_MAGIC=0x281ee6de,0x8fcebb4c,23298 -DKERNEL -DNRF9160_XXAA -DNRF_TRUSTZONE_NONSECURE -DUSE_PARTITION_MANAGER=1 -D_FORTIFY_SOURCE=2 -D__PROGRAM_START -D__ZEPHYR__=1 -I/home/am/nrfmix/zephyr/include -Izephyr/include/generated -I/home/am/nrfmix/zephyr/soc/arm/nordic_nrf/nrf91 -I/home/am/nrfmix/nrf/include -I/home/am/nrfmix/modules/hal/cmsis/CMSIS/Core/Include -I/home/am/nrfmix/modules/hal/nordic/nrfx -I/home/am/nrfmix/modules/hal/nordic/nrfx/drivers/include -I/home/am/nrfmix/modules/hal/nordic/nrfx/mdk -I/home/am/nrfmix/modules/hal/nordic/. -isystem /home/am/nrfmix/zephyr/lib/libc/minimal/include -isystem /opt/gnuarmemb/bin/../lib/gcc/arm-none-eabi/8.3.1/include -isystem /opt/gnuarmemb/bin/../lib/gcc/arm-none-eabi/8.3.1/include-fixed -Os -imacros/home/am/nrfmix/zephyr/samples/sensor/bme280/build/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -mcpu=cortex-m33 -mthumb -mabi=aapcs -imacros/home/am/nrfmix/zephyr/include/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wno-unused-but-set-variable -Werror=implicit-int -fno-asynchronous-unwind-tables -fno-pie -fno-pic -fno-strict-overflow -fno-reorder-functions -fno-defer-pop -fmacro-prefix-map=/home/am/nrfmix/zephyr/samples/sensor/bme280=CMAKE_SOURCE_DIR -fmacro-prefix-map=/home/am/nrfmix/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/home/am/nrfmix=WEST_TOPDIR -ffunction-sections -fdata-sections -std=c99 -nostdinc -MD -MT CMakeFiles/app.dir/src/main.c.obj -MF CMakeFiles/app.dir/src/main.c.obj.d -o CMakeFiles/app.dir/src/main.c.obj   -c ../src/main.c
    ../src/main.c:17:2: error: #error Your devicetree has no enabled nodes with compatible "bosch,bme280"
     #error Your devicetree has no enabled nodes with compatible "bosch,bme280"
      ^~~~~
    ninja: build stopped: subcommand failed.
    

Children
Related