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
  • I see that the error occurs after the overlay file, nrf5340dk_nrf5340_cpuapp.overlay, has been processed(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"

    If you check the build folder and open the file nrf5340dk_nrf5340_cpuapp.dts.pre.tmp and scroll down to line 698 you should find the syntax error causing this message.

  • i changed the pins numbers and i tried again always the same output 

    *** Booting Zephyr OS build v2.4.99-ncs2 ***
    No device "BME280" found; did initialization fail? "

    and the line 698 in the nrf5340dk_nrf5340_cpuapp.dts.pre.tmp is the line 8 below and so on 
    i think it's blocked on pins level 
    i don't know what can be causing this output ?? 

    *
    *
    *
    *
    &i2c1 {
        compatible = "nordic,nrf-twim";
     status = "okay";
     sda-pin = < 34 >;
     scl-pin = < 35 >;
        clock-frequency = <100000>;
     bme280@76 {
      compatible = "bosch,bme280";
      reg = <0x76>;
      label = "BME280";
     };
    };
    &uart1 {
        status = "disabled";
    };

  • Thank you for the updates.

    Do you have any tools available for checking whether there is any activity on the I2C lines? Do you see anything now?

    Anyways, here is something to try. Try adding the following to prj.conf:

    CONFIG_I2C=y

    I see others adding this line too, though I have not yet checked whether it is necessary or not:
    CONFIG_SENSOR=y

  • tools like what ? 
    how can i check the activity on i2c ?

Reply Children
No Data
Related