Skip to content

Commit

Permalink
samples: sensor: bme680: Extend upstream sample
Browse files Browse the repository at this point in the history
Add sample that reuses source code from "original" sample that
existing in the upstream Zephyr.

Extend sample with configurations that rely on internal
shields pca63565 and pca63566.

Remove Twister alt-config for upstream sample.

Signed-off-by: Sebastian Głąb <[email protected]>
  • Loading branch information
nordic-segl committed Feb 28, 2025
1 parent 7e02f62 commit 3dadda7
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@
/samples/nrf_rpc/ @nrfconnect/ncs-si-muffin
/samples/sensor/accel_polling/ @nrfconnect/ncs-low-level-test
/samples/sensor/bh1749/ @nrfconnect/ncs-cia
/samples/sensor/bme680/ @nrfconnect/ncs-low-level-test
/samples/sensor/bme68x_iaq/ @nrfconnect/ncs-cia
/samples/sensor/qdec/ @nrfconnect/ncs-low-level-test
/samples/subsys/settings/ @nrfconnect/ncs-low-level-test
Expand Down Expand Up @@ -705,7 +706,6 @@
/scripts/partition_manager/*.rst @nrfconnect/ncs-aurora-doc
/scripts/shell/ble_console/**/*.rst @nrfconnect/ncs-doc-leads
/scripts/west_commands/sbom/*.rst @nrfconnect/ncs-si-muffin-doc
/scripts/twister/alt/zephyr/samples/sensor/ @nrfconnect/ncs-low-level-test
/scripts/twister/alt/zephyr/tests/drivers/ @nrfconnect/ncs-low-level-test

# Share
Expand Down
12 changes: 12 additions & 0 deletions samples/sensor/bme680/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
# Copyright (c) 2018 Bosch Sensortec GmbH
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

cmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(bme680)

FILE(GLOB app_sources src/*.c)
target_sources(app PRIVATE ${app_sources})
3 changes: 3 additions & 0 deletions samples/sensor/bme680/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This sample extends the same-named Zephyr sample to verify it with Nordic development kits.

Source code and basic configuration files can be found in the corresponding folder structure in zephyr/samples/sensor/bme680.
3 changes: 3 additions & 0 deletions samples/sensor/bme680/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CONFIG_STDOUT_CONSOLE=y
CONFIG_I2C=y
CONFIG_SENSOR=y
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ common:
- drivers
- i2c
- sensors
- ci_samples_sensor
- ci_samples_sensor_bme680
harness: console

tests:
sample.sensor.bme680.nrf54h:
nrf.extended.sample.sensor.bme680.nrf54h:
filter: not CONFIG_COVERAGE
harness_config:
fixture: pca63566
Expand All @@ -21,7 +23,7 @@ tests:
- SHIELD=pca63566
platform_allow: nrf54h20dk/nrf54h20/cpuapp

sample.sensor.bme680.nrf54h_cpuppr:
nrf.extended.sample.sensor.bme680.nrf54h_cpuppr:
filter: not CONFIG_COVERAGE
sysbuild: true
harness_config:
Expand All @@ -35,7 +37,7 @@ tests:
- vpr_launcher_SHIELD=pca63566_fwd
platform_allow: nrf54h20dk/nrf54h20/cpuppr

sample.sensor.bme680.nrf54h_coverage:
nrf.extended.sample.sensor.bme680.nrf54h_coverage:
filter: CONFIG_COVERAGE
harness_config:
fixture: pca63566
Expand All @@ -47,7 +49,7 @@ tests:
- SHIELD=pca63566;coverage_support
platform_allow: nrf54h20dk/nrf54h20/cpuapp

sample.sensor.bme680.nrf54l:
nrf.extended.sample.sensor.bme680.nrf54l:
filter: not CONFIG_COVERAGE
harness_config:
fixture: pca63565
Expand All @@ -59,7 +61,7 @@ tests:
- SHIELD=pca63565
platform_allow: nrf54l15dk/nrf54l15/cpuapp

sample.sensor.bme680.nrf54l_coverage:
nrf.extended.sample.sensor.bme680.nrf54l_coverage:
filter: CONFIG_COVERAGE
harness_config:
fixture: pca63565
Expand All @@ -71,7 +73,7 @@ tests:
- SHIELD=pca63565;coverage_support
platform_allow: nrf54l15dk/nrf54l15/cpuapp

sample.sensor.bme680.nrf54l_cpuflpr:
nrf.extended.sample.sensor.bme680.nrf54l_cpuflpr:
filter: not CONFIG_COVERAGE
sysbuild: true
harness_config:
Expand All @@ -82,5 +84,5 @@ tests:
.]*$"
extra_args:
- SHIELD=pca63565
- vpr_launcher_DTC_OVERLAY_FILE="../../../../nrf/boards/shields/pca63565/boards/nrf54l15dk_nrf54l15_vpr_launcher.overlay"
- vpr_launcher_DTC_OVERLAY_FILE="${ZEPHYR_NRF_MODULE_DIR}/boards/shields/pca63565/boards/nrf54l15dk_nrf54l15_vpr_launcher.overlay"
platform_allow: nrf54l15dk/nrf54l15/cpuflpr
43 changes: 43 additions & 0 deletions samples/sensor/bme680/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2018 Bosch Sensortec GmbH
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/drivers/sensor.h>
#include <stdio.h>

int main(void)
{
const struct device *const dev = DEVICE_DT_GET_ONE(bosch_bme680);
struct sensor_value temp, press, humidity, gas_res;

if (!device_is_ready(dev)) {
printk("sensor: device not ready.\n");
return 0;
}

printf("Device %p name is %s\n", dev, dev->name);

#ifndef CONFIG_COVERAGE
while (1) {
#else
for (int i = 0; i < 5; i++) {
#endif
k_sleep(K_MSEC(3000));

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);
sensor_channel_get(dev, SENSOR_CHAN_GAS_RES, &gas_res);

printf("T: %d.%06d; P: %d.%06d; H: %d.%06d; G: %d.%06d\n",
temp.val1, temp.val2, press.val1, press.val2,
humidity.val1, humidity.val2, gas_res.val1,
gas_res.val2);
}
return 0;
}
5 changes: 5 additions & 0 deletions scripts/ci/tags.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1523,6 +1523,11 @@ ci_samples_sensor_accel_polling:
- nrf/samples/sensor/accel_polling/
- zephyr/samples/sensor/accel_polling/

ci_samples_sensor_bme680:
files:
- nrf/samples/sensor/bme680/
- zephyr/samples/sensor/bme680/

ci_samples_sensor_qdec:
files:
- nrf/samples/sensor/qdec/
Expand Down

0 comments on commit 3dadda7

Please sign in to comment.