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

  • Thank you for the update. I am happy to hear it is working now.

  • Hello Helsing,
    thank you very much 
    i'm recently having an issue with the display of the values of the BME280
    well it's displaying this error when the sensor is connected to the Kit

    and it's displaying this error with the other address when it's not connected

    Knowing that : 

    0x0BAD0001 means "Internal Error" in the I2C driver.

    0x0BAE0001 means "Address not acknowledged" in the I2C driver.
    and doubting that the issue is hardware that leads me to believe that the issue may be with how the sensor is wired to the board, or setup in some way, causing an error in the driver.


    for me i did the wiring like this 

    P1.02 to SDI
    P1.03 to SCK
    GND to SDO
    GND to GND
    Vin 3-5v to VIN

    is there a pre-config to do or some settings to fix before running the sensor ?

    can you please help me with the wiring 
    knowing that you already tried the sensor, how did it go with you please ?
    can you help me please 
    i would be very grateful

  • the final answer for the display of this problem was related to the voltage 
    try to double check with a voltage meter that the input voltage is 3V
    Find a pin labeled "VDD", and try that if you measure it to be 3.3V.
    in this case the needed voltage is 3.3V
    make sure your pins wiring is good 

Related