BSEC configuration

This commit is contained in:
Klaus K Wilting committed 2018-11-25 20:56:14 +01:00
1 parent e2c975178a
commit f024361c19
45 files changed
+68 -2006

No files matched your search

+45 -6
View File
@@ -8,6 +8,43 @@ static const char TAG[] = "main";
bmeStatus_t bme_status;
TaskHandle_t BmeTask;
// BSEC configuration
// 3,3V supply voltage; 3s sensor_control; 4 days calibration
// change this const if not applicable for your application (see BME680
// datasheet)
const uint8_t bsec_config_iaq[454] = {
1, 7, 4, 1, 61, 0, 0, 0, 0, 0, 0, 0, 174, 1, 0,
0, 48, 0, 1, 0, 137, 65, 0, 63, 205, 204, 204, 62, 0, 0,
64, 63, 205, 204, 204, 62, 0, 0, 225, 68, 0, 192, 168, 71, 64,
49, 119, 76, 0, 0, 0, 0, 0, 80, 5, 95, 0, 0, 0, 0,
0, 0, 0, 0, 28, 0, 2, 0, 0, 244, 1, 225, 0, 25, 0,
0, 128, 64, 0, 0, 32, 65, 144, 1, 0, 0, 112, 65, 0, 0,
0, 63, 16, 0, 3, 0, 10, 215, 163, 60, 10, 215, 35, 59, 10,
215, 35, 59, 9, 0, 5, 0, 0, 0, 0, 0, 1, 88, 0, 9,
0, 229, 208, 34, 62, 0, 0, 0, 0, 0, 0, 0, 0, 218, 27,
156, 62, 225, 11, 67, 64, 0, 0, 160, 64, 0, 0, 0, 0, 0,
0, 0, 0, 94, 75, 72, 189, 93, 254, 159, 64, 66, 62, 160, 191,
0, 0, 0, 0, 0, 0, 0, 0, 33, 31, 180, 190, 138, 176, 97,
64, 65, 241, 99, 190, 0, 0, 0, 0, 0, 0, 0, 0, 167, 121,
71, 61, 165, 189, 41, 192, 184, 30, 189, 64, 12, 0, 10, 0, 0,
0, 0, 0, 0, 0, 0, 0, 229, 0, 254, 0, 2, 1, 5, 48,
117, 100, 0, 44, 1, 112, 23, 151, 7, 132, 3, 197, 0, 92, 4,
144, 1, 64, 1, 64, 1, 144, 1, 48, 117, 48, 117, 48, 117, 48,
117, 100, 0, 100, 0, 100, 0, 48, 117, 48, 117, 48, 117, 100, 0,
100, 0, 48, 117, 48, 117, 100, 0, 100, 0, 100, 0, 100, 0, 48,
117, 48, 117, 48, 117, 100, 0, 100, 0, 100, 0, 48, 117, 48, 117,
100, 0, 100, 0, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44,
1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1,
44, 1, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8,
7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7,
112, 23, 112, 23, 112, 23, 112, 23, 112, 23, 112, 23, 112, 23, 112,
23, 112, 23, 112, 23, 112, 23, 112, 23, 112, 23, 112, 23, 255, 255,
255, 255, 255, 255, 255, 255, 220, 5, 220, 5, 220, 5, 255, 255, 255,
255, 255, 255, 220, 5, 220, 5, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 44, 1, 0, 0, 0, 0,
239, 79, 0, 0};
// initialize BME680 sensor
int bme_init(void) {
@@ -22,9 +59,11 @@ int bme_init(void) {
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);
ESP_LOGE(TAG, "Could not initialize BME680, error %d",
(int)ret.bme680_status);
} else if ((int)ret.bsec_status) {
ESP_LOGE(TAG, "Could not initialize BSEC library, error %d", (int)ret.bsec_status);
ESP_LOGE(TAG, "Could not initialize BSEC library, error %d",
(int)ret.bsec_status);
} else {
ESP_LOGI(TAG, "BME680 sensor found and initialized");
return 1;
@@ -131,13 +170,13 @@ void state_save(const uint8_t *state_buffer, uint32_t length) {
* @return number of bytes copied to config_buffer
*/
uint32_t config_load(uint8_t *config_buffer, uint32_t n_buffer) {
// ...
// Load a library config from non-volatile memory, if available.
//
// Return zero if loading was unsuccessful or no config was available,
// otherwise return length of loaded config string.
// ...
return 0;
memcpy(config_buffer, bsec_config_iaq, sizeof(bsec_config_iaq));
return sizeof(bsec_config_iaq);
}
/*!
+8 -8
View File
@@ -164,7 +164,7 @@ void onEvent(ev_t ev) {
switch (ev) {
case EV_SCAN_TIMEOUT:
strcpy_P(buff, PSTR("SCAN TIMEOUT"));
strcpy_P(buff, PSTR("SCAN_TIMEOUT"));
break;
case EV_BEACON_FOUND:
@@ -210,8 +210,8 @@ void onEvent(ev_t ev) {
break;
case EV_TXCOMPLETE:
strcpy_P(buff, (LMIC.txrxFlags & TXRX_ACK) ? PSTR("RECEIVED ACK")
: PSTR("TX COMPLETE"));
strcpy_P(buff, (LMIC.txrxFlags & TXRX_ACK) ? PSTR("RECEIVED_ACK")
: PSTR("TX_COMPLETE"));
sprintf(display_line6, " "); // clear previous lmic status
if (LMIC.dataLen) {
@@ -237,20 +237,20 @@ void onEvent(ev_t ev) {
case EV_RXCOMPLETE:
// data received in ping slot
strcpy_P(buff, PSTR("RX COMPLETE"));
strcpy_P(buff, PSTR("RX_COMPLETE"));
break;
case EV_LINK_DEAD:
strcpy_P(buff, PSTR("LINK DEAD"));
strcpy_P(buff, PSTR("LINK_DEAD"));
break;
case EV_LINK_ALIVE:
strcpy_P(buff, PSTR("LINK ALIVE"));
strcpy_P(buff, PSTR("LINK_ALIVE"));
break;
case EV_TXSTART:
if (!(LMIC.opmode & OP_JOINING))
strcpy_P(buff, PSTR("TX START"));
strcpy_P(buff, PSTR("TX_START"));
break;
case EV_SCAN_FOUND:
@@ -262,7 +262,7 @@ void onEvent(ev_t ev) {
break;
default:
sprintf_P(buff, PSTR("UNKNOWN EVENT %d"), ev);
sprintf_P(buff, PSTR("UNKNOWN_EVENT_%d"), ev);
break;
}
+1 -1
View File
@@ -11,7 +11,7 @@
// Payload send cycle and encoding
#define SEND_SECS 30 // payload send cycle [seconds/2] -> 60 sec.
#define PAYLOAD_ENCODER 3 // payload encoder: 1=Plain, 2=Packed, 3=CayenneLPP dynamic, 4=CayenneLPP packed
#define PAYLOAD_ENCODER 2 // 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
+12 -4
View File
@@ -4,25 +4,33 @@
// Local logging tag
static const char TAG[] = "main";
#define SENSORBUFFER 10 // max. size of user sensor data buffer in bytes [default=20]
#define SENSORBUFFER \
10 // max. size of user sensor data buffer in bytes [default=20]
void sensor_init(void) {
// this function is called dureing device startup
// put your sensor initialization routines here
// this function is called during device startup
// put your user sensor initialization routines here
}
uint8_t sensor_mask(uint8_t sensor_no) {
switch (sensor_no) {
case 0:
return (uint8_t)COUNT_DATA;
case 1:
return (uint8_t)SENSOR1_DATA;
case 2:
return (uint8_t)SENSOR2_DATA;
break;
case 3:
return (uint8_t)SENSOR3_DATA;
case 4:
return (uint8_t)SENSOR4_DATA;
case 5:
return (uint8_t)GPS_DATA;
case 6:
return (uint8_t)MEMS_DATA;
case 7:
return (uint8_t)ALARM_DATA;
}
}