RocketLogger 2.1.3
bme280.h
Go to the documentation of this file.
1
32#ifndef SENSOR_BME280_H_
33#define SENSOR_BME280_H_
34
35#include <stdint.h>
36
37#define BME280_I2C_ADDRESS_LEFT 0x76
38
39#define BME280_I2C_ADDRESSES \
40 { (BME280_I2C_ADDRESS_LEFT) }
41
42#define BME280_CHANNEL_TEMPERATURE 0
43#define BME280_CHANNEL_HUMIDITY 1
44#define BME280_CHANNEL_PRESSURE 2
45
46// register definitions
47#define BME280_ID 0x60
48
49#define BME280_REG_CALIBRATION_BLOCK1 0x88
50#define BME280_REG_ID 0xD0
51#define BME280_REG_RESET 0xE0
52#define BME280_REG_CALIBRATION_BLOCK2 0xE1
53#define BME280_REG_CONTROL_HUMIDITY 0xF2
54#define BME280_REG_STATUS 0xF3
55#define BME280_REG_CONTROL_MEASURE 0xF4
56#define BME280_REG_CONFIG 0xF5
57#define BME280_REG_PRESSURE_MSB 0xF7
58#define BME280_REG_PRESSURE_LSB 0xF8
59#define BME280_REG_PRESSURE_XLSB 0xF9
60#define BME280_REG_TEMPERATURE_MSB 0xFA
61#define BME280_REG_TEMPERATURE_LSB 0xFB
62#define BME280_REG_TEMPERATURE_XLSB 0xFC
63#define BME280_REG_HUMIDITY_MSB 0xFD
64#define BME280_REG_HUMIDITY_LSB 0xFE
65
66#define BME280_CALIBRATION_BLOCK1_SIZE 26
67#define BME280_CALIBRATION_BLOCK2_SIZE 7
68
69#define BME280_DATA_BLOCK_SIZE 8
70
71#define BME280_RESET_VALUE 0xB6
72
73#define BME280_OVERSAMPLE_HUMIDITY_OFF 0x00
74#define BME280_OVERSAMPLE_HUMIDITY_1 0x01
75#define BME280_OVERSAMPLE_HUMIDITY_2 0x02
76#define BME280_OVERSAMPLE_HUMIDITY_4 0x03
77#define BME280_OVERSAMPLE_HUMIDITY_8 0x04
78#define BME280_OVERSAMPLE_HUMIDITY_16 0x0f
79
80#define BME280_MEASURING 0x03
81#define BME280_UPDATE 0x1
82
83#define BME280_OVERSAMPLE_TEMPERATURE_OFF 0x00
84#define BME280_OVERSAMPLE_TEMPERATURE_1 0x20
85#define BME280_OVERSAMPLE_TEMPERATURE_2 0x40
86#define BME280_OVERSAMPLE_TEMPERATURE_4 0x60
87#define BME280_OVERSAMPLE_TEMPERATURE_8 0x80
88#define BME280_OVERSAMPLE_TEMPERATURE_16 0xA0
89#define BME280_OVERSAMPLE_PRESSURE_OFF 0x00
90#define BME280_OVERSAMPLE_PRESSURE_1 0x04
91#define BME280_OVERSAMPLE_PRESSURE_2 0x08
92#define BME280_OVERSAMPLE_PRESSURE_4 0x0C
93#define BME280_OVERSAMPLE_PRESSURE_8 0x10
94#define BME280_OVERSAMPLE_PRESSURE_16 0x14
95#define BME280_MODE_SLEEP 0x00
96#define BME280_MODE_FORCE 0x01
97#define BME280_MODE_NORMAL 0x03
98
99#define BME280_STANDBY_DURATION_0_5 0x00
100#define BME280_STANDBY_DURATION_62 0x20
101#define BME280_STANDBY_DURATION_125 0x40
102#define BME280_STANDBY_DURATION_250 0x60
103#define BME280_STANDBY_DURATION_500 0x80
104#define BME280_STANDBY_DURATION_1000 0xA0
105#define BME280_STANDBY_DURATION_10 0xC0
106#define BME280_STANDBY_DURATION_20 0xE0
107#define BME280_FILTER_OFF 0x00
108#define BME280_FILTER_2 0x04
109#define BME280_FILTER_4 0x08
110#define BME280_FILTER_8 0x0C
111#define BME280_FILTER_16 0x10
112#define BME280_SPI_EN 0x01
113
114/*
115 * BME280 data structures
116 */
118 // temperature
119 uint16_t T1;
120 int16_t T2;
121 int16_t T3;
122
123 // pressure
124 uint16_t P1;
125 int16_t P2;
126 int16_t P3;
127 int16_t P4;
128 int16_t P5;
129 int16_t P6;
130 int16_t P7;
131 int16_t P8;
132 int16_t P9;
133
134 // humidity
135 uint8_t H1;
136 int16_t H2;
137 uint8_t H3;
138 int16_t H4;
139 int16_t H5;
140 int8_t H6;
141};
142
143/*
144 * Typedef for BME280 data structures
145 */
147
154int bme280_init(int);
155
161void bme280_deinit(int);
162
169int bme280_read(int);
170
178int32_t bme280_get_value(int, int);
179
180#endif /* SENSOR_BME280_H_ */
int32_t bme280_get_value(int, int)
Definition bme280.c:237
void bme280_deinit(int)
Definition bme280.c:189
int bme280_init(int)
Definition bme280.c:144
int bme280_read(int)
Definition bme280.c:193