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

BME280 error "#error Your devicetree has no enabled nodes with compatible "bosch,bme280""

Hi,

This is the second time posting this issue. Using nRF9160 dk with nRF Connect SDK v1.3.1 with zepyhr v2.3.0-rc1-ncs2. I tried the BME280 sample from zephyr which gives an error. I also looked into all the posts regarding it and followed the Walkthrough for BME280. 

Main.c

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

#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

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

	if (dev == NULL) {
		printk("No device \"%s\" found; did initialization fail?\n",
		       BME280_LABEL);
		return;
	} else {
		printk("Found device \"%s\"\n", BME280_LABEL);
	}

	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));
	}
}

overlay

&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";
    };
};


prj.confg
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

kconfig
# Copyright (c) 2020, Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

config LOG
	default y

config LOG_PRINTK
	default y

config SENSOR_LOG_LEVEL
	default 4

# Workaround for not being able to have commas in macro arguments
DT_COMPAT_BOSCH_BME280 := bosch,bme280

# Enable SPI support by default if there are any BME280 sensors
# on a SPI bus.
config SPI
	default $(dt_compat_on_bus,$(DT_COMPAT_BOSCH_BME280),spi)

# Enable I2C support by default if there are any BME280 sensors
# on an I2C bus.
config I2C
	default $(dt_compat_on_bus,$(DT_COMPAT_BOSCH_BME280),i2c)

source "Kconfig.zephyr"


When building I get  "/src/main.c:17:2: error: #error Your devicetree has no enabled nodes with compatible "bosch,bme280".  When I update the code and remove the error I get this 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 = {

I already tried the BME280 sensor with older version and it is working fine. 

Parents
  • Hello Ahmed,

    Is there any particular reason why you added the bme280 to i2c3? It is disabled by default for the nRF9160 since it uses the same memory instantiation as SPI3, which is enabled by default. You could add the sensor to i2c2 instead or otherwise you have to disable spi3 in the overlay file as well.

    Additionally, I have noticed that the status in your overlay file says “ok”, but it has to be “okay” instead.

    I hope this will help you!

    Regards,

    Markus

  • Hello Markus,

    Thanks for the response. Followed your advice and changed the overlay file but that did not change anything same warning and the device chip can not be found. I tried updating the bme.c lib but no luck till now. As I mentioned the code and sensor works on older version but not the version I mentioned above. Let me know if you have any more idea or ways to fix it.

    /"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 = {

    Regards.

    Ahmed 

Reply
  • Hello Markus,

    Thanks for the response. Followed your advice and changed the overlay file but that did not change anything same warning and the device chip can not be found. I tried updating the bme.c lib but no luck till now. As I mentioned the code and sensor works on older version but not the version I mentioned above. Let me know if you have any more idea or ways to fix it.

    /"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 = {

    Regards.

    Ahmed 

Children
No Data
Related