Skip to content

Commit f772ae1

Browse files
committed
Updated to BSEC v1.4.9.2. Added support for BME688.
1 parent 7a93575 commit f772ae1

File tree

39 files changed

+4009
-3469
lines changed

39 files changed

+4009
-3469
lines changed

LICENSE

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ The binaries and includes for the core BSEC library in this repository are licen
22
under the Software license agreement described in the link
33
https://www.bosch-sensortec.com/media/boschsensortec/downloads/bsec/2017-07-17_clickthrough_license_terms_environmentalib_sw_clean.pdf
44

5-
The Arduino wrapper and BME680 Sensor API are licensed under the following license.
5+
The Arduino wrapper and BME68x Sensor API are licensed under the following license.
66

7-
Copyright (c) 2020 Bosch Sensortec GmbH. All rights reserved.
7+
Copyright (c) 2021 Bosch Sensortec GmbH. All rights reserved.
88

99
BSD-3-Clause
1010

@@ -15,12 +15,12 @@ modification, are permitted provided that the following conditions are met:
1515
notice, this list of conditions and the following disclaimer.
1616

1717
2. Redistributions in binary form must reproduce the above copyright
18-
notice, this list of conditions and the following disclaimer in the
19-
documentation and/or other materials provided with the distribution.
18+
notice, this list of conditions and the following disclaimer in the
19+
documentation and/or other materials provided with the distribution.
2020

2121
3. Neither the name of the copyright holder nor the names of its
22-
contributors may be used to endorse or promote products derived from
23-
this software without specific prior written permission.
22+
contributors may be used to endorse or promote products derived from
23+
this software without specific prior written permission.
2424

2525
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2626
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
@@ -33,4 +33,4 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3333
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
3434
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
3535
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36-
POSSIBILITY OF SUCH DAMAGE.
36+
POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## About BSEC
44

5-
Bosch Sensortec Environmental Cluster (BSEC) Software v1.4.8.0 released on July 8th, 2020
5+
Bosch Sensortec Environmental Cluster (BSEC) Software v1.4.9.2 released on June 13th, 2022
66

77
The BSEC fusion library has been conceptualized to provide a higher-level signal processing and fusion for the BME680. The library receives compensated sensor values from the sensor API. It processes the BME680 signals to provide the requested sensor outputs.
88

