boards/thingy53: add BME688 sensor support

add BME688 sensor support to thingy53
This commit is contained in:
raiden00pl
2025-05-06 20:02:05 +02:00
committed by Xiang Xiao
parent 3a31da9585
commit fb901e3bda
6 changed files with 187 additions and 1 deletions

View File

@@ -28,7 +28,7 @@ Low power accelerometer (ADXL362) Yes SPI
IMU (BMI270) Yes SPI or I2C 0x68
Magnetometer (BMM150) Yes I2C 0x10
Color sensor (BH1749NUC) Yes I2C 0x38
Air quality sensor (BME688) No I2C 0x76
Air quality sensor (BME688) Yes I2C 0x76
================================== ======= =============
Serial Console

View File

@@ -0,0 +1,54 @@
/****************************************************************************
* boards/arm/nrf53/common/include/nrf53_bme688.h
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __BOARDS_ARM_NRF53_COMMON_INCLUDE_NRF53_BME688_H
#define __BOARDS_ARM_NRF53_COMMON_INCLUDE_NRF53_BME688_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
/****************************************************************************
* Public Functions Prototypes
****************************************************************************/
/****************************************************************************
* Name: nrf53_bme688_init
*
* Description:
* Initialize and register the BME688 as uorb sensor
*
* Input Parameters:
* devno - The user specifies device number, from 0.
* busno - I2C bus number
* addr - The I2C address
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
int nrf53_bme688_init(int devno, int busno, uint8_t addr);
#endif /* __BOARDS_ARM_NRF53_COMMON_INCLUDE_NRF53_BME688_H */

View File

@@ -54,6 +54,10 @@ if(CONFIG_ARCH_BOARD_COMMON)
list(APPEND SRCS nrf53_bmm150.c)
endif()
if(CONFIG_SENSORS_BME688)
list(APPEND SRCS nrf53_bme688.c)
endif()
target_sources(board PRIVATE ${SRCS})
endif()

View File

@@ -54,6 +54,10 @@ ifeq ($(CONFIG_SENSORS_BMM150),y)
CSRCS += nrf53_bmm150.c
endif
ifeq ($(CONFIG_SENSORS_BME688),y)
CSRCS += nrf53_bme688.c
endif
DEPPATH += --dep-path src
VPATH += :src
CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src

View File

@@ -0,0 +1,110 @@
/****************************************************************************
* boards/arm/nrf53/common/src/nrf53_bme688.c
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <debug.h>
#include <errno.h>
#include <stdio.h>
#include <nuttx/i2c/i2c_master.h>
#include <nuttx/sensors/bme688.h>
#include "nrf53_i2c.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nrf53_bme688_init
*
* Description:
* Initialize and register the BME688 as uorb sensor
*
* Input Parameters:
* devno - The user specifies device number, from 0.
* busno - I2C bus number
* addr - The I2C address
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
int nrf53_bme688_init(int devno, int busno, uint8_t addr)
{
struct bme688_config_s config;
struct i2c_master_s *i2c;
int ret;
/* Address not configurable yet */
UNUSED(addr);
sninfo("Initializing BME688!\n");
/* Initialize I2C */
i2c = nrf53_i2cbus_initialize(busno);
if (!i2c)
{
return -ENODEV;
}
/* Default configuration */
config.temp_os = BME688_OS_2X;
#ifndef CONFIG_BME688_DISABLE_PRESS_MEAS
config.press_os = BME688_OS_16X;
#endif
#ifndef CONFIG_BME688_DISABLE_HUM_MEAS
config.hum_os = BME688_OS_1X;
#endif
#ifdef CONFIG_BME688_ENABLE_IIR_FILTER
config.filter_coef = BME688_FILTER_COEF3;
#endif
#ifndef CONFIG_BME688_DISABLE_GAS_MEAS
config.target_temp = 300;
config.heater_duration = 100;
config.nb_conv = 0;
config.amb_temp = 30;
#endif
/* Then register the sensor */
ret = bme688_register(devno, i2c, &config);
if (ret < 0)
{
snerr("ERROR: Error registering BME688\n");
}
return ret;
}

View File

@@ -46,6 +46,10 @@
# include "nrf53_bmm150.h"
#endif
#ifdef CONFIG_SENSORS_BME688
# include "nrf53_bme688.h"
#endif
#include "arm_internal.h"
#include "thingy53.h"
@@ -135,5 +139,15 @@ int nrf53_sensors_init(void)
}
#endif
#ifdef CONFIG_SENSORS_BME688
/* Initialize BME688 */
ret = nrf53_bme688_init(0, BME688_I2C_BUS, BME688_I2C_ADDR);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: nrf53_bme688_init failed: %d\n", ret);
}
#endif
return ret;
}