From d5565c99e67a873521e640005ab3768f71b19d77 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Mon, 26 Nov 2018 16:12:41 +0100 Subject: [PATCH] BME680: bugfix pressure value conversion; feature temperature offset --- src/bme680mems.cpp | 8 +++++--- src/paxcounter.conf | 5 ++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/bme680mems.cpp b/src/bme680mems.cpp index 82a4b6f7..88ed85b2 100644 --- a/src/bme680mems.cpp +++ b/src/bme680mems.cpp @@ -8,6 +8,8 @@ static const char TAG[] = "main"; bmeStatus_t bme_status; TaskHandle_t BmeTask; +float bme_offset = (float) BME_TEMP_OFFSET; + // --- Bosch BSEC library configuration --- // 3,3V supply voltage; 3s max time between sensor_control calls; 4 days // calibration. Change this const if not applicable for your application (see @@ -55,9 +57,9 @@ int bme_init(void) { // Switch on low-power mode and provide no temperature offset return_values_init ret = - bsec_iot_init(BSEC_SAMPLE_RATE_LP, 0.0f, i2c_write, i2c_read, + bsec_iot_init(BSEC_SAMPLE_RATE_LP, bme_offset, i2c_write, i2c_read, user_delay_ms, state_load, config_load); - + if ((int)ret.bme680_status) { ESP_LOGE(TAG, "Could not initialize BME680, error %d", (int)ret.bme680_status); @@ -79,7 +81,7 @@ void output_ready(int64_t timestamp, float iaq, uint8_t iaq_accuracy, bme_status.temperature = temperature; bme_status.humidity = humidity; - bme_status.pressure = pressure; + bme_status.pressure = (pressure / 100.0); // conversion Pa -> hPa bme_status.iaq = iaq; } diff --git a/src/paxcounter.conf b/src/paxcounter.conf index 460e9c7e..89d55981 100644 --- a/src/paxcounter.conf +++ b/src/paxcounter.conf @@ -11,7 +11,7 @@ // Payload send cycle and encoding #define SEND_SECS 30 // payload send cycle [seconds/2] -> 60 sec. -#define PAYLOAD_ENCODER 2 // payload encoder: 1=Plain, 2=Packed, 3=CayenneLPP dynamic, 4=CayenneLPP packed +#define PAYLOAD_ENCODER 3 // payload encoder: 1=Plain, 2=Packed, 3=CayenneLPP dynamic, 4=CayenneLPP packed // Set this to include BLE counting and vendor filter functions #define VENDORFILTER 1 // comment out if you want to count things, not people @@ -70,6 +70,9 @@ #define DISPLAYREFRESH_MS 40 // OLED refresh cycle in ms [default = 40] -> 1000/40 = 25 frames per second #define HOMECYCLE 30 // house keeping cycle in seconds [default = 30 secs] +// Settings for BME680 environmental sensor (if present) +#define BME_TEMP_OFFSET 5.0f // Offset sensor on chip temp <-> ambient temp [default = 5°C] + // OTA settings #define USE_OTA 1 // Comment out to disable OTA update #define WIFI_MAX_TRY 5 // maximum number of wifi connect attempts for OTA update [default = 20]