diff options
author | Daniel Friesel <daniel.friesel@uos.de> | 2019-10-25 13:38:50 +0200 |
---|---|---|
committer | Daniel Friesel <daniel.friesel@uos.de> | 2019-10-25 13:38:50 +0200 |
commit | a4cad3173fc49cc0286f6eedf6efbca15db6688e (patch) | |
tree | a13cf0073e9cde9addfa8fa4456c9abf96f9d13d /src/app | |
parent | 6cf0c6ea48f4fd538a057b1d3a62e137ca884864 (diff) |
BME280 driver: normalize API, add i2cdetect test
Diffstat (limited to 'src/app')
-rw-r--r-- | src/app/i2cdetect/main.cc | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/app/i2cdetect/main.cc b/src/app/i2cdetect/main.cc index e235369..faa2725 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_BME280 +#include "driver/bme280.h" +#include "driver/bme680_util.h" +#endif #ifdef DRIVER_BME680 #include "driver/bme680.h" #include "driver/bme680_util.h" @@ -52,6 +56,30 @@ void loop(void) kout << "AM2320 error " << dec << am2320.getStatus() << endl; } #endif +#ifdef DRIVER_BME280 + bme280.intf = BME280_I2C_INTF; + bme280.read = bme680_i2c_read; + bme280.write = bme680_i2c_write; + bme280.delay_ms = bme680_delay_ms; + + int8_t rslt = BME280_OK; + struct bme280_data comp_data; + rslt = bme280.init(); + kout << "BME280 init " << rslt << endl; + bme280.settings.osr_p = BME280_OVERSAMPLING_16X; + bme280.settings.osr_t = BME280_OVERSAMPLING_16X; + bme280.settings.osr_h = BME280_OVERSAMPLING_16X; + bme280.settings.filter = BME280_FILTER_COEFF_OFF; + bme280.settings.standby_time = BME280_STANDBY_TIME_500_MS; + bme280.setSensorSettings(BME280_OSR_PRESS_SEL | BME280_OSR_TEMP_SEL | BME280_OSR_HUM_SEL | BME280_FILTER_SEL | BME280_STANDBY_SEL); + bme280.setSensorMode(BME280_NORMAL_MODE); + arch.delay_ms(100); + rslt = bme280.getSensorData(BME280_ALL, &comp_data); + kout << "BME280 read " << rslt << endl; + kout << "BME280 temperature " << (float)comp_data.temperature / 100 << " degC" << endl; + kout << "BME280 humidity " << (float)comp_data.humidity / 1024 << " %" << endl; + kout << "BME280 pressure " << (float)comp_data.pressure / 100 << " Pa" << endl; +#endif #ifdef DRIVER_BME680 bme680.intf = BME680_I2C_INTF; bme680.read = bme680_i2c_read; |