arduino / nicla-sense-me-fw

Arduino Nicla Sense ME resources (libraries, bootloader, host pc utilities)
GNU Affero General Public License v3.0
47 stars 27 forks source link

[AE-106] `.toString()` values from the SensorQuaternion class always returns zero #107

Open aliphys opened 1 year ago

aliphys commented 1 year ago

Description of defect

.toString()values from the SensorQuaternion class always returns zero. Even after 10 minutes have passed.

https://github.com/arduino/nicla-sense-me-fw/blob/b4425275859b2dea1ec22c546851106df9ac8fb5/Arduino_BHY2/src/sensors/SensorQuaternion.h#L44-L47

Split from https://github.com/arduino/nicla-sense-me-fw/issues/82

Target(s) affected by this defect ?

Nicla Sense ME

Toolchain(s) (name and version) displaying this defect ?

Version: 2.0.4 Date: 2023-02-27T16:14:28.576Z CLI Version: 0.31.0

Copyright © 2023 Arduino SA

What version of Mbed-os are you using (tag or sha) ?

What version(s) of tools are you using. List all that apply (E.g. mbed-cli)

ArduinoBLE 1.3.3 Arduino_BHY2 1.0.6 Firmware of Nicla Sense Flashed (see this comment)

How is this defect reproduced ?

Run this sketch, which is modified from the Standalone.ino sketch


/* 
 * This sketch shows how nicla can be used in standalone mode.
 * Without the need for an host, nicla can run sketches that 
 * are able to configure the bhi sensors and are able to read all 
 * the bhi sensors data.
*/

#include "Arduino_BHY2.h"

SensorXYZ accel(SENSOR_ID_ACC);
SensorXYZ gyro(SENSOR_ID_GYRO);
Sensor temp(SENSOR_ID_TEMP);
Sensor gas(SENSOR_ID_GAS);
SensorQuaternion rotation(SENSOR_ID_RV);
SensorBSEC bsec(SENSOR_ID_BSEC);

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

  BHY2.begin();

  accel.begin();
  gyro.begin();
  temp.begin();
  gas.begin();
  bsec.begin();
  rotation.begin();
  delay(3000); # 3 second delay, before starting loop
}

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

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

  if (millis() - printTime >= 1000) {
    printTime = millis();

    Serial.println(String("acceleration: ") + accel.toString());
    Serial.println(String("gyroscope: ") + gyro.toString());
    Serial.println(String("temperature: ") + String(temp.value(),3));

    # remove decimalPlaces agrument in String function
    Serial.println(String("gas: ") + String(gas.value()));
    Serial.println(String("co2: ") + String(bsec.co2_eq()));
    Serial.println(String("iaq: ") + String(bsec.iaq()));

    Serial.println(String("rotation: ") + rotation.toString());
  }
}

Output

acceleration: XYZ values - X: 390   Y: -971   Z: -3929

gyroscope: XYZ values - X: 0   Y: -2   Z: -2

temperature: 30.430
gas: 22369.00
co2: 502
iaq: 26
rotation: Quaternion values - X: 0.000   Y: 0.000   Z: 0.000   W: 0.000   Accuracy: 0.000