Loading...
Searching...
No Matches
bme680.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2019 Mesotic SAS
3 * 2020 Gunar Schorcht
4 *
5 * This file is subject to the terms and conditions of the GNU Lesser
6 * General Public License v2.1. See the file LICENSE in the top level
7 * directory for more details.
8 */
9
108#ifndef BME680_H
109#define BME680_H
110
111#include "periph/i2c.h"
112#include "periph/spi.h"
113
114#ifdef MODULE_BME680_FP
115#define BME680_FLOAT_POINT_COMPENSATION
116#endif
117
118#include "bme680_hal.h"
119#include "bme680_internal.h"
120
121#ifdef __cplusplus
122extern "C" {
123#endif
124
128#define BME680_I2C_ADDR_1 (0x76)
129
133#define BME680_I2C_ADDR_2 (0x77)
134
139#define BME680_SENSOR(d) (*((struct bme680_dev *)d))
140
144enum {
150};
151
152#ifdef DOXYGEN
156typedef struct bme680_field_data {
157 uint8_t status;
161 uint8_t gas_index;
162 uint8_t meas_index;
163#ifndef MODULE_BME680_FP
164 int16_t temperature;
165 uint32_t pressure;
166 uint32_t humidity;
167 uint32_t gas_resistance;
168#else /* MODULE_BME680_FP */
169 float temperature;
170 float pressure;
171 float humidity;
172 float gas_resistance;
173#endif /* MODULE_BME680_FP */
174};
175
176#endif /* DOXYGEN */
177
182
187typedef struct bme680_dev bme680_dev_t;
188
192typedef struct {
194 uint8_t addr;
196
200typedef struct {
201 spi_t dev;
202 gpio_t nss_pin;
204
212
216typedef struct {
217 uint8_t ifsel;
218 uint8_t temp_os;
219 uint8_t hum_os;
220 uint8_t pres_os;
221 uint8_t filter;
222 uint8_t gas_measure;
223 uint16_t heater_dur;
224 uint16_t heater_temp;
225 uint8_t power_mode;
226 uint8_t settings;
229
233typedef struct {
234 struct bme680_dev sensor;
236} bme680_t;
237
241extern bme680_t *bme680_devs[];
242
246extern unsigned int bme680_devs_numof;
247
257int bme680_init(bme680_t *dev, const bme680_params_t *params);
258
273
288
305
318int bme680_set_ambient_temp(bme680_t* dev, int8_t temp);
319
320#ifdef __cplusplus
321}
322#endif
323
324#endif /* BME680_H */
Abstraction layer for RIOT adaption.
int bme680_init(bme680_t *dev, const bme680_params_t *params)
Initialize the BME680 sensor.
unsigned int bme680_devs_numof
Number of initialized BME680 sensor devices in bme680_devs.
int bme680_force_measurement(bme680_t *dev)
Force a single TPHG measurement cycle.
bme680_t * bme680_devs[]
References to BME680 sensor devices used by the HAL functions.
int bme680_get_duration(bme680_t *dev)
Duration one THPG measurement cycle.
int bme680_set_ambient_temp(bme680_t *dev, int8_t temp)
Set the ambient temperature.
struct bme680_dev bme680_dev_t
Shortcut type definition for BME680 sensor device structure.
Definition bme680.h:187
int bme680_get_data(bme680_t *dev, bme680_field_data_t *data)
Get results of a TPHG measurement.
@ BME680_NO_NEW_DATA
No new data.
Definition bme680.h:149
@ BME680_COM_FAILED
Communication with the device failed.
Definition bme680.h:146
@ BME680_NULL_PTR
NULL pointer check failed.
Definition bme680.h:145
@ BME680_INVALID
Invalid value or length.
Definition bme680.h:148
@ BME680_NO_DEV
Device doesn't exist.
Definition bme680.h:147
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:151
Low-level I2C peripheral driver interface definition.
Low-level SPI peripheral driver interface definition.
BME680 sensor field data.
Definition bme680.h:156
uint32_t gas_resistance
Gas resistance in ohms.
Definition bme680.h:167
int16_t temperature
Temperature in degree Celsius x 100.
Definition bme680.h:164
uint32_t humidity
Relative humidity in percent x 1000.
Definition bme680.h:166
uint8_t meas_index
Measurement index.
Definition bme680.h:162
uint8_t gas_index
Index of used heater profile.
Definition bme680.h:161
uint8_t status
Status for new data, gas measurement valid and heater stable.
Definition bme680.h:157
uint32_t pressure
Pressure in Pascal.
Definition bme680.h:165
BME680 I2C parameters.
Definition bme680.h:192
uint8_t addr
I2C address.
Definition bme680.h:194
i2c_t dev
I2C device which is used.
Definition bme680.h:193
BME680 SPI parameters.
Definition bme680.h:200
gpio_t nss_pin
Chip Select pin.
Definition bme680.h:202
spi_t dev
SPI device which is used.
Definition bme680.h:201
BME680 device initialization parameters.
Definition bme680.h:216
uint8_t ifsel
Interface selection.
Definition bme680.h:217
bme680_intf_t intf
Hardware interface parameters.
Definition bme680.h:227
uint8_t gas_measure
Enable gas measurement.
Definition bme680.h:222
uint8_t pres_os
Pressure oversampling.
Definition bme680.h:220
uint8_t hum_os
Humidity oversampling.
Definition bme680.h:219
uint16_t heater_dur
Heater duration in ms.
Definition bme680.h:223
uint8_t power_mode
Power mode (sleep or forced)
Definition bme680.h:225
uint16_t heater_temp
Heater temperature in °C.
Definition bme680.h:224
uint8_t temp_os
Temperature oversampling.
Definition bme680.h:218
uint8_t settings
Settings used.
Definition bme680.h:226
uint8_t filter
IIR filter coefficient.
Definition bme680.h:221
BME680 device descriptor.
Definition bme680.h:233
bme680_intf_t intf
Device interface.
Definition bme680.h:235
BME680 Hardware interface parameters union.
Definition bme680.h:208
bme680_intf_spi_t spi
SPI specific interface parameters.
Definition bme680.h:210
bme680_intf_i2c_t i2c
I2C specific interface parameters.
Definition bme680.h:209