-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmbed_bme680.h
68 lines (44 loc) · 1.49 KB
/
mbed_bme680.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef BME680_H
#define BME680_H
#include "bme680.h"
#include "mbed.h"
#define BME680_DEFAULT_ADDRESS (0x77 << 1) // The default I2C address (shifted for MBed 8 bit address)
//#define BME680_DEBUG_MODE // Use this for enhance debug logs for I2C and more.
extern I2C i2c;
/**
* BME680 Class for I2C usage.
* Wraps the Bosch library for MBed usage.
*/
class BME680 {
public:
BME680();
BME680(uint8_t adr);
bool begin();
bool setTemperatureOversampling(uint8_t os);
bool setPressureOversampling(uint8_t os);
bool setHumidityOversampling(uint8_t os);
bool setIIRFilterSize(uint8_t fs);
bool setGasHeater(uint16_t heaterTemp, uint16_t heaterTime);
bool performReading();
bool isGasHeatingSetupStable();
int16_t getRawTemperature();
uint32_t getRawPressure();
uint32_t getRawHumidity();
uint32_t getRawGasResistance();
float getTemperature();
float getPressure();
float getHumidity();
float getGasResistance();
private:
bool _filterEnabled, _tempEnabled, _humEnabled, _presEnabled, _gasEnabled;
int32_t _sensorID;
struct bme680_dev gas_sensor;
struct bme680_field_data data;
uint8_t _adr;
static void log(const char *format, ...);
// BME680 - hardware interface
static int8_t i2c_write(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint16_t len);
static int8_t i2c_read(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint16_t len);
static void delay_msec(uint32_t ms);
};
#endif