summaryrefslogtreecommitdiff
path: root/src/app
diff options
context:
space:
mode:
Diffstat (limited to 'src/app')
-rw-r--r--src/app/i2cdetect/main.cc39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/app/i2cdetect/main.cc b/src/app/i2cdetect/main.cc
index a31dbc9..2b30b47 100644
--- a/src/app/i2cdetect/main.cc
+++ b/src/app/i2cdetect/main.cc
@@ -12,6 +12,10 @@
#ifdef DRIVER_AM2320
#include "driver/am2320.h"
#endif
+#ifdef DRIVER_BME680
+#include "driver/bme680.h"
+#include "driver/bme680_util.h"
+#endif
#ifdef DRIVER_CCS811
#include "driver/ccs811.h"
#endif
@@ -42,6 +46,41 @@ void loop(void)
kout << "AM2320 error " << dec << am2320.getStatus() << endl;
}
#endif
+#ifdef DRIVER_BME680
+ struct bme680_dev gas_sensor;
+
+ gas_sensor.dev_id = BME680_I2C_ADDR_SECONDARY;
+ gas_sensor.intf = BME680_I2C_INTF;
+ gas_sensor.read = bme680_i2c_read;
+ gas_sensor.write = bme680_i2c_write;
+ gas_sensor.delay_ms = bme680_delay_ms;
+ /* amb_temp can be set to 25 prior to configuring the gas sensor
+ * or by performing a few temperature readings without operating the gas sensor.
+ */
+ gas_sensor.amb_temp = 25;
+
+ int8_t rslt = BME680_OK;
+ rslt = bme680_init(&gas_sensor);
+ kout << "BME680 init " << rslt << endl;
+
+ gas_sensor.power_mode = BME680_FORCED_MODE;
+ gas_sensor.tph_sett.os_hum = BME680_OS_1X;
+ gas_sensor.tph_sett.os_pres = BME680_OS_16X;
+ gas_sensor.tph_sett.os_temp = BME680_OS_2X;
+
+ gas_sensor.gas_sett.run_gas = BME680_ENABLE_GAS_MEAS;
+ gas_sensor.gas_sett.heatr_dur = 150;
+ gas_sensor.gas_sett.heatr_temp = 300;
+ bme680_set_sensor_settings(BME680_OST_SEL | BME680_OSP_SEL | BME680_OSH_SEL | BME680_GAS_SENSOR_SEL, &gas_sensor);
+ bme680_set_sensor_mode(&gas_sensor);
+ arch.delay_ms(500);
+ struct bme680_field_data data;
+ bme680_get_sensor_data(&data, &gas_sensor);
+ kout << "BME680 temperature " << (float)data.temperature / 100 << " degC" << endl;
+ kout << "BME680 humidity " << (float)data.humidity / 1000 << " %" << endl;
+ kout << "BME680 pressure " << (float)data.pressure / 100 << " hPa" << endl;
+ kout << "BME680 gas resistance " << data.gas_resistance << endl;
+#endif
#ifdef DRIVER_CCS811
kout << "CCS811 status is " << ccs811.check() << endl;
#endif