Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Arduino_BHY2/examples/Standalone/Standalone.ino
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ 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()
{
Expand All @@ -25,6 +26,7 @@ void setup()
gyro.begin();
temp.begin();
gas.begin();
bsec.begin();
rotation.begin();
}

Expand All @@ -42,6 +44,8 @@ void loop()
Serial.println(String("gyroscope: ") + gyro.toString());
Serial.println(String("temperature: ") + String(temp.value(),3));
Serial.println(String("gas: ") + String(gas.value(),3));
Serial.println(String("co2: ") + String(bsec.co2_eq(),3));
Serial.println(String("iaq: ") + String(bsec.iaq(),3));
Copy link
Contributor Author

@aliphys aliphys Jun 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following @alrvid 's comment, the following two lines are problematic. The data types of the SenseBSEC class are not uniform and are either unit8_t, unit16_t, unit32_t or float. See here.

  uint16_t iaq() {return _data.iaq;}
  uint16_t iaq_s() {return _data.iaq_s;}
  float b_voc_eq() {return _data.b_voc_eq;}
  uint32_t co2_eq() {return _data.co2_eq;}
  uint8_t accuracy() {return _data.accuracy;}
  float comp_t() {return _data.comp_t;}
  float comp_h() {return _data.comp_h;}
  uint32_t comp_g() {return _data.comp_g;}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

String(val, decimalPlaces) can only be used for certain data types:

`val`:  a variable to format as a String - *Allowed data types:* string, char, byte, int, long, unsigned int, unsigned long, float, double +

So unit8_t, unit16_t and unit32_t are illegal.

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