Callback from BME680/BSEC2 to class function

Hi, I'm lost for a solution to avoid error; "invalid use of non-static member function 'void EnvironmentClass::newDataCallback(bme68xData" hitting the statement: envsensor.attachCallback(... while compiling. Have tried "static" and other stuff. The library is the BSEC2 for the Bosch BME680. I'm sure there are many of you that know C++ better than me. :relieved:

** ino file:

#include "Environment.h"
EnvironmentClass env;
void setup(void) {}
void loop(void) {}

** (Environment.h) Header file:

#ifndef ENV_H
#define ENV_H
// Bosch BSEC2 library
#include <bsec2.h>

#define BME_SCL 4
#define BME_SDA 3
#define SEALEVELPRESSURE_HPA (1029.8)
#define SAMPLE_RATE BSEC_SAMPLE_RATE_ULP

class EnvironmentClass
{
private:
  TwoWire I2CBME = TwoWire(0);
  Bsec2 envSensor;
public:
  EnvironmentClass(); 
  void newDataCallback(const bme68xData data, const bsecOutputs outputs, Bsec2 bsec);
};
#endif

** (Environment.cpp) Code file:

#include "Environment.h"

bsecSensor sensorList[] = {BSEC_OUTPUT_IAQ, BSEC_OUTPUT_RAW_TEMPERATURE};

EnvironmentClass::EnvironmentClass() {
  I2CBME.begin(BME_SDA, BME_SCL, 100000);
  envSensor.begin(BME68X_I2C_ADDR_HIGH, I2CBME);
  envSensor.updateSubscription(sensorList, ARRAY_LEN(sensorList), SAMPLE_RATE);
  envSensor.attachCallback(EnvironmentClass::newDataCallback);
};
void EnvironmentClass::newDataCallback(const bme68xData data, const bsecOutputs outputs, Bsec2 bsec) {};

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.