bme280.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Kees Bakker, SODAQ
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
30 #ifndef BME280_H
31 #define BME280_H
32 
33 #include "saul.h"
34 #include "periph/i2c.h"
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
45 typedef struct {
46  uint16_t dig_T1;
47  int16_t dig_T2;
48  int16_t dig_T3;
50  uint16_t dig_P1;
51  int16_t dig_P2;
52  int16_t dig_P3;
53  int16_t dig_P4;
54  int16_t dig_P5;
55  int16_t dig_P6;
56  int16_t dig_P7;
57  int16_t dig_P8;
58  int16_t dig_P9;
60  uint8_t dig_H1;
61  int16_t dig_H2;
62  uint8_t dig_H3;
63  int16_t dig_H4;
64  int16_t dig_H5;
65  int8_t dig_H6;
67 
71 typedef enum {
72  BME280_SB_0_5 = 0,
73  BME280_SB_62_5 = 1,
74  BME280_SB_125 = 2,
75  BME280_SB_250 = 3,
76  BME280_SB_500 = 4,
77  BME280_SB_1000 = 5,
78  BME280_SB_10 = 6,
79  BME280_SB_20 = 7
81 
85 typedef enum {
86  BME280_FILTER_OFF = 0,
87  BME280_FILTER_2 = 1,
88  BME280_FILTER_4 = 2,
89  BME280_FILTER_8 = 3,
90  BME280_FILTER_16 = 4,
92 
96 typedef enum {
97  BME280_MODE_SLEEP = 0,
98  BME280_MODE_FORCED = 1,
99  BME280_MODE_FORCED2 = 2, /* Same as FORCED */
100  BME280_MODE_NORMAL = 3
101 } bme280_mode_t;
102 
111 typedef enum {
112  BME280_OSRS_SKIPPED = 0,
113  BME280_OSRS_X1 = 1,
114  BME280_OSRS_X2 = 2,
115  BME280_OSRS_X4 = 3,
116  BME280_OSRS_X8 = 4,
117  BME280_OSRS_X16 = 5,
118 } bme280_osrs_t;
119 
125 typedef struct {
126  /* I2C details */
128  uint8_t i2c_addr;
130  /* Config Register */
133  uint8_t spi3w_en;
135  /* ctrl_meas */
140  /* ctrl_hum */
143 
147 typedef struct {
150 } bme280_t;
151 
155 enum {
156  BME280_OK = 0,
160 };
161 
167 extern const saul_driver_t bme280_relative_humidity_saul_driver;
168 extern const saul_driver_t bme280_pressure_saul_driver;
182 int bme280_init(bme280_t* dev, const bme280_params_t* params);
183 
192 int16_t bme280_read_temperature(bme280_t* dev);
193 
204 uint16_t bme280_read_humidity(bme280_t *dev);
205 
216 uint32_t bme280_read_pressure(bme280_t *dev);
217 
218 #ifdef __cplusplus
219 }
220 #endif
221 
222 #endif /* BME280_H */
223 
int16_t dig_P4
P4 coefficient.
Definition: bme280.h:53
int16_t bme280_read_temperature(bme280_t *dev)
Read temperature value from the given BME280 device, returned in centi °C.
int16_t dig_H4
H4 coefficient.
Definition: bme280.h:63
bme280_osrs_t humid_oversample
ctrl_hum osrs_h
Definition: bme280.h:141
int16_t dig_H2
H2 coefficient.
Definition: bme280.h:61
bme280_mode_t
Values for mode field of the BME280 ctrl_meas register.
Definition: bme280.h:96
bme280_filter_t
Values for filter field of the BME280 config register.
Definition: bme280.h:85
int16_t dig_P2
P2 coefficient.
Definition: bme280.h:51
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:104
Calibration struct for the BME280 sensor.
Definition: bme280.h:45
Definition of the RIOT actuator/sensor interface.
Definition: saul.h:139
bme280_osrs_t press_oversample
ctrl_meas osrs_p
Definition: bme280.h:138
int16_t dig_P6
P6 coefficient.
Definition: bme280.h:55
bme280_filter_t filter
filter coefficient
Definition: bme280.h:132
int16_t dig_P7
P7 coefficient.
Definition: bme280.h:56
int16_t dig_P3
P3 coefficient.
Definition: bme280.h:52
did not detect BME280
Definition: bme280.h:158
uint16_t dig_P1
P1 coefficient.
Definition: bme280.h:50
Definition of the generic [S]ensor [A]ctuator [U]ber [L]ayer.
uint8_t spi3w_en
Enables 3-wire SPI interface.
Definition: bme280.h:133
bme280_calibration_t calibration
Calibration Data.
Definition: bme280.h:149
uint8_t dig_H3
H3 coefficient.
Definition: bme280.h:62
error initializing the I2C bus
Definition: bme280.h:157
bme280_params_t params
Device Parameters.
Definition: bme280.h:148
i2c_t i2c_dev
I2C device which is used.
Definition: bme280.h:127
could not read calibration data
Definition: bme280.h:159
bme280_mode_t run_mode
ctrl_meas mode
Definition: bme280.h:136
int8_t dig_H6
H6 coefficient.
Definition: bme280.h:65
int16_t dig_T2
T2 coefficient.
Definition: bme280.h:47
uint16_t dig_T1
T1 coefficient.
Definition: bme280.h:46
Device descriptor for the BME280 sensor.
Definition: bme280.h:147
everything was fine
Definition: bme280.h:156
bme280_osrs_t temp_oversample
ctrl_meas osrs_t
Definition: bme280.h:137
int16_t dig_T3
T3 coefficient.
Definition: bme280.h:48
int16_t dig_P8
P8 coefficient.
Definition: bme280.h:57
int16_t dig_H5
H5 coefficient.
Definition: bme280.h:64
uint16_t bme280_read_humidity(bme280_t *dev)
Read humidity value from the given BME280 device, returned in centi RH.
int16_t dig_P5
P5 coefficient.
Definition: bme280.h:54
const saul_driver_t bme280_temperature_saul_driver
export SAUL endpoints
bme280_t_sb_t t_sb
standby
Definition: bme280.h:131
bme280_t_sb_t
Values for t_sb field of the BME280 config register.
Definition: bme280.h:71
Parameters for the BME280 sensor.
Definition: bme280.h:125
uint32_t bme280_read_pressure(bme280_t *dev)
Read air pressure value from the given BME280 device, returned in PA.
int16_t dig_P9
P9 coefficient.
Definition: bme280.h:58
uint8_t dig_H1
H1 coefficient.
Definition: bme280.h:60
int bme280_init(bme280_t *dev, const bme280_params_t *params)
Initialize the given BME280 device.
uint8_t i2c_addr
I2C address.
Definition: bme280.h:128
bme280_osrs_t
Values for oversampling settings.
Definition: bme280.h:111
Low-level I2C peripheral driver interface definition.