examples/basic/basic.ino

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,36 @@ String output;
1212
// Entry point for the example
1313
void setup(void)
1414
{
15+
/* Initializes the Serial communication */
1516
Serial.begin(115200);
16-
Wire.begin();
17-
18-
iaqSensor.begin(BME680_I2C_ADDR_PRIMARY, Wire);
17+
delay(1000);
18+
pinMode(LED_BUILTIN, OUTPUT);
19+
iaqSensor.begin(BME68X_I2C_ADDR_LOW, Wire);
1920
output = "\nBSEC library version " + String(iaqSensor.version.major) + "." + String(iaqSensor.version.minor) + "." + String(iaqSensor.version.major_bugfix) + "." + String(iaqSensor.version.minor_bugfix);
2021
Serial.println(output);
2122
checkIaqSensorStatus();
2223

23-
bsec_virtual_sensor_t sensorList[10] = {
24-
BSEC_OUTPUT_RAW_TEMPERATURE,
25-
BSEC_OUTPUT_RAW_PRESSURE,
26-
BSEC_OUTPUT_RAW_HUMIDITY,
27-
BSEC_OUTPUT_RAW_GAS,
24+
bsec_virtual_sensor_t sensorList[13] = {
2825
BSEC_OUTPUT_IAQ,
2926
BSEC_OUTPUT_STATIC_IAQ,
3027
BSEC_OUTPUT_CO2_EQUIVALENT,
3128
BSEC_OUTPUT_BREATH_VOC_EQUIVALENT,
29+
BSEC_OUTPUT_RAW_TEMPERATURE,
30+
BSEC_OUTPUT_RAW_PRESSURE,
31+
BSEC_OUTPUT_RAW_HUMIDITY,
32+
BSEC_OUTPUT_RAW_GAS,
33+
BSEC_OUTPUT_STABILIZATION_STATUS,
34+
BSEC_OUTPUT_RUN_IN_STATUS,
3235
BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_TEMPERATURE,
3336
BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_HUMIDITY,
37+
BSEC_OUTPUT_GAS_PERCENTAGE
3438
};
3539

36-
iaqSensor.updateSubscription(sensorList, 10, BSEC_SAMPLE_RATE_LP);
40+
iaqSensor.updateSubscription(sensorList, 13, BSEC_SAMPLE_RATE_LP);
3741
checkIaqSensorStatus();
3842

3943
// Print the header
40-
output = "Timestamp [ms], raw temperature [°C], pressure [hPa], raw relative humidity [%], gas [Ohm], IAQ, IAQ accuracy, temperature [°C], relative humidity [%], Static IAQ, CO2 equivalent, breath VOC equivalent";
44+
output = "Timestamp [ms], IAQ, IAQ accuracy, Static IAQ, CO2 equivalent, breath VOC equivalent, raw temp[°C], pressure [hPa], raw relative humidity [%], gas [Ohm], Stab Status, run in status, comp temp[°C], comp humidity [%], gas percentage";
4145
Serial.println(output);
4246
}
4347

@@ -46,19 +50,24 @@ void loop(void)
4650
{
4751
unsigned long time_trigger = millis();
4852
if (iaqSensor.run()) { // If new data is available
53+
digitalWrite(LED_BUILTIN, LOW);
4954
output = String(time_trigger);
55+
output += ", " + String(iaqSensor.iaq);
56+
output += ", " + String(iaqSensor.iaqAccuracy);
57+
output += ", " + String(iaqSensor.staticIaq);
58+
output += ", " + String(iaqSensor.co2Equivalent);
59+
output += ", " + String(iaqSensor.breathVocEquivalent);
5060
output += ", " + String(iaqSensor.rawTemperature);
5161
output += ", " + String(iaqSensor.pressure);
5262
output += ", " + String(iaqSensor.rawHumidity);
5363
output += ", " + String(iaqSensor.gasResistance);
54-
output += ", " + String(iaqSensor.iaq);
55-
output += ", " + String(iaqSensor.iaqAccuracy);
64+
output += ", " + String(iaqSensor.stabStatus);
65+
output += ", " + String(iaqSensor.runInStatus);
5666
output += ", " + String(iaqSensor.temperature);
5767
output += ", " + String(iaqSensor.humidity);
58-
output += ", " + String(iaqSensor.staticIaq);
59-
output += ", " + String(iaqSensor.co2Equivalent);
60-
output += ", " + String(iaqSensor.breathVocEquivalent);
68+
output += ", " + String(iaqSensor.gasPercentage);
6169
Serial.println(output);
70+
digitalWrite(LED_BUILTIN, HIGH);
6271
} else {
6372
checkIaqSensorStatus();
6473
}
@@ -67,26 +76,26 @@ void loop(void)
6776
// Helper function definitions
6877
void checkIaqSensorStatus(void)
6978
{
70-
if (iaqSensor.status != BSEC_OK) {
71-
if (iaqSensor.status < BSEC_OK) {
72-
output = "BSEC error code : " + String(iaqSensor.status);
79+
if (iaqSensor.bsecStatus != BSEC_OK) {
80+
if (iaqSensor.bsecStatus < BSEC_OK) {
81+
output = "BSEC error code : " + String(iaqSensor.bsecStatus);
7382
Serial.println(output);
7483
for (;;)
7584
errLeds(); /* Halt in case of failure */
7685
} else {
77-
output = "BSEC warning code : " + String(iaqSensor.status);
86+
output = "BSEC warning code : " + String(iaqSensor.bsecStatus);
7887
Serial.println(output);
7988
}
8089
}
8190

82-
if (iaqSensor.bme680Status != BME680_OK) {
83-
if (iaqSensor.bme680Status < BME680_OK) {
84-
output = "BME680 error code : " + String(iaqSensor.bme680Status);
91+
if (iaqSensor.bme68xStatus != BME68X_OK) {
92+
if (iaqSensor.bme68xStatus < BME68X_OK) {
93+
output = "BME68X error code : " + String(iaqSensor.bme68xStatus);
8594
Serial.println(output);
8695
for (;;)
8796
errLeds(); /* Halt in case of failure */
8897
} else {
89-
output = "BME680 warning code : " + String(iaqSensor.bme680Status);
98+
output = "BME68X warning code : " + String(iaqSensor.bme68xStatus);
9099
Serial.println(output);
91100
}
92101
}

examples/basic_config_state/basic_config_state.ino

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const uint8_t bsec_config_iaq[] = {
1717
#include "config/generic_33v_3s_4d/bsec_iaq.txt"
1818
};
1919

20+
2021
#define STATE_SAVE_PERIOD UINT32_C(360 * 60 * 1000) // 360 minutes - 4 times a day
2122

2223
// Helper functions declarations
@@ -35,11 +36,11 @@ String output;
3536
// Entry point for the example
3637
void setup(void)
3738
{
38-
EEPROM.begin(BSEC_MAX_STATE_BLOB_SIZE + 1); // 1st address for the length
39+
EEPROM.begin(BSEC_MAX_STATE_BLOB_SIZE + 1);
3940
Serial.begin(115200);
40-
Wire.begin();
41-
42-
iaqSensor.begin(BME680_I2C_ADDR_PRIMARY, Wire);
41+
delay(1000);
42+
pinMode(LED_BUILTIN, OUTPUT);
43+
iaqSensor.begin(BME68X_I2C_ADDR_LOW, Wire);
4344
output = "\nBSEC library version " + String(iaqSensor.version.major) + "." + String(iaqSensor.version.minor) + "." + String(iaqSensor.version.major_bugfix) + "." + String(iaqSensor.version.minor_bugfix);
4445
Serial.println(output);
4546
checkIaqSensorStatus();
@@ -49,21 +50,27 @@ void setup(void)
4950

5051
loadState();
5152

52-
bsec_virtual_sensor_t sensorList[7] = {
53+
bsec_virtual_sensor_t sensorList[13] = {
54+
BSEC_OUTPUT_IAQ,
55+
BSEC_OUTPUT_STATIC_IAQ,
56+
BSEC_OUTPUT_CO2_EQUIVALENT,
57+
BSEC_OUTPUT_BREATH_VOC_EQUIVALENT,
5358
BSEC_OUTPUT_RAW_TEMPERATURE,
5459
BSEC_OUTPUT_RAW_PRESSURE,
5560
BSEC_OUTPUT_RAW_HUMIDITY,
5661
BSEC_OUTPUT_RAW_GAS,
57-
BSEC_OUTPUT_IAQ,
62+
BSEC_OUTPUT_STABILIZATION_STATUS,
63+
BSEC_OUTPUT_RUN_IN_STATUS,
5864
BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_TEMPERATURE,
5965
BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_HUMIDITY,
66+
BSEC_OUTPUT_GAS_PERCENTAGE
6067
};
6168

62-
iaqSensor.updateSubscription(sensorList, 7, BSEC_SAMPLE_RATE_LP);
69+
iaqSensor.updateSubscription(sensorList, 13, BSEC_SAMPLE_RATE_LP);
6370
checkIaqSensorStatus();
6471

6572
// Print the header
66-
output = "Timestamp [ms], raw temperature [°C], pressure [hPa], raw relative humidity [%], gas [Ohm], IAQ, IAQ accuracy, temperature [°C], relative humidity [%]";
73+
output = "Timestamp [ms], IAQ, IAQ accuracy, Static IAQ, CO2 equivalent, breath VOC equivalent, raw temp[°C], pressure [hPa], raw relative humidity [%], gas [Ohm], Stab Status, run in status, comp temp[°C], comp humidity [%], gas percentage";
6774
Serial.println(output);
6875
}
6976

@@ -72,16 +79,24 @@ void loop(void)
7279
{
7380
unsigned long time_trigger = millis();
7481
if (iaqSensor.run()) { // If new data is available
82+
digitalWrite(LED_BUILTIN, LOW);
7583
output = String(time_trigger);
84+
output += ", " + String(iaqSensor.iaq);
85+
output += ", " + String(iaqSensor.iaqAccuracy);
86+
output += ", " + String(iaqSensor.staticIaq);
87+
output += ", " + String(iaqSensor.co2Equivalent);
88+
output += ", " + String(iaqSensor.breathVocEquivalent);
7689
output += ", " + String(iaqSensor.rawTemperature);
7790
output += ", " + String(iaqSensor.pressure);
7891
output += ", " + String(iaqSensor.rawHumidity);
7992
output += ", " + String(iaqSensor.gasResistance);
80-
output += ", " + String(iaqSensor.iaq);
81-
output += ", " + String(iaqSensor.iaqAccuracy);
93+
output += ", " + String(iaqSensor.stabStatus);
94+
output += ", " + String(iaqSensor.runInStatus);
8295
output += ", " + String(iaqSensor.temperature);
8396
output += ", " + String(iaqSensor.humidity);
97+
output += ", " + String(iaqSensor.gasPercentage);
8498
Serial.println(output);
99+
digitalWrite(LED_BUILTIN, HIGH);
85100
updateState();
86101
} else {
87102
checkIaqSensorStatus();
@@ -91,30 +106,29 @@ void loop(void)
91106
// Helper function definitions
92107
void checkIaqSensorStatus(void)
93108
{
94-
if (iaqSensor.status != BSEC_OK) {
95-
if (iaqSensor.status < BSEC_OK) {
96-
output = "BSEC error code : " + String(iaqSensor.status);
109+
if (iaqSensor.bsecStatus != BSEC_OK) {
110+
if (iaqSensor.bsecStatus < BSEC_OK) {
111+
output = "BSEC error code : " + String(iaqSensor.bsecStatus);
97112
Serial.println(output);
98113
for (;;)
99114
errLeds(); /* Halt in case of failure */
100115
} else {
101-
output = "BSEC warning code : " + String(iaqSensor.status);
116+
output = "BSEC warning code : " + String(iaqSensor.bsecStatus);
102117
Serial.println(output);
103118
}
104119
}
105120

106-
if (iaqSensor.bme680Status != BME680_OK) {
107-
if (iaqSensor.bme680Status < BME680_OK) {
108-
output = "BME680 error code : " + String(iaqSensor.bme680Status);
121+
if (iaqSensor.bme68xStatus != BME68X_OK) {
122+
if (iaqSensor.bme68xStatus < BME68X_OK) {
123+
output = "BME68X error code : " + String(iaqSensor.bme68xStatus);
109124
Serial.println(output);
110125
for (;;)
111126
errLeds(); /* Halt in case of failure */
112127
} else {
113-
output = "BME680 warning code : " + String(iaqSensor.bme680Status);
128+
output = "BME68X warning code : " + String(iaqSensor.bme68xStatus);
114129
Serial.println(output);
115130
}
116131
}
117-
iaqSensor.status = BSEC_OK;
118132
}
119133

120134
void errLeds(void)
@@ -153,14 +167,14 @@ void loadState(void)
153167
void updateState(void)
154168
{
155169
bool update = false;
156-
/* Set a trigger to save the state. Here, the state is saved every STATE_SAVE_PERIOD with the first state being saved once the algorithm achieves full calibration, i.e. iaqAccuracy = 3 */
157170
if (stateUpdateCounter == 0) {
171+
/* First state update when IAQ accuracy is >= 3 */
158172
if (iaqSensor.iaqAccuracy >= 3) {
159173
update = true;
160174
stateUpdateCounter++;
161175
}
162176
} else {
163-
/* Update every STATE_SAVE_PERIOD milliseconds */
177+
/* Update every STATE_SAVE_PERIOD minutes */
164178
if ((stateUpdateCounter * STATE_SAVE_PERIOD) < millis()) {
165179
update = true;
166180
stateUpdateCounter++;
@@ -181,4 +195,4 @@ void updateState(void)
181195
EEPROM.write(0, BSEC_MAX_STATE_BLOB_SIZE);
182196
EEPROM.commit();
183197
}
184-
}
198+
}

0 commit comments

Comments
 (0)