-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAdafruit_BME690.h
More file actions
122 lines (103 loc) · 4.48 KB
/
Copy pathAdafruit_BME690.h
File metadata and controls
122 lines (103 loc) · 4.48 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*!
* @file Adafruit_BME690.h
*
* Adafruit BME690 temperature, humidity, barometric pressure and gas sensor
* driver
*
* This is the documentation for Adafruit's BME690 driver for the
* Arduino platform. It is designed specifically to work with the
* Adafruit BME690 breakout: https://www.adafruit.com/products/TBD
*
* These sensors use I2C or SPI to communicate, 2 or 4 pins are required
* to interface with the breakout.
*
* Adafruit invests time and resources providing this open source code,
* please support Adafruit and open-source hardware by purchasing
* products from Adafruit!
*
* Written by Ladyada for Adafruit Industries.
*
* BSD license, all text here must be included in any redistribution.
*
*/
#ifndef __BME690_H__
#define __BME690_H__
#include <Adafruit_I2CDevice.h>
#include <Adafruit_SPIDevice.h>
#include <Adafruit_Sensor.h>
#include <Wire.h>
#include "Arduino.h"
#include "bme69x.h"
#define BME69X_DEFAULT_ADDRESS (0x77) ///< The default I2C address
#define BME69X_DEFAULT_SPIFREQ (1000000) ///< The default SPI Clock speed
/** BME690 oversampling constants - wrappers for bme69x.h constants */
#define BME690_OS_16X BME69X_OS_16X ///< 16x oversampling
#define BME690_OS_8X BME69X_OS_8X ///< 8x oversampling
#define BME690_OS_4X BME69X_OS_4X ///< 4x oversampling
#define BME690_OS_2X BME69X_OS_2X ///< 2x oversampling
#define BME690_OS_1X BME69X_OS_1X ///< 1x oversampling
#define BME690_OS_NONE BME69X_OS_NONE ///< No oversampling
/** BME690 IIR filter size constants */
#define BME690_FILTER_SIZE_127 BME69X_FILTER_SIZE_127 ///< IIR filter size 127
#define BME690_FILTER_SIZE_63 BME69X_FILTER_SIZE_63 ///< IIR filter size 63
#define BME690_FILTER_SIZE_31 BME69X_FILTER_SIZE_31 ///< IIR filter size 31
#define BME690_FILTER_SIZE_15 BME69X_FILTER_SIZE_15 ///< IIR filter size 15
#define BME690_FILTER_SIZE_7 BME69X_FILTER_SIZE_7 ///< IIR filter size 7
#define BME690_FILTER_SIZE_3 BME69X_FILTER_SIZE_3 ///< IIR filter size 3
#define BME690_FILTER_SIZE_1 BME69X_FILTER_SIZE_1 ///< IIR filter size 1
#define BME690_FILTER_OFF BME69X_FILTER_OFF ///< IIR filter off
/*! Adafruit_BME690 Class for both I2C and SPI usage.
* Wraps the Bosch library for Arduino usage
*/
class Adafruit_BME690 {
public:
/** Value returned by remainingReadingMillis indicating no asynchronous
* reading has been initiated by beginReading. **/
static constexpr int reading_not_started = -1;
/** Value returned by remainingReadingMillis indicating asynchronous reading
* is complete and calling endReading will not block. **/
static constexpr int reading_complete = 0;
Adafruit_BME690(TwoWire* theWire = &Wire);
Adafruit_BME690(int8_t cspin, SPIClass* theSPI = &SPI);
Adafruit_BME690(int8_t cspin, int8_t mosipin, int8_t misopin, int8_t sckpin);
bool begin(uint8_t addr = BME69X_DEFAULT_ADDRESS, bool initSettings = true);
float readTemperature();
float readPressure();
float readHumidity();
uint32_t readGas();
float readAltitude(float seaLevel);
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 setODR(uint8_t odr);
// Perform a reading in blocking mode.
bool performReading();
uint32_t beginReading();
bool endReading();
int remainingReadingMillis();
/** Temperature (Celsius) assigned after calling performReading() or
* endReading() **/
float temperature;
/** Pressure (Pascals) assigned after calling performReading() or endReading()
* **/
uint32_t pressure;
/** Humidity (RH %) assigned after calling performReading() or endReading()
* **/
float humidity;
/** Gas resistance (ohms) assigned after calling performReading() or
* endReading() **/
uint32_t gas_resistance;
private:
Adafruit_I2CDevice* _i2cdev = NULL; ///< Pointer to I2C bus interface
Adafruit_SPIDevice* _spidev = NULL; ///< Pointer to SPI bus interface
TwoWire* _wire = NULL; ///< Pointer to Wire instance
int32_t _sensorID; ///< ID number for temperature sensor
uint32_t _meas_start = 0; ///< Measurement start time (millis)
uint16_t _meas_period = 0; ///< Measurement period in milliseconds
struct bme69x_dev gas_sensor; ///< BME69x device structure
struct bme69x_conf gas_conf; ///< BME69x configuration structure
struct bme69x_heatr_conf gas_heatr_conf; ///< BME69x heater configuration
};
#endif