Nicla Sense ME - BME688 sensor

Hello,
I'm a lucky owner of a NICLA Sense ME. I also have a BME688 development kit which I have used to trained a model to recognised coffee using the BME AI-Studio.
I was able to upload the config file of the model but then I don't have a clue of how to use that model with the Nicla Sense ME.
The Nicla tutorilas focus more on the other sensors and there s not much on the gaz sensor itself and how to use trained models.
If someone was able to get it working I would be interested to see how. Otherwise some guidance would be appreciated.
Thanks :blush:

I've been messing around over the last few days creating a machine learning model for small thermal imager.

In my code I create the model and then have the model compare against live images. Every 6 minutes the learned model self updates to compensate for the background getting warmer as the day heats up.

#include <Wire.h>
#include <Adafruit_AMG88xx.h>
#include <LinearRegression.h>
////
Adafruit_AMG88xx amg;
LinearRegression lr;
////
const int pixels = 64;
float CurrentFrame[pixels] = { 0 };
int   sensorDelay = 125;
float dpAtom = 1.0f / 80.0f; // low/high from data sheet
float tsAtom = 1.0f / 64.0f; // 64 data points 64 time stamps.
double valuesModel[2];
double values[2];
////
void setup() {
  Serial.begin(115200);
  //Serial.println("AMG88xx thermal camera!");
  bool status;
  // default settings
  status = amg.begin();
  if (!status) {
    Serial.println("Could not find a valid AMG88xx sensor, check wiring!");
    while (1);
  }
  delay(sensorDelay);
  BackgroundImage();
} // setup()
//
int count = 0;
float daChange = 0.0f;
float avg = 0.0f;
float stdD = 0.0f; //standard deviation
void loop()
{
  lr.reset();
  amg.readPixels( CurrentFrame );
  for (int i = 0; i < pixels; i++)
  {
    lr.learn( ((float)i + 1.0f) * tsAtom, (float(CurrentFrame[i]) * dpAtom) );
    avg += (float(CurrentFrame[i]));
  }
  avg /= pixels; // an average of all the readings
  // calculate the standard deviation
  for (int i = 0; i < pixels; i++) {
    stdD += pow(CurrentFrame[i] - avg, 2);
  }
  stdD = sqrt(stdD / pixels);
  stdD *= 10;
  /*
  // if the current value is more than a standard deviation above the mean,
  // then that counts as a peak. also make sure that the current value is
  // more than 25 above the mean, in case there is just some noise in a
  // pretty flat signal
  //    if (sensorFiltered[0] - avg > std && sensorFiltered[0] - avg > 50 )
  //    {
  //        return true;
  //    } else {
  //        return false;
  //    }
*/

  lr.parameters(values);
  daChange = 100 * ((valuesModel[1] - values[1]) / valuesModel[1]);
  //Serial.print("ValuesModel: ");
  //Serial.print(" *X + ");
  //Serial.print(valuesModel[1], 6);
  //Serial.print(" Values: ");
  //Serial.print(" *X + ");
  //Serial.print(values[1], 6);
  //Serial.print(" %ofChange ");
  Serial.print( daChange, 6 );
  Serial.print( "," );
  Serial.print( stdD );
  Serial.println();
  delay(sensorDelay);
  count++;
  //6(150 times 60 seconds) 6 minutes
  if ( count == 54000 )
  {
    BackgroundImage();
  }
}
//
void BackgroundImage()
{
  // gather a background image
  // load model
  for (int i = 0; i < 2; i++)
  {
    lr.reset();
    amg.readPixels( CurrentFrame ); // discard several readings
    delay(sensorDelay);
  }
  lr.reset();
  amg.readPixels( CurrentFrame );
  for (int i = 0; i < pixels; i++)
  {
    lr.learn( ((float)i + 1.0f) * tsAtom, (CurrentFrame[i] * dpAtom) );
  }
  //Serial.print("Values: ");
  lr.parameters(valuesModel);
  //Serial.print(" *X + ");
  //Serial.println(valuesModel[1], 6);
}

I am also using standard deviation to see how it stacks up against Liner Regression, not so well.

Hi,

Good to see the first Forum entries on the Arduino Nicla. For my protyping business I've received my first Nicla Sense ME too. Trying to read the values of the various sensors. So far the code example of the RGB led work fine. But cannot acces the sensors. I've tried to run a kind of I2C scanner to extract the I2C adressess. But no result yet.

This Nicla Sense ME product is a great addition to the Arduino Pro line. I'm convinced that it offers me a rich platform extension to track environmental changes in production lines. For one of my clients I'm creating an advanced prototype that uses the accelero sensor in combination with accurate temperature/humitity and TinyML to and predict early failures and reduce maintenance costs.

Would be great to get some practival directions how to access the sensors and starting to read the captured data via USB line via the Arduino IDE 1.8.15.

Any support is highly appreciated.

Bas.
bas@botberg.nl - prototyping
Netherlands.

Hi Bas, take a look at the Nicla Cheatsheet, you can find info on how to read sensors in standalone mode, over BLE , over Eslov cable.

I follow the topic with interest since I was looking for the same thing (create a model with BME AI-studio and use it with Nicla). I would also like to explore the features of the BHI260AP better :thinking:

Hello Andrea,

I have followed the Nicla Cheatsheet and was trying to read the sensor values with the bhy script.
I got the following error when trying to enable the sensor as per the example :

./bhy sensor config -p /dev/cu.usbmodemE43D33542 -sensor 10 -rate 1 -latency 0
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0xb01dfacedebac1e pc=0x7fff6732570a]

runtime stack:
runtime: unexpected return pc for runtime.sigpanic called from 0x7fff6732570a
stack: frame={sp:0x7ffeefbff578, fp:0x7ffeefbff5c8} stack=[0x7ffeefb80618,0x7ffeefbff680)

I'm on MAC, first time I used GO . The ./bhy list command works and I can see the available ports.

Any idea what might be the problem?

Thanks

Hi All,

We're also getting started with a few Nicla Sense ME devices in our lab. At the moment I can read the sensors, though haven't found an example to extract iAQ, eCO2, bVOC, or calibrated temperature data. I also haven't found an example that allows reading or writing from flash memory.

I assume these will slowly make their way to the cheat sheet?

I'm also interested in getting these values and have thus far been unsuccessful.

I found this topic on a Bosch message board (https://community.bosch-sensortec.com/t5/MEMS-sensors-forum/BME688-Nicla-Sense-me-how-to-access-the-data/m-p/46408#M8368 but so far I'm getting the same results (only temperature, rest of the values 0).