Adafruit QT PY M0, Adafruit BME688, BSEC2: Can't get it working

Cannot get BSEC2 to run on a Adafruit BME688 to output gas estimates, which I trained before.

Compilation and upload work, initializaton of instance mySensor fails in code below @ 

 

 

if(!mySensor.begin(0x77, Wire, customDelay))

 

 

Here's my config: adafruit BME688 sensor, adress 0x77 (default), adafruit QT PY SAMD21, both connected thru STEMMA QT (I2C), Arduino IDE 2.1.0, Mac OS 13.4, connected via USB C

For other Arduino boards (e.g. ESP...) used with BSEC2 and the BME688 one has to modify platform.txt. Couldn't find any similar instructions for the QT PY SAMD21.

Anyone an idea why init fails?

 

 

#include "trainedModel.h"
#include <Wire.h>
#include <bsec2.h>
#include <stdint.h>

Bsec2 mySensor;

void customDelay(unsigned long time, void *data) {
  delayMicroseconds(time);
}

void setup() {
  Serial.begin(115200);

  delay(5000);

  Serial.println("Starting setup...");

  delay(3000);

  uint8_t bsecState[BSEC_MAX_STATE_BLOB_SIZE] = {0};
  uint8_t bsecInstance[BSEC_INSTANCE_SIZE];
  mySensor.allocateMemory(bsecInstance);
  Serial.println("Memory allocated...");

  if(!mySensor.begin(0x77, Wire, customDelay)) {
    Serial.println("Failed to initialize BSEC2 library");
    while(1);
  }
  Serial.println("BSEC2 library initialized...");

  if(!mySensor.setConfig(bsec_config_selectivity)) {
    Serial.println("Failed to set the configuration");
    while(1);
  }
  Serial.println("Configuration set...");

  if(!mySensor.setState(bsecState)) {
    Serial.println("Failed to set the state");
    while(1);
  }
  Serial.println("State set...");

  bsecSensor sensorList[] = {
    BSEC_OUTPUT_GAS_ESTIMATE_1,
    BSEC_OUTPUT_GAS_ESTIMATE_2,
    BSEC_OUTPUT_GAS_ESTIMATE_3,
    BSEC_OUTPUT_GAS_ESTIMATE_4
  };
  
  if(!mySensor.updateSubscription(sensorList, ARRAY_LEN(sensorList), BSEC_SAMPLE_RATE_SCAN)) {
    Serial.println("Failed to update sensor subscription");
    while(1);
  }
  Serial.println("Sensor subscription updated...");
  
  Serial.println("Setup complete");
}

void loop() {
  Serial.println("Entering main loop.");

  delay(3000);

  Serial.println("Entering main loop...");

  if(mySensor.run()) {
    Serial.println("Sensor running...");
    const bsecOutputs* outputs = mySensor.getOutputs();
    for(int i=0; i<outputs->nOutputs; i++) {
      Serial.print("Gas estimate for class ");
      Serial.print(i+1);
      Serial.print(": ");
      Serial.println(outputs->output[i].signal);
    }
  }
  else {
    Serial.println("Sensor not running...");
  }

  Serial.println("Loop completed. Starting next iteration...");
}

 

 

Best reply by BSTRobin

Hi EventHorizon,

BSEC2.4.0.0 will not include or use files from BSEC2.0.6.
You can check platform.txt and if you copy correct .a file from BSEC2.4.0.0 package to Arduio SDK library folder?

View original
13 replies
Resolved