03-22-2021 09:43 PM - edited 03-22-2021 09:47 PM
Hallo,
I'm currently facing a problem with the bsec-Library and an ESP8266.
I started with the basic.ino script which seems to work, but after ~30min the ESP8266 crashes and reboots. Therefore I modified the script a little bit to print the free heap size. This shows that there is a memory leak and the ESP8266 crashes after it ran out of memory.
This is the free heap size in bytes between two crashes.
Is this a known problem and is there a fix for this?
I am using this version:
Arduino IDE: 1.8.13
bsec: 1.6.1480
esp8266 core: 2.7.4
#include "bsec.h"
extern "C" {
#include "user_interface.h"
}
// Helper functions declarations
void checkIaqSensorStatus(void);
// Create an object of the class Bsec
Bsec iaqSensor;
String output;
// Entry point for the example
void setup(void)
{
Serial.begin(115200);
Wire.begin();
iaqSensor.begin(BME680_I2C_ADDR_SECONDARY, Wire);
Serial.println(output);
checkIaqSensorStatus();
bsec_virtual_sensor_t sensorList[2] = {
BSEC_OUTPUT_IAQ,
BSEC_OUTPUT_STATIC_IAQ,
};
iaqSensor.updateSubscription(sensorList, 2, BSEC_SAMPLE_RATE_CONTINUOUS);
checkIaqSensorStatus();
// Print the header
output = "Timestamp [ms], IAQ, IAQ accuracy";
Serial.println(output);
}
// Function that is looped forever
void loop(void)
{
unsigned long time_trigger = millis();
if (iaqSensor.run()) { // If new data is available
output = String(time_trigger);
output += ", " + String(iaqSensor.iaq);
output += ", " + String(iaqSensor.iaqAccuracy);
Serial.println(output);
uint32_t free = system_get_free_heap_size();
Serial.print("Free RAM: ");
Serial.println(free);
} else {
checkIaqSensorStatus();
}
}
// Helper function definitions
void checkIaqSensorStatus(void)
{
if (iaqSensor.status != BSEC_OK) {
if (iaqSensor.status < BSEC_OK) {
Serial.println("Error");
for (;;) {}
} else {
Serial.println("Warning");
}
}
if (iaqSensor.bme680Status != BME680_OK) {
if (iaqSensor.bme680Status < BME680_OK) {
Serial.println("Error");
for (;;) {}
} else {
Serial.println("Warning");
}
}
}
This is the output of the ESP8266 Exception Decoder:
Exception 29: StoreProhibited: A store referenced a page mapped with an attribute that does not permit stores
PC: 0x4000df64
EXCVADDR: 0x00000000
Decoding stack results
0x40100508: pvPortZalloc(size_t, char const*, int) at C:\Users\{USER}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\heap.cpp line 301
0x4021e0bc: mem_malloc at core/mem.c line 210
0x40100154: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\{USER}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 177
0x40100154: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\{USER}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 177
0x40100154: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\{USER}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 177
0x40100154: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\{USER}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 177
0x40100154: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\{USER}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 177
0x402068d5: Bsec::setState(unsigned char*) at C:\Users\{USER}\Documents\Arduino\libraries\BSEC_Software_Library\src\bsec.cpp line 286
0x40206ca9: Bsec::run(long long) at C:\Users\{USER}\Documents\Arduino\libraries\BSEC_Software_Library\src\bsec.cpp line 209
0x402068d8: Bsec::setState(unsigned char*) at C:\Users\{USER}\Documents\Arduino\libraries\BSEC_Software_Library\src\bsec.cpp line 286
0x40100154: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\{USER}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 177
0x40100154: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\{USER}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 177
0x40100154: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\{USER}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 177
0x40100154: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\{USER}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 177
0x40100154: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\{USER}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 177
0x40100154: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\{USER}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 177
0x40100154: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\{USER}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 177
0x40100154: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\{USER}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 177
0x40106b39: Twi::busywait(unsigned int) at C:\Users\{USER}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_si2c.cpp line 237
0x40208654: Twi::write_bit(bool) at C:\Users\{USER}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_si2c.cpp line 280
0x40210c4c: expf at /home/earle/src/esp-quick-toolchain/repo/newlib/newlib/libm/math/wf_exp.c line 44
0x40210f1f: powf at /home/earle/src/esp-quick-toolchain/repo/newlib/newlib/libm/math/wf_pow.c line 36
0x40206b01: Bsec::readProcessData(long long, bsec_bme_settings_t) at C:\Users\{USER}\Documents\Arduino\libraries\BSEC_Software_Library\src\bsec.cpp line 399
0x40100154: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\{USER}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 177
0x40211240: sqrtf at /home/earle/src/esp-quick-toolchain/repo/newlib/newlib/libm/math/wf_sqrt.c line 36
0x40211240: sqrtf at /home/earle/src/esp-quick-toolchain/repo/newlib/newlib/libm/math/wf_sqrt.c line 36
0x402085d6: Twi::write_stop() at C:\Users\{USER}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_si2c.cpp line 262
0x402085d6: Twi::write_stop() at C:\Users\{USER}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_si2c.cpp line 262
0x4020884d: Twi::writeTo(unsigned char, unsigned char*, unsigned int, unsigned char) at C:\Users\{USER}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_si2c.cpp line 349
0x402085d6: Twi::write_stop() at C:\Users\{USER}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_si2c.cpp line 262
0x40208ab4: twi_writeTo(unsigned char, unsigned char*, unsigned int, unsigned char) at C:\Users\{USER}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_si2c.cpp line 984
0x40207050: TwoWire::endTransmission(unsigned char) at C:\Users\{USER}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\libraries\Wire\Wire.cpp line 171
0x40207078: TwoWire::endTransmission() at C:\Users\{USER}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\libraries\Wire\Wire.cpp line 180
0x402066d1: Bsec::i2cWrite(unsigned char, unsigned char, unsigned char*, unsigned short) at C:\Users\{USER}\Documents\Arduino\libraries\BSEC_Software_Library\src\bsec.cpp line 578
0x40201204: bme680_set_regs at C:\Users\{USER}\Documents\Arduino\libraries\BSEC_Software_Library\src\bme680\bme680.c line 355
0x40207c94: __esp_yield() at C:\Users\{USER}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266/core_esp8266_features.h line 92
0x40208c02: __delay(unsigned long) at C:\Users\{USER}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_wiring.cpp line 54
0x40206df0: Bsec::delay_ms(unsigned int) at C:\Users\{USER}\Documents\Arduino\libraries\BSEC_Software_Library\src\bsec.cpp line 533
0x40206d65: Bsec::run(long long) at C:\Users\{USER}\Documents\Arduino\libraries\BSEC_Software_Library\src\bsec.cpp line 242
0x40207110: HardwareSerial::write(unsigned char const*, unsigned int) at C:\Users\{USER}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266/HardwareSerial.h line 164
0x4020711c: HardwareSerial::write(unsigned char const*, unsigned int) at C:\Users\{USER}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266/HardwareSerial.h line 165
0x40207110: HardwareSerial::write(unsigned char const*, unsigned int) at C:\Users\{USER}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266/HardwareSerial.h line 164
0x4020730d: Print::write(char const*) at C:\Users\{USER}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266/Print.h line 62
0x4020742d: Print::printNumber(unsigned long, unsigned char) at C:\Users\{USER}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\Print.cpp line 268
0x40209471: uart_write(uart_t*, char const*, size_t) at C:\Users\{USER}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\uart.cpp line 509
0x4020736c: Print::println() at C:\Users\{USER}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\Print.cpp line 186
0x40206599: loop() at C:\Users\{USER}\Downloads\temp\basic/basic.ino line 42
0x40100154: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\{USER}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 177
0x40100175: esp_schedule() at C:\Users\{USER}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 125
0x40207dbc: loop_wrapper() at C:\Users\{USER}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 197
03-30-2021 11:17 AM
Hello Multi123321,
There was "BSEC Binary Size Information" document after you downloaded BSEC package.