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 Reply Children
No Data
Related