top of page
Search

Issues - Reading Sensor Data - Nicla Sense ME

Writer's picture: Ifrim CiprianIfrim Ciprian

In the last update I have discussed the importance of I2C connectivity in order to use the extra sensors, as well as the issues encountered with detecting the addresses for them.


I have then decided to leave I2C aside for now, and switch to getting all the outputs from the Nicla Sense board and apply the correct filtering techniques.

So, firstly, I have used the following code to get all the useful sensor data:

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

Sensor humidity(SENSOR_ID_HUM);
Sensor temperature(SENSOR_ID_TEMP);
Sensor pressure(SENSOR_ID_BARO);
Sensor gas(SENSOR_ID_GAS);
//SensorBSEC bsec(uint8_t(171));
//SensorBSEC bsec(uint8_t(115));
SensorBSEC bsec(SENSOR_ID_BSEC);;
SensorXYZ magnetometer(SENSOR_ID_MAG);
SensorXYZ gravity_vector(SENSOR_ID_GRA);
SensorOrientation orientation(SENSOR_ID_ORI);
SensorOrientation device_orientation(SENSOR_ID_DEVICE_ORI);
Sensor tilt(SENSOR_ID_WRIST_TILT_GESTURE);

//SensorActivity activity(uint8_t(63));
//SensorActivity activity(SENOSR_ID_AR);

void setup(){
  Serial.begin(115200);
  BHY2.begin();
  temperature.begin();
  humidity.begin();
  pressure.begin();
  gas.begin();
  bsec.begin();
  magnetometer.begin();
  gravity_vector.begin();
  orientation.begin();
  tilt.begin();
  device_orientation.begin();
  
  //activity.configure(100,1);
  //activity.begin();
}

void loop(){
  static auto lastCheck= millis();
  BHY2.update();

  // Check sensor values every second  
  if (millis() - lastCheck >= 1000) {
    lastCheck = millis();
    Serial.println(String("Temperature is: ") + String(temperature.value()) + String("C"));
    Serial.println(String("Humidity is: ") + String(humidity.value()) + String("%"));
    Serial.println(String("Gas resistance: ") + String(gas.value()));
    Serial.println(String("Pressure: ") + String(pressure.value()) + String("hPa"));
    Serial.println(String("Magnetometer info: ") + magnetometer.toString());
    Serial.println(String("Gravity Vector info: ") + gravity_vector.toString());
    Serial.println(String("Tilt info: ") + tilt.toString());
    Serial.println(String(orientation.toString()));
    Serial.println(bsec.toString());
    
    //Serial.println(String("Activity info: ") + activity.toString());
  }
}

This code enables me to get the following data:

  • Temperature;

  • Humidity;

  • Pressure;

  • Altitude;

  • Maximum Identified Gas Resistance;

  • Magnetometer X,Y,Z Vectors;

  • Gravity X,Y,Z Vectors;

  • Board Orientation = Heading, Pitch, Roll (Compass capability);

  • Tilt Info = Bosch Trained Supervised ML Model able to recognise a tilt movement; from the IMU and send a 1 instead of a 0 when the event occurs.

Moreover, the board does have an extra output which would be useful in my case. The ability to use the same aforementioned trained ML classifier to identify the activity the user is doing, for example:

  1. walking;

  2. running;

  3. standing;

  4. driving;

  5. cycling.

This information would be quite useful to either disable the device based on user activity, example:

  • if the user is running, disable the watch, go into sandby and consume less energy;

  • if the user is moving, inform them to stand before starting to measure heart rate.

However, this activity output does not actually work and the processor is crahsing with an MbedOS Memory Hardcrash.


I have updated the on-board chip firmware, as well as libraries, by using the official GitHub repository firmware/libraries: https://github.com/arduino/nicla-sense-me-fw. But I have had no luck in getting the device to output the data.

So, then I moved to reinstalling the Nicla MbedOS in Arduino, and also switch from Arduino IDE 1.8.16 to IDE 2.0, so here are the actual versions for everything:

  • Both Arduino IDE 1.8.16 and Arduino IDE 2.0

  • MbedOS Nicla version 2.7.2

  • BHY2 Library version 1.0.4

  • Latest Nicla Chip Firmware (12/2021) flashed from their GitHub repo.

Because I have had to luck with it, and I do not know if my board is faulty or not, I have contacted an Arduino Technitian as well as wrote a topic on the official Bosch Sensortec Community, available at:



I have also contacted Nick, as he, luckily for me, has multiple Nicla boards, and he can check if the code is working and if the issues are with my board or the library.


As the activity check is not the most important feature, I will leave this on the side, and now focus on calibrating the values against commercial grade devices, and implementing Exponentially Weighted Moving Average + Mean Average for filtering, combined with KNN Supervised Machine Learning to check for Data Anomalies and remove outliers.




8 views0 comments

Recent Posts

See All

Comments


  • LinkedIn
  • Facebook
  • YouTube
  • Instagram

©2022 AURI Robotics - Environmental Data Collection with Smartwatches

bottom of page