Nicla Sense Me : BSEC values always return 0 despite modifying SensorTypes.h and other defines

Subject: BSEC values always return 0 despite modifying SensorTypes.h and other defines

Hello everyone,

I’m working on a Nicla Sense ME project using the BSEC library, and I’m facing an issue where my BSEC values always return 0. I’ve already tried several suggestions I found on different forums but nothing seems to work:

• In SensorTypes.h, I changed

#define SENSOR_DATA_FIXED_LENGTH (10)

to

#define SENSOR_DATA_FIXED_LENGTH (30)

• I also modified my code to use

SensorBSEC bsec(SENSOR_ID_BSEC_LEGACY);

instead of the default

SensorBSEC bsec(SENSOR_ID_BSEC);

• Additionally, I changed

#define SENSOR_LONG_DATA_FIXED_LENGTH (21)

to

#define SENSOR_LONG_DATA_FIXED_LENGTH (30)

No matter what combination I try, the BSEC values I read are always 0. Has anyone encountered this problem before or found a reliable workaround?

I would be very grateful for any insights or advice on how to get valid BSEC measurements instead of zeros. Thank you in advance for your help!

Here is my complete code:

#include "Arduino.h"
#include "Arduino_BHY2.h"


SensorBSEC bsec(SENSOR_ID_BSEC);

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

  BHY2.begin();
  bsec.begin();
}

void loop()
{
  static auto printTime = millis();

  // Update function should be continuously polled
  BHY2.update();

  if (millis() - printTime >= 1000) {
    printTime = millis();
    Serial.println(String("BSEC info: ") + bsec.toString());
  }
}