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

BME280 with NRF5340 display (T,P,H) problem

Hello everybody,

I'm having a problem to display the temperature, pressure and humidity.

i followed this tutorial on a NRF5340 https://devzone.nordicsemi.com/nordic/b/archives/posts/nrf-connect-sdk-tutorial---part-3-temporary

in my case i'm using SES V5.34a avec NRF Connect v3.7.0 with NRF SDK V1.5.1

i'm working with BME280 adafruit! (3-5)voltage

below is my nrf5340dk_nrf5340_cpuapp.overlay

as the scl pin is on P1.03 and the sda is on P1.02

&i2c1 {
    compatible = "nordic,nrf-twim";
	status = "okay";
	sda-pin = < 34-32 >;
	scl-pin = < 34-31 >;
    clock-frequency = <100000>;  
	
	/* The I2C address could be one of two, here 0x76 is assumed */
	bme280@76 {
		compatible = "bosch,bme280";
		reg = <0x76>;
		label = "BME280";
	};
};

&uart1 {
    status = "disabled";
};

and my prj.conf is below

CONFIG_SENSOR=y
CONFIG_BME280=y
CONFIG_I2C_1=y

and for the main.c i useed the code linked on the nfr/samples/sensor/bme280

/*
 * Copyright (c) 2012-2014 Wind River Systems, Inc.
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#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)
{
	const 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));
	}
}

my build is going well on SES and it's successful but when i try west flash from bash or Cmd prompt i'm always getting errors 

C:\Users\rzaafouri\ncs\v1.5.1\nrf\samples\sensor\bme280>west flash
-- west flash: rebuilding
[0/1] Re-running CMake...
Including boilerplate (Zephyr base (cached)): C:/Users/rzaafouri/ncs/v1.5.1/zephyr/cmake/app/boilerplate.cmake
-- Application: C:/Users/rzaafouri/ncs/v1.5.1/nrf/samples/sensor/bme280
-- Using NCS Toolchain 1.6.0 for building. (C:/Users/rzaafouri/ncs/v1.6.0/toolchain/cmake)
-- Zephyr version: 2.4.99 (C:/Users/rzaafouri/ncs/v1.5.1/zephyr)
-- Found west (found suitable version "0.11.0", minimum required is "0.7.1")
-- Board: nrf5340dk_nrf5340_cpuapp
-- Cache files will be written to: C:/Users/rzaafouri/ncs/v1.5.1/zephyr/.cache
-- Found dtc: C:/Users/rzaafouri/ncs/v1.6.0/toolchain/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")
-- Found toolchain: gnuarmemb (C:/Users/rzaafouri/ncs/v1.6.0/toolchain/opt)
-- Found BOARD.dts: C:/Users/rzaafouri/ncs/v1.5.1/zephyr/boards/arm/nrf5340dk_nrf5340/nrf5340dk_nrf5340_cpuapp.dts
-- Found devicetree overlay: C:/Users/rzaafouri/ncs/v1.5.1/nrf/samples/sensor/bme280/boards/nrf5340dk_nrf5340_cpuapp.overlay
Error: nrf5340dk_nrf5340_cpuapp.dts.pre.tmp:698.16-17 syntax error
FATAL ERROR: Unable to parse input tree
CMake Error at C:/Users/rzaafouri/ncs/v1.5.1/zephyr/cmake/dts.cmake:205 (message):
  command failed with return code: 1
Call Stack (most recent call first):
  C:/Users/rzaafouri/ncs/v1.5.1/zephyr/cmake/app/boilerplate.cmake:533 (include)
  C:/Users/rzaafouri/ncs/v1.5.1/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
  C:/Users/rzaafouri/ncs/v1.5.1/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:40 (include_boilerplate)
  CMakeLists.txt:4 (find_package)


-- Configuring incomplete, errors occurred!
See also "C:/Users/rzaafouri/ncs/v1.5.1/nrf/samples/sensor/bme280/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/rzaafouri/ncs/v1.5.1/nrf/samples/sensor/bme280/build/CMakeFiles/CMakeError.log".
FAILED: build.ninja
C:\Users\rzaafouri\ncs\v1.5.1\toolchain\opt\bin\cmake.exe --regenerate-during-build -SC:\Users\rzaafouri\ncs\v1.5.1\nrf\samples\sensor\bme280 -BC:\Users\rzaafouri\ncs\v1.5.1\nrf\samples\sensor\bme280\build
ninja: error: rebuilding 'build.ninja': subcommand failed
FATAL ERROR: re-build in C:\Users\rzaafouri\ncs\v1.5.1\nrf\samples\sensor\bme280\build failed (no --build-dir given)

could you please help me solve my problem and be able to get returned values of my sensor bme280

or if you see that i have something wrong with my configuration, don't hesitate to tell . 
i will really appreciate your help and contribution 

thank you in advance

Parents
  • Hi Rihab,

    What does your config file currently look like? Have you tried using these four configs at the same time?

    CONFIG_SENSOR=y
    CONFIG_BME280=y
    CONFIG_I2C=y
    CONFIG_I2C_1=y
    When using these configs, I can read this in the terminal:
    *** Booting Zephyr OS build v2.4.99-ncs2  ***

    Found device "BME280"
    This happens even though I do not have any sensor connected at the moment.
  • Hi Helsing i'm having another problem .i think it's a processing error i think because i have with all of the projects 


    do you have an idea what does it refers to ?

    1> C:\Users\rzaafouri\ncs\v1.5.1-rc1\toolchain\opt/bin/arm-none-eabi-gcc -DBUILD_VERSION=v2.4.99-ncs2 -DKERNEL -DNRF5340_XXAA_APPLICATION -DUSE_PARTITION_MANAGER=0 -D_FORTIFY_SOURCE=2 -D__PROGRAM_START -D__ZEPHYR__=1 -I../../../kernel/include -I../../../arch/arm/include -I../../../include -Izephyr/include/generated -I../../../soc/arm/nordic_nrf/nrf53 -IC:/Users/rzaafouri/ncs/v1.5.1/nrf/include -IC:/Users/rzaafouri/ncs/v1.5.1/modules/hal/nordic/nrfx -IC:/Users/rzaafouri/ncs/v1.5.1/modules/hal/nordic/nrfx/drivers/include -IC:/Users/rzaafouri/ncs/v1.5.1/modules/hal/nordic/nrfx/mdk -I../../../modules/hal_nordic/nrfx/. -IC:/Users/rzaafouri/ncs/v1.5.1/modules/hal/cmsis/CMSIS/Core/Include -isystem ../../../lib/libc/minimal/include -isystem c:/users/rzaafouri/ncs/v1.5.1/toolchain/opt/bin/../lib/gcc/arm-none-eabi/9.2.1/include -isystem c:/users/rzaafouri/ncs/v1.5.1/toolchain/opt/bin/../lib/gcc/arm-none-eabi/9.2.1/include-fixed -isystem C:/Users/rzaafouri/ncs/v1.5.1/nrfxlib/crypto/nrf_cc312_platform/include -Os -imacros C:/Users/rzaafouri/ncs/v1.5.1/zephyr/samples/hello_world/build_nrf5340dk_nrf5340_cpuapp/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -mcpu=cortex-m33 -mthumb -mabi=aapcs -imacros C:/Users/rzaafouri/ncs/v1.5.1/zephyr/include/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wno-address-of-packed-member -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=C:/Users/rzaafouri/ncs/v1.5.1/zephyr/samples/hello_world=CMAKE_SOURCE_DIR -fmacro-prefix-map=C:/Users/rzaafouri/ncs/v1.5.1/zephyr=ZEPHYR_BASE -fmacro-prefix-map=C:/Users/rzaafouri/ncs/v1.5.1=WEST_TOPDIR -ffunction-sections -fdata-sections -std=c99 -nostdinc -MD -MF C:/Users/rzaafouri/ncs/v1.5.1/zephyr/samples/hello_world/build_nrf5340dk_nrf5340_cpuapp/zephyr\CMakeFiles\offsets.dir\arch\arm\core\offsets\offsets.c.obj.d -fno-diagnostics-show-caret -o zephyr/CMakeFiles/offsets.dir/arch/arm/core/offsets/offsets.c.obj -c C:/Users/rzaafouri/ncs/v1.5.1/zephyr/arch/arm/core/offsets/offsets.c
    1> In file included from ../../../include/arch/arm/aarch32/arch.h:20,
    1>                  from ../../../include/arch/cpu.h:19,
    1>                  from ../../../include/kernel_includes.h:33,
    1>                  from ../../../include/kernel.h:17,
    1>                  from C:/Users/rzaafouri/ncs/v1.5.1/zephyr/arch/arm/core/offsets/offsets_aarch32.c:28,
    1>                  from C:/Users/rzaafouri/ncs/v1.5.1/zephyr/arch/arm/core/offsets/offsets.c:12:
    1> ../../../include/arch/arm/aarch32/cortex_m/nvic.h:15:21: warning: implicit declaration of function 'DT_INST' [-Wimplicit-function-declaration]
    1> ../../../include/devicetree.h:2176:24: note: in definition of macro 'DT_CAT'
    1> ../../../include/arch/arm/aarch32/cortex_m/nvic.h:22:27: note: in expansion of macro 'DT_PROP'
    1> ../../../include/arch/arm/aarch32/cortex_m/nvic.h:22:35: note: in expansion of macro 'NVIC_NODEID'
    1> ../../../include/arch/arm/aarch32/exc.h:24:41: note: in expansion of macro 'NUM_IRQ_PRIO_BITS'
    1> ../../../include/arch/arm/aarch32/exc.h:60:31: note: in expansion of macro 'Z_EXC_PRIO'
    1> ../../../include/arch/arm/aarch32/asm_inline_gcc.h:62:9: note: in expansion of macro '_EXC_IRQ_DEFAULT_PRIO'
    1> ../../../include/arch/arm/aarch32/cortex_m/nvic.h:15:44: error: pasting ")" and "_P_arm_num_irq_priority_bits" does not give a valid preprocessing token
    1> ../../../include/devicetree.h:2176:24: note: in definition of macro 'DT_CAT'
    1> ../../../include/arch/arm/aarch32/cortex_m/nvic.h:22:27: note: in expansion of macro 'DT_PROP'
    1> ../../../include/arch/arm/aarch32/cortex_m/nvic.h:22:35: note: in expansion of macro 'NVIC_NODEID'
    1> ../../../include/arch/arm/aarch32/exc.h:24:41: note: in expansion of macro 'NUM_IRQ_PRIO_BITS'
    1> ../../../include/arch/arm/aarch32/exc.h:60:31: note: in expansion of macro 'Z_EXC_PRIO'
    1> ../../../include/arch/arm/aarch32/asm_inline_gcc.h:62:9: note: in expansion of macro '_EXC_IRQ_DEFAULT_PRIO'
    1> ../../../include/arch/arm/aarch32/cortex_m/nvic.h:15:32: error: 'arm_v8m_nvic' undeclared (first use in this function)
    1> ../../../include/devicetree.h:2176:24: note: in definition of macro 'DT_CAT'
    1> ../../../include/arch/arm/aarch32/cortex_m/nvic.h:22:27: note: in expansion of macro 'DT_PROP'
    1> ../../../include/arch/arm/aarch32/cortex_m/nvic.h:22:35: note: in expansion of macro 'NVIC_NODEID'
    1> ../../../include/arch/arm/aarch32/exc.h:24:41: note: in expansion of macro 'NUM_IRQ_PRIO_BITS'
    1> ../../../include/arch/arm/aarch32/exc.h:60:31: note: in expansion of macro 'Z_EXC_PRIO'
    1> ../../../include/arch/arm/aarch32/asm_inline_gcc.h:62:9: note: in expansion of macro '_EXC_IRQ_DEFAULT_PRIO'
    1> ../../../include/arch/arm/aarch32/cortex_m/nvic.h:15:32: note: each undeclared identifier is reported only once for each function it appears in
    1> ../../../include/devicetree.h:2176:24: note: in definition of macro 'DT_CAT'
    1> ../../../include/arch/arm/aarch32/cortex_m/nvic.h:22:27: note: in expansion of macro 'DT_PROP'
    1> ../../../include/arch/arm/aarch32/cortex_m/nvic.h:22:35: note: in expansion of macro 'NVIC_NODEID'
    1> ../../../include/arch/arm/aarch32/exc.h:24:41: note: in expansion of macro 'NUM_IRQ_PRIO_BITS'
    1> ../../../include/arch/arm/aarch32/exc.h:60:31: note: in expansion of macro 'Z_EXC_PRIO'
    1> ../../../include/arch/arm/aarch32/asm_inline_gcc.h:62:9: note: in expansion of macro '_EXC_IRQ_DEFAULT_PRIO'
    1> ../../../include/devicetree.h:463:48: error: expected ')' before '_P_arm_num_irq_priority_bits'
    1> ../../../include/devicetree.h:2176:30: note: in definition of macro 'DT_CAT'
    1> ../../../include/arch/arm/aarch32/cortex_m/nvic.h:22:27: note: in expansion of macro 'DT_PROP'
    1> ../../../include/arch/arm/aarch32/exc.h:24:41: note: in expansion of macro 'NUM_IRQ_PRIO_BITS'
    1> ../../../include/arch/arm/aarch32/exc.h:60:31: note: in expansion of macro 'Z_EXC_PRIO'
    1> ../../../include/arch/arm/aarch32/asm_inline_gcc.h:62:9: note: in expansion of macro '_EXC_IRQ_DEFAULT_PRIO'
    1> In file included from ../../../include/arch/arm/aarch32/arch.h:26,
    1>                  from ../../../include/arch/cpu.h:19,
    1>                  from ../../../include/kernel_includes.h:33,
    1>                  from ../../../include/kernel.h:17,
    1>                  from C:/Users/rzaafouri/ncs/v1.5.1/zephyr/arch/arm/core/offsets/offsets_aarch32.c:28,
    1>                  from C:/Users/rzaafouri/ncs/v1.5.1/zephyr/arch/arm/core/offsets/offsets.c:12:
    1> ../../../include/arch/arm/aarch32/exc.h:24:36: note: to match this '('
    1> ../../../include/arch/arm/aarch32/exc.h:60:31: note: in expansion of macro 'Z_EXC_PRIO'
    1> ../../../include/arch/arm/aarch32/asm_inline_gcc.h:62:9: note: in expansion of macro '_EXC_IRQ_DEFAULT_PRIO'
    1> In file included from ../../../include/arch/arm/aarch32/arch.h:20,
    1>                  from ../../../include/arch/cpu.h:19,
    1>                  from ../../../include/kernel_includes.h:33,
    1>                  from ../../../include/kernel.h:17,
    1>                  from C:/Users/rzaafouri/ncs/v1.5.1/zephyr/arch/arm/core/offsets/offsets_aarch32.c:28,
    1>                  from C:/Users/rzaafouri/ncs/v1.5.1/zephyr/arch/arm/core/offsets/offsets.c:12:
    1> ../../../include/arch/arm/aarch32/cortex_m/nvic.h:15:28: error: missing binary operator before token "("
    1> ../../../include/devicetree.h:2176:24: note: in definition of macro 'DT_CAT'
    1> ../../../include/arch/arm/aarch32/cortex_m/nvic.h:22:27: note: in expansion of macro 'DT_PROP'
    1> ../../../include/arch/arm/aarch32/cortex_m/nvic.h:22:35: note: in expansion of macro 'NVIC_NODEID'
    1> ../../../include/arch/arm/aarch32/cortex_m/cmsis.h:96:25: note: in expansion of macro 'NUM_IRQ_PRIO_BITS'
    Build failed

  • When did this start appearing? What do you do in order for this to appear. Do you remember any recent changes you made?

    I am not familiar with this, though it looks like something that would need to be fixed. I suggest you create a new ticket, and someone else from our team will be assigned to the task.

Reply Children
  • i just tried to create another project but from another directory this time 
    i think i broke something in the processing operation 
    but the thing is that in my project BME280


    the DT_NODE_HAS_STATUS function became grey 
    and the other one appeared 
    so i think even by correcting this error 
    i will get the classic error of "devicetree has no enabled nodes"

    i don't know what to do actually, i tried alot of methods but the error doesn't go  

    do you recommend some team members that can help me 
    i'm really stuck and it's getting complicated

Related