From 8f201e066f1e800e88338603c86ba3d2aff603f7 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Thu, 22 Nov 2018 23:37:53 +0100 Subject: [PATCH] BOSCH BSEC integration --- include/bme680.h | 15 --- include/bme680mems.h | 23 ++++ include/globals.h | 2 +- .../LICENSE | 0 .../README.md | 0 .../bme680.c | 0 .../bme680.h | 0 .../bme680_defs.h | 0 .../bsec_datatypes.h | 0 .../bsec_interface.h | 0 .../generic_18v_300s_28d/bsec_iaq.config | Bin .../config/generic_18v_300s_28d/bsec_iaq.csv | 0 .../bsec_serialized_configurations_iaq.c | 0 .../bsec_serialized_configurations_iaq.h | 0 .../generic_18v_300s_4d/bsec_iaq.config | Bin .../config/generic_18v_300s_4d/bsec_iaq.csv | 0 .../bsec_serialized_configurations_iaq.c | 0 .../bsec_serialized_configurations_iaq.h | 0 .../config/generic_18v_3s_28d/bsec_iaq.config | Bin .../config/generic_18v_3s_28d/bsec_iaq.csv | 0 .../bsec_serialized_configurations_iaq.c | 0 .../bsec_serialized_configurations_iaq.h | 0 .../config/generic_18v_3s_4d/bsec_iaq.config | Bin .../config/generic_18v_3s_4d/bsec_iaq.csv | 0 .../bsec_serialized_configurations_iaq.c | 0 .../bsec_serialized_configurations_iaq.h | 0 .../generic_33v_300s_28d/bsec_iaq.config | Bin .../config/generic_33v_300s_28d/bsec_iaq.csv | 0 .../bsec_serialized_configurations_iaq.c | 0 .../bsec_serialized_configurations_iaq.h | 0 .../generic_33v_300s_4d/bsec_iaq.config | Bin .../config/generic_33v_300s_4d/bsec_iaq.csv | 0 .../bsec_serialized_configurations_iaq.c | 0 .../bsec_serialized_configurations_iaq.h | 0 .../config/generic_33v_3s_28d/bsec_iaq.config | Bin .../config/generic_33v_3s_28d/bsec_iaq.csv | 0 .../bsec_serialized_configurations_iaq.c | 0 .../bsec_serialized_configurations_iaq.h | 0 .../config/generic_33v_3s_4d/bsec_iaq.config | Bin .../config/generic_33v_3s_4d/bsec_iaq.csv | 0 .../bsec_serialized_configurations_iaq.c | 0 .../bsec_serialized_configurations_iaq.h | 0 .../docs/BSEC - release notes_1.4.7.1.pdf | Bin .../docs/BSEC_Binary_Size_Information.pdf | Bin .../BST-BME680-Integration-Guide-AN008-47.pdf | 0 .../examples/bsec_integration.c | 0 .../examples/bsec_integration.h | 0 .../examples/bsec_iot_example.c | 0 .../examples/bsec_iot_example.ino | 0 .../examples/bsec_iot_ulp_plus_example.c | 0 .../examples/bsec_iot_ulp_plus_example.ino | 0 .../libalgobsec.a | Bin .../libalgobsec.a.Size.log | 0 platformio.ini | 6 +- src/bme680.cpp | 44 ------ src/bme680mems.cpp | 127 ++++++++++++++++++ src/hal/generic.h | 11 +- src/hal/ttgobeam.h | 7 +- 58 files changed, 168 insertions(+), 67 deletions(-) delete mode 100644 include/bme680.h create mode 100644 include/bme680mems.h rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/LICENSE (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/README.md (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/bme680.c (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/bme680.h (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/bme680_defs.h (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/bsec_datatypes.h (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/bsec_interface.h (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/config/generic_18v_300s_28d/bsec_iaq.config (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/config/generic_18v_300s_28d/bsec_iaq.csv (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/config/generic_18v_300s_28d/bsec_serialized_configurations_iaq.c (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/config/generic_18v_300s_28d/bsec_serialized_configurations_iaq.h (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/config/generic_18v_300s_4d/bsec_iaq.config (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/config/generic_18v_300s_4d/bsec_iaq.csv (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/config/generic_18v_300s_4d/bsec_serialized_configurations_iaq.c (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/config/generic_18v_300s_4d/bsec_serialized_configurations_iaq.h (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/config/generic_18v_3s_28d/bsec_iaq.config (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/config/generic_18v_3s_28d/bsec_iaq.csv (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/config/generic_18v_3s_28d/bsec_serialized_configurations_iaq.c (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/config/generic_18v_3s_28d/bsec_serialized_configurations_iaq.h (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/config/generic_18v_3s_4d/bsec_iaq.config (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/config/generic_18v_3s_4d/bsec_iaq.csv (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/config/generic_18v_3s_4d/bsec_serialized_configurations_iaq.c (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/config/generic_18v_3s_4d/bsec_serialized_configurations_iaq.h (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/config/generic_33v_300s_28d/bsec_iaq.config (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/config/generic_33v_300s_28d/bsec_iaq.csv (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/config/generic_33v_300s_28d/bsec_serialized_configurations_iaq.c (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/config/generic_33v_300s_28d/bsec_serialized_configurations_iaq.h (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/config/generic_33v_300s_4d/bsec_iaq.config (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/config/generic_33v_300s_4d/bsec_iaq.csv (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/config/generic_33v_300s_4d/bsec_serialized_configurations_iaq.c (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/config/generic_33v_300s_4d/bsec_serialized_configurations_iaq.h (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/config/generic_33v_3s_28d/bsec_iaq.config (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/config/generic_33v_3s_28d/bsec_iaq.csv (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/config/generic_33v_3s_28d/bsec_serialized_configurations_iaq.c (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/config/generic_33v_3s_28d/bsec_serialized_configurations_iaq.h (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/config/generic_33v_3s_4d/bsec_iaq.config (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/config/generic_33v_3s_4d/bsec_iaq.csv (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/config/generic_33v_3s_4d/bsec_serialized_configurations_iaq.c (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/config/generic_33v_3s_4d/bsec_serialized_configurations_iaq.h (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/docs/BSEC - release notes_1.4.7.1.pdf (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/docs/BSEC_Binary_Size_Information.pdf (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/docs/BST-BME680-Integration-Guide-AN008-47.pdf (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/examples/bsec_integration.c (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/examples/bsec_integration.h (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/examples/bsec_iot_example.c (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/examples/bsec_iot_example.ino (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/examples/bsec_iot_ulp_plus_example.c (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/examples/bsec_iot_ulp_plus_example.ino (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/libalgobsec.a (100%) rename lib/{Bosch-BSEC-1.4.7.1 => Bosch-BSEC}/libalgobsec.a.Size.log (100%) delete mode 100644 src/bme680.cpp create mode 100644 src/bme680mems.cpp diff --git a/include/bme680.h b/include/bme680.h deleted file mode 100644 index 6b8e3827..00000000 --- a/include/bme680.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef _BME680_H -#define _BME680_H - -#include "globals.h" -#include -#include -#include "Adafruit_BME680.h" - -extern bmeStatus_t - bme_status; // Make struct for storing gps data globally available - -void bme_init(); -bool bme_read(); - -#endif \ No newline at end of file diff --git a/include/bme680mems.h b/include/bme680mems.h new file mode 100644 index 00000000..9714cf84 --- /dev/null +++ b/include/bme680mems.h @@ -0,0 +1,23 @@ +#ifndef _BME680MEMS_H +#define _BME680MEMS_H + +#include "globals.h" +#include +#include "bme680.h" +#include "bsec_interface.h" +#include "bsec_datatypes.h" +//#include "bme680_defs.h" +//#include "bme680.c" + +extern bmeStatus_t + bme_status; // Make struct for storing gps data globally available + +void bme_init(); +bool bme_read(); +void user_delay_ms(uint32_t period); +int8_t user_i2c_read(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, + uint16_t len); +int8_t user_i2c_write(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, + uint16_t len); + +#endif \ No newline at end of file diff --git a/include/globals.h b/include/globals.h index 7b68c88d..ef9b8b49 100644 --- a/include/globals.h +++ b/include/globals.h @@ -95,7 +95,7 @@ extern TaskHandle_t irqHandlerTask, wifiSwitchTask; #endif #ifdef HAS_BME -#include "bme680.h" +#include "bme680mems.h" #endif #ifdef HAS_LORA diff --git a/lib/Bosch-BSEC-1.4.7.1/LICENSE b/lib/Bosch-BSEC/LICENSE similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/LICENSE rename to lib/Bosch-BSEC/LICENSE diff --git a/lib/Bosch-BSEC-1.4.7.1/README.md b/lib/Bosch-BSEC/README.md similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/README.md rename to lib/Bosch-BSEC/README.md diff --git a/lib/Bosch-BSEC-1.4.7.1/bme680.c b/lib/Bosch-BSEC/bme680.c similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/bme680.c rename to lib/Bosch-BSEC/bme680.c diff --git a/lib/Bosch-BSEC-1.4.7.1/bme680.h b/lib/Bosch-BSEC/bme680.h similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/bme680.h rename to lib/Bosch-BSEC/bme680.h diff --git a/lib/Bosch-BSEC-1.4.7.1/bme680_defs.h b/lib/Bosch-BSEC/bme680_defs.h similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/bme680_defs.h rename to lib/Bosch-BSEC/bme680_defs.h diff --git a/lib/Bosch-BSEC-1.4.7.1/bsec_datatypes.h b/lib/Bosch-BSEC/bsec_datatypes.h similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/bsec_datatypes.h rename to lib/Bosch-BSEC/bsec_datatypes.h diff --git a/lib/Bosch-BSEC-1.4.7.1/bsec_interface.h b/lib/Bosch-BSEC/bsec_interface.h similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/bsec_interface.h rename to lib/Bosch-BSEC/bsec_interface.h diff --git a/lib/Bosch-BSEC-1.4.7.1/config/generic_18v_300s_28d/bsec_iaq.config b/lib/Bosch-BSEC/config/generic_18v_300s_28d/bsec_iaq.config similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/config/generic_18v_300s_28d/bsec_iaq.config rename to lib/Bosch-BSEC/config/generic_18v_300s_28d/bsec_iaq.config diff --git a/lib/Bosch-BSEC-1.4.7.1/config/generic_18v_300s_28d/bsec_iaq.csv b/lib/Bosch-BSEC/config/generic_18v_300s_28d/bsec_iaq.csv similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/config/generic_18v_300s_28d/bsec_iaq.csv rename to lib/Bosch-BSEC/config/generic_18v_300s_28d/bsec_iaq.csv diff --git a/lib/Bosch-BSEC-1.4.7.1/config/generic_18v_300s_28d/bsec_serialized_configurations_iaq.c b/lib/Bosch-BSEC/config/generic_18v_300s_28d/bsec_serialized_configurations_iaq.c similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/config/generic_18v_300s_28d/bsec_serialized_configurations_iaq.c rename to lib/Bosch-BSEC/config/generic_18v_300s_28d/bsec_serialized_configurations_iaq.c diff --git a/lib/Bosch-BSEC-1.4.7.1/config/generic_18v_300s_28d/bsec_serialized_configurations_iaq.h b/lib/Bosch-BSEC/config/generic_18v_300s_28d/bsec_serialized_configurations_iaq.h similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/config/generic_18v_300s_28d/bsec_serialized_configurations_iaq.h rename to lib/Bosch-BSEC/config/generic_18v_300s_28d/bsec_serialized_configurations_iaq.h diff --git a/lib/Bosch-BSEC-1.4.7.1/config/generic_18v_300s_4d/bsec_iaq.config b/lib/Bosch-BSEC/config/generic_18v_300s_4d/bsec_iaq.config similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/config/generic_18v_300s_4d/bsec_iaq.config rename to lib/Bosch-BSEC/config/generic_18v_300s_4d/bsec_iaq.config diff --git a/lib/Bosch-BSEC-1.4.7.1/config/generic_18v_300s_4d/bsec_iaq.csv b/lib/Bosch-BSEC/config/generic_18v_300s_4d/bsec_iaq.csv similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/config/generic_18v_300s_4d/bsec_iaq.csv rename to lib/Bosch-BSEC/config/generic_18v_300s_4d/bsec_iaq.csv diff --git a/lib/Bosch-BSEC-1.4.7.1/config/generic_18v_300s_4d/bsec_serialized_configurations_iaq.c b/lib/Bosch-BSEC/config/generic_18v_300s_4d/bsec_serialized_configurations_iaq.c similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/config/generic_18v_300s_4d/bsec_serialized_configurations_iaq.c rename to lib/Bosch-BSEC/config/generic_18v_300s_4d/bsec_serialized_configurations_iaq.c diff --git a/lib/Bosch-BSEC-1.4.7.1/config/generic_18v_300s_4d/bsec_serialized_configurations_iaq.h b/lib/Bosch-BSEC/config/generic_18v_300s_4d/bsec_serialized_configurations_iaq.h similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/config/generic_18v_300s_4d/bsec_serialized_configurations_iaq.h rename to lib/Bosch-BSEC/config/generic_18v_300s_4d/bsec_serialized_configurations_iaq.h diff --git a/lib/Bosch-BSEC-1.4.7.1/config/generic_18v_3s_28d/bsec_iaq.config b/lib/Bosch-BSEC/config/generic_18v_3s_28d/bsec_iaq.config similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/config/generic_18v_3s_28d/bsec_iaq.config rename to lib/Bosch-BSEC/config/generic_18v_3s_28d/bsec_iaq.config diff --git a/lib/Bosch-BSEC-1.4.7.1/config/generic_18v_3s_28d/bsec_iaq.csv b/lib/Bosch-BSEC/config/generic_18v_3s_28d/bsec_iaq.csv similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/config/generic_18v_3s_28d/bsec_iaq.csv rename to lib/Bosch-BSEC/config/generic_18v_3s_28d/bsec_iaq.csv diff --git a/lib/Bosch-BSEC-1.4.7.1/config/generic_18v_3s_28d/bsec_serialized_configurations_iaq.c b/lib/Bosch-BSEC/config/generic_18v_3s_28d/bsec_serialized_configurations_iaq.c similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/config/generic_18v_3s_28d/bsec_serialized_configurations_iaq.c rename to lib/Bosch-BSEC/config/generic_18v_3s_28d/bsec_serialized_configurations_iaq.c diff --git a/lib/Bosch-BSEC-1.4.7.1/config/generic_18v_3s_28d/bsec_serialized_configurations_iaq.h b/lib/Bosch-BSEC/config/generic_18v_3s_28d/bsec_serialized_configurations_iaq.h similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/config/generic_18v_3s_28d/bsec_serialized_configurations_iaq.h rename to lib/Bosch-BSEC/config/generic_18v_3s_28d/bsec_serialized_configurations_iaq.h diff --git a/lib/Bosch-BSEC-1.4.7.1/config/generic_18v_3s_4d/bsec_iaq.config b/lib/Bosch-BSEC/config/generic_18v_3s_4d/bsec_iaq.config similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/config/generic_18v_3s_4d/bsec_iaq.config rename to lib/Bosch-BSEC/config/generic_18v_3s_4d/bsec_iaq.config diff --git a/lib/Bosch-BSEC-1.4.7.1/config/generic_18v_3s_4d/bsec_iaq.csv b/lib/Bosch-BSEC/config/generic_18v_3s_4d/bsec_iaq.csv similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/config/generic_18v_3s_4d/bsec_iaq.csv rename to lib/Bosch-BSEC/config/generic_18v_3s_4d/bsec_iaq.csv diff --git a/lib/Bosch-BSEC-1.4.7.1/config/generic_18v_3s_4d/bsec_serialized_configurations_iaq.c b/lib/Bosch-BSEC/config/generic_18v_3s_4d/bsec_serialized_configurations_iaq.c similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/config/generic_18v_3s_4d/bsec_serialized_configurations_iaq.c rename to lib/Bosch-BSEC/config/generic_18v_3s_4d/bsec_serialized_configurations_iaq.c diff --git a/lib/Bosch-BSEC-1.4.7.1/config/generic_18v_3s_4d/bsec_serialized_configurations_iaq.h b/lib/Bosch-BSEC/config/generic_18v_3s_4d/bsec_serialized_configurations_iaq.h similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/config/generic_18v_3s_4d/bsec_serialized_configurations_iaq.h rename to lib/Bosch-BSEC/config/generic_18v_3s_4d/bsec_serialized_configurations_iaq.h diff --git a/lib/Bosch-BSEC-1.4.7.1/config/generic_33v_300s_28d/bsec_iaq.config b/lib/Bosch-BSEC/config/generic_33v_300s_28d/bsec_iaq.config similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/config/generic_33v_300s_28d/bsec_iaq.config rename to lib/Bosch-BSEC/config/generic_33v_300s_28d/bsec_iaq.config diff --git a/lib/Bosch-BSEC-1.4.7.1/config/generic_33v_300s_28d/bsec_iaq.csv b/lib/Bosch-BSEC/config/generic_33v_300s_28d/bsec_iaq.csv similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/config/generic_33v_300s_28d/bsec_iaq.csv rename to lib/Bosch-BSEC/config/generic_33v_300s_28d/bsec_iaq.csv diff --git a/lib/Bosch-BSEC-1.4.7.1/config/generic_33v_300s_28d/bsec_serialized_configurations_iaq.c b/lib/Bosch-BSEC/config/generic_33v_300s_28d/bsec_serialized_configurations_iaq.c similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/config/generic_33v_300s_28d/bsec_serialized_configurations_iaq.c rename to lib/Bosch-BSEC/config/generic_33v_300s_28d/bsec_serialized_configurations_iaq.c diff --git a/lib/Bosch-BSEC-1.4.7.1/config/generic_33v_300s_28d/bsec_serialized_configurations_iaq.h b/lib/Bosch-BSEC/config/generic_33v_300s_28d/bsec_serialized_configurations_iaq.h similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/config/generic_33v_300s_28d/bsec_serialized_configurations_iaq.h rename to lib/Bosch-BSEC/config/generic_33v_300s_28d/bsec_serialized_configurations_iaq.h diff --git a/lib/Bosch-BSEC-1.4.7.1/config/generic_33v_300s_4d/bsec_iaq.config b/lib/Bosch-BSEC/config/generic_33v_300s_4d/bsec_iaq.config similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/config/generic_33v_300s_4d/bsec_iaq.config rename to lib/Bosch-BSEC/config/generic_33v_300s_4d/bsec_iaq.config diff --git a/lib/Bosch-BSEC-1.4.7.1/config/generic_33v_300s_4d/bsec_iaq.csv b/lib/Bosch-BSEC/config/generic_33v_300s_4d/bsec_iaq.csv similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/config/generic_33v_300s_4d/bsec_iaq.csv rename to lib/Bosch-BSEC/config/generic_33v_300s_4d/bsec_iaq.csv diff --git a/lib/Bosch-BSEC-1.4.7.1/config/generic_33v_300s_4d/bsec_serialized_configurations_iaq.c b/lib/Bosch-BSEC/config/generic_33v_300s_4d/bsec_serialized_configurations_iaq.c similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/config/generic_33v_300s_4d/bsec_serialized_configurations_iaq.c rename to lib/Bosch-BSEC/config/generic_33v_300s_4d/bsec_serialized_configurations_iaq.c diff --git a/lib/Bosch-BSEC-1.4.7.1/config/generic_33v_300s_4d/bsec_serialized_configurations_iaq.h b/lib/Bosch-BSEC/config/generic_33v_300s_4d/bsec_serialized_configurations_iaq.h similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/config/generic_33v_300s_4d/bsec_serialized_configurations_iaq.h rename to lib/Bosch-BSEC/config/generic_33v_300s_4d/bsec_serialized_configurations_iaq.h diff --git a/lib/Bosch-BSEC-1.4.7.1/config/generic_33v_3s_28d/bsec_iaq.config b/lib/Bosch-BSEC/config/generic_33v_3s_28d/bsec_iaq.config similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/config/generic_33v_3s_28d/bsec_iaq.config rename to lib/Bosch-BSEC/config/generic_33v_3s_28d/bsec_iaq.config diff --git a/lib/Bosch-BSEC-1.4.7.1/config/generic_33v_3s_28d/bsec_iaq.csv b/lib/Bosch-BSEC/config/generic_33v_3s_28d/bsec_iaq.csv similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/config/generic_33v_3s_28d/bsec_iaq.csv rename to lib/Bosch-BSEC/config/generic_33v_3s_28d/bsec_iaq.csv diff --git a/lib/Bosch-BSEC-1.4.7.1/config/generic_33v_3s_28d/bsec_serialized_configurations_iaq.c b/lib/Bosch-BSEC/config/generic_33v_3s_28d/bsec_serialized_configurations_iaq.c similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/config/generic_33v_3s_28d/bsec_serialized_configurations_iaq.c rename to lib/Bosch-BSEC/config/generic_33v_3s_28d/bsec_serialized_configurations_iaq.c diff --git a/lib/Bosch-BSEC-1.4.7.1/config/generic_33v_3s_28d/bsec_serialized_configurations_iaq.h b/lib/Bosch-BSEC/config/generic_33v_3s_28d/bsec_serialized_configurations_iaq.h similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/config/generic_33v_3s_28d/bsec_serialized_configurations_iaq.h rename to lib/Bosch-BSEC/config/generic_33v_3s_28d/bsec_serialized_configurations_iaq.h diff --git a/lib/Bosch-BSEC-1.4.7.1/config/generic_33v_3s_4d/bsec_iaq.config b/lib/Bosch-BSEC/config/generic_33v_3s_4d/bsec_iaq.config similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/config/generic_33v_3s_4d/bsec_iaq.config rename to lib/Bosch-BSEC/config/generic_33v_3s_4d/bsec_iaq.config diff --git a/lib/Bosch-BSEC-1.4.7.1/config/generic_33v_3s_4d/bsec_iaq.csv b/lib/Bosch-BSEC/config/generic_33v_3s_4d/bsec_iaq.csv similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/config/generic_33v_3s_4d/bsec_iaq.csv rename to lib/Bosch-BSEC/config/generic_33v_3s_4d/bsec_iaq.csv diff --git a/lib/Bosch-BSEC-1.4.7.1/config/generic_33v_3s_4d/bsec_serialized_configurations_iaq.c b/lib/Bosch-BSEC/config/generic_33v_3s_4d/bsec_serialized_configurations_iaq.c similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/config/generic_33v_3s_4d/bsec_serialized_configurations_iaq.c rename to lib/Bosch-BSEC/config/generic_33v_3s_4d/bsec_serialized_configurations_iaq.c diff --git a/lib/Bosch-BSEC-1.4.7.1/config/generic_33v_3s_4d/bsec_serialized_configurations_iaq.h b/lib/Bosch-BSEC/config/generic_33v_3s_4d/bsec_serialized_configurations_iaq.h similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/config/generic_33v_3s_4d/bsec_serialized_configurations_iaq.h rename to lib/Bosch-BSEC/config/generic_33v_3s_4d/bsec_serialized_configurations_iaq.h diff --git a/lib/Bosch-BSEC-1.4.7.1/docs/BSEC - release notes_1.4.7.1.pdf b/lib/Bosch-BSEC/docs/BSEC - release notes_1.4.7.1.pdf similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/docs/BSEC - release notes_1.4.7.1.pdf rename to lib/Bosch-BSEC/docs/BSEC - release notes_1.4.7.1.pdf diff --git a/lib/Bosch-BSEC-1.4.7.1/docs/BSEC_Binary_Size_Information.pdf b/lib/Bosch-BSEC/docs/BSEC_Binary_Size_Information.pdf similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/docs/BSEC_Binary_Size_Information.pdf rename to lib/Bosch-BSEC/docs/BSEC_Binary_Size_Information.pdf diff --git a/lib/Bosch-BSEC-1.4.7.1/docs/BST-BME680-Integration-Guide-AN008-47.pdf b/lib/Bosch-BSEC/docs/BST-BME680-Integration-Guide-AN008-47.pdf similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/docs/BST-BME680-Integration-Guide-AN008-47.pdf rename to lib/Bosch-BSEC/docs/BST-BME680-Integration-Guide-AN008-47.pdf diff --git a/lib/Bosch-BSEC-1.4.7.1/examples/bsec_integration.c b/lib/Bosch-BSEC/examples/bsec_integration.c similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/examples/bsec_integration.c rename to lib/Bosch-BSEC/examples/bsec_integration.c diff --git a/lib/Bosch-BSEC-1.4.7.1/examples/bsec_integration.h b/lib/Bosch-BSEC/examples/bsec_integration.h similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/examples/bsec_integration.h rename to lib/Bosch-BSEC/examples/bsec_integration.h diff --git a/lib/Bosch-BSEC-1.4.7.1/examples/bsec_iot_example.c b/lib/Bosch-BSEC/examples/bsec_iot_example.c similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/examples/bsec_iot_example.c rename to lib/Bosch-BSEC/examples/bsec_iot_example.c diff --git a/lib/Bosch-BSEC-1.4.7.1/examples/bsec_iot_example.ino b/lib/Bosch-BSEC/examples/bsec_iot_example.ino similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/examples/bsec_iot_example.ino rename to lib/Bosch-BSEC/examples/bsec_iot_example.ino diff --git a/lib/Bosch-BSEC-1.4.7.1/examples/bsec_iot_ulp_plus_example.c b/lib/Bosch-BSEC/examples/bsec_iot_ulp_plus_example.c similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/examples/bsec_iot_ulp_plus_example.c rename to lib/Bosch-BSEC/examples/bsec_iot_ulp_plus_example.c diff --git a/lib/Bosch-BSEC-1.4.7.1/examples/bsec_iot_ulp_plus_example.ino b/lib/Bosch-BSEC/examples/bsec_iot_ulp_plus_example.ino similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/examples/bsec_iot_ulp_plus_example.ino rename to lib/Bosch-BSEC/examples/bsec_iot_ulp_plus_example.ino diff --git a/lib/Bosch-BSEC-1.4.7.1/libalgobsec.a b/lib/Bosch-BSEC/libalgobsec.a similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/libalgobsec.a rename to lib/Bosch-BSEC/libalgobsec.a diff --git a/lib/Bosch-BSEC-1.4.7.1/libalgobsec.a.Size.log b/lib/Bosch-BSEC/libalgobsec.a.Size.log similarity index 100% rename from lib/Bosch-BSEC-1.4.7.1/libalgobsec.a.Size.log rename to lib/Bosch-BSEC/libalgobsec.a.Size.log diff --git a/platformio.ini b/platformio.ini index 48a64f53..3054840a 100644 --- a/platformio.ini +++ b/platformio.ini @@ -50,13 +50,9 @@ lib_deps_rgbled = SmartLeds@>=1.1.3 lib_deps_gps = TinyGPSPlus@>=1.0.2 -lib_deps_sensors = - Adafruit Unified Sensor@^1.0.2 - Adafruit BME680 Library@^1.0.7 lib_deps_basic = ArduinoJson@^5.13.1 Time@>=1.5 - ${common.lib_deps_sensors} lib_deps_all = ${common.lib_deps_basic} ${common.lib_deps_lora} @@ -64,6 +60,8 @@ lib_deps_all = ${common.lib_deps_rgbled} ${common.lib_deps_gps} build_flags = + -Llib/Bosch-BSEC + -llibalgobsec.a -include src/hal/${PIOENV}.h -include src/paxcounter.conf -w diff --git a/src/bme680.cpp b/src/bme680.cpp deleted file mode 100644 index 22c7b684..00000000 --- a/src/bme680.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#ifdef HAS_BME - -#include "bme680.h" - -// Local logging tag -static const char TAG[] = "main"; - -#define SEALEVELPRESSURE_HPA (1013.25) - -// I2C Bus interface -Adafruit_BME680 bme; - -bmeStatus_t bme_status; - -void bme_init(void) { - // initialize BME680 sensor using default i2c address 0x77 - if (bme.begin(HAS_BME)) { - // Set up oversampling and filter initialization - bme.setTemperatureOversampling(BME680_OS_8X); - bme.setHumidityOversampling(BME680_OS_2X); - bme.setPressureOversampling(BME680_OS_4X); - bme.setIIRFilterSize(BME680_FILTER_SIZE_3); - bme.setGasHeater(320, 150); // 320*C for 150 ms - ESP_LOGI(TAG, "BME680 chip found and initialized"); - } else - ESP_LOGE(TAG, "BME680 chip not found on i2c bus"); -} - -bool bme_read(void) { - bool ret = bme.performReading(); - if (ret) { - // read current BME data and buffer in global struct - bme_status.temperature = bme.temperature; - bme_status.pressure = (uint16_t)(bme.pressure / 100.0); // convert Pa -> hPa - bme_status.humidity = bme.humidity; - bme_status.gas_resistance = (uint16_t)(bme.gas_resistance / 1000.0); // convert Ohm -> kOhm - ESP_LOGI(TAG, "BME680 sensor data read success"); - } else { - ESP_LOGI(TAG, "BME680 sensor read error"); - } - return ret; -} - -#endif // HAS_BME \ No newline at end of file diff --git a/src/bme680mems.cpp b/src/bme680mems.cpp new file mode 100644 index 00000000..6d98dd77 --- /dev/null +++ b/src/bme680mems.cpp @@ -0,0 +1,127 @@ +#ifdef HAS_BME + +#include "bme680mems.h" + +// Local logging tag +static const char TAG[] = "main"; + +bmeStatus_t bme_status; + +void bme_init(void) { + + // initialize BME680 sensor + + struct bme680_dev gas_sensor; + + Wire.begin(HAS_BME, 400000); // I2C connect to BME680 sensor with 400 KHz + + // configure sensor for I2C communication + gas_sensor.dev_id = BME_ADDR; + gas_sensor.intf = BME680_I2C_INTF; + gas_sensor.read = user_i2c_read; + gas_sensor.write = user_i2c_write; + gas_sensor.delay_ms = user_delay_ms; + gas_sensor.amb_temp = 25; + + int8_t rslt = BME680_OK; + rslt = bme680_init(&gas_sensor); + + if (rslt == BME680_OK) { + ESP_LOGI(TAG, "BME680 sensor found"); + } else { + ESP_LOGE(TAG, "BME680 sensor not found on i2c bus"); + return; + } + + // configure BME680 sensor in forced mode + + uint8_t set_required_settings; + + /* Set the temperature, pressure and humidity settings */ + gas_sensor.tph_sett.os_hum = BME680_OS_2X; + gas_sensor.tph_sett.os_pres = BME680_OS_4X; + gas_sensor.tph_sett.os_temp = BME680_OS_8X; + gas_sensor.tph_sett.filter = BME680_FILTER_SIZE_3; + + /* Set the remaining gas sensor settings and link the heating profile */ + gas_sensor.gas_sett.run_gas = BME680_ENABLE_GAS_MEAS; + /* Create a ramp heat waveform in 3 steps */ + gas_sensor.gas_sett.heatr_temp = 320; /* degree Celsius */ + gas_sensor.gas_sett.heatr_dur = 150; /* milliseconds */ + + /* Select the power mode */ + /* Must be set before writing the sensor configuration */ + gas_sensor.power_mode = BME680_FORCED_MODE; + + /* Set the required sensor settings needed */ + set_required_settings = BME680_OST_SEL | BME680_OSP_SEL | BME680_OSH_SEL | + BME680_FILTER_SEL | BME680_GAS_SENSOR_SEL; + + /* Set the desired sensor configuration */ + rslt = bme680_set_sensor_settings(set_required_settings, &gas_sensor); + + /* Set the power mode */ + rslt = bme680_set_sensor_mode(&gas_sensor); + + if (rslt == BME680_OK) { + ESP_LOGI(TAG, "BME680 sensor initialized"); + } else { + ESP_LOGE(TAG, "BME680 initialization failed"); + return; + } +} + +bool bme_read(void) { + /* + + bool ret = bme.performReading(); + if (ret) { + // read current BME data and buffer in global struct + bme_status.temperature = bme.temperature; + bme_status.pressure = (uint16_t)(bme.pressure / 100.0); // convert Pa -> + hPa bme_status.humidity = bme.humidity; bme_status.gas_resistance = + (uint16_t)(bme.gas_resistance / 1000.0); // convert Ohm -> kOhm + ESP_LOGI(TAG, "BME680 sensor data read success"); + } else { + ESP_LOGI(TAG, "BME680 sensor read error"); + } + return ret; + + */ +} + +int8_t user_i2c_read(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, + uint16_t len) { + int8_t rslt = 0; /* Return 0 for Success, non-zero for failure */ + uint16_t i; + + Wire.beginTransmission(dev_id); + Wire.write(reg_addr); + rslt = Wire.endTransmission(); + + Wire.requestFrom((int)dev_id, (int)len); + for (i = 0; (i < len) && Wire.available(); i++) { + reg_data[i] = Wire.read(); + } + + return rslt; +} + +int8_t user_i2c_write(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, + uint16_t len) { + int8_t rslt = 0; /* Return 0 for Success, non-zero for failure */ + uint16_t i; + + Wire.beginTransmission(dev_id); + Wire.write(reg_addr); + for (i = 0; i < len; i++) { + Wire.write(reg_data[i]); + } + rslt = Wire.endTransmission(); + + return rslt; +} + +void user_delay_ms(uint32_t period) { vTaskDelay(period / portTICK_PERIOD_MS); } + +#endif // HAS_BME \ No newline at end of file diff --git a/src/hal/generic.h b/src/hal/generic.h index 96eca070..1bf595e0 100644 --- a/src/hal/generic.h +++ b/src/hal/generic.h @@ -13,9 +13,16 @@ #define SPI_SCLK GPIO_NUM_18 #define SPI_CS GPIO_NUM_5 +////////////// test ////////// // enable only if device has these sensors, otherwise comment these lines -#define HAS_BME 0x77 // BME680 sensor on I2C bus (default SDA=4/SCL=15); comment out if not present -#define HAS_SENSORS 1 // comment out if device has user defined sensors +// BME680 sensor on I2C bus +#define HAS_BME GPIO_NUM_21, GPIO_NUM_22 // SDA, SCL +// #define BME_ADDR BME680_I2C_ADDR_PRIMARY // i2c addr 0x76 +#define BME_ADDR BME680_I2C_ADDR_SECONDARY // i2c addr 0x77 +// +// user defined sensors +//#define HAS_SENSORS 1 // comment out if device has user defined sensors +////////////// test ////////// #define CFG_sx1276_radio 1 // select LoRa chip //#define CFG_sx1272_radio 1 // select LoRa chip diff --git a/src/hal/ttgobeam.h b/src/hal/ttgobeam.h index 234ff03c..be946607 100644 --- a/src/hal/ttgobeam.h +++ b/src/hal/ttgobeam.h @@ -7,7 +7,12 @@ ////////////// test ////////// // enable only if device has these sensors, otherwise comment these lines -#define HAS_BME 0x77 // BME680 sensor on I2C bus (default SDA=21/SCL=22); comment out if not present +// BME680 sensor on I2C bus +#define HAS_BME GPIO_NUM_21, GPIO_NUM_22 // SDA, SCL +// #define BME_ADDR BME680_I2C_ADDR_PRIMARY // i2c addr 0x76 +#define BME_ADDR BME680_I2C_ADDR_SECONDARY // i2c addr 0x77 +// +// user defined sensors //#define HAS_SENSORS 1 // comment out if device has user defined sensors ////////////// test //////////