We want to read accelerometer data using the Arduino Nicla,
We need float data, we tried to modify the BHY2 library but it still giving us integer data.
Hello
It should be possible to print out data of float type provided that the Board support package supports it.
for example, using the Nicla Board (from Board Manger) Support Package 2.9.9, and the example:Arduinio_BHY2->Standalone, you can see the data output for temperature and gas are floating point type.
Could you share the Nicla Board Package version you are using? under menu->Boards Manager
also, do you mind share a few snippets of your changes in the library?
a sample change I tested was:
```
diff --git a/Arduino_BHY2/src/sensors/DataParser.h b/Arduino_BHY2/src/sensors/DataParser.h
index 7af5127..b174bea 100644
--- a/Arduino_BHY2/src/sensors/DataParser.h
+++ b/Arduino_BHY2/src/sensors/DataParser.h
@@ -15,6 +15,13 @@ struct DataXYZ {
+ " Y: " + String(y)
+ " Z: " + String(z) + "\n");
}
+
+ String toString(float scale) {
+ return (String)("XYZ values - X: " + String(x * scale)
+ + " Y: " + String(y * scale)
+ + " Z: " + String(z * scale) + "\n");
+ }
+
};
struct DataOrientation {
diff --git a/Arduino_BHY2/src/sensors/SensorXYZ.h b/Arduino_BHY2/src/sensors/SensorXYZ.h
index 88a36af..8a2a2ae 100644
--- a/Arduino_BHY2/src/sensors/SensorXYZ.h
+++ b/Arduino_BHY2/src/sensors/SensorXYZ.h
@@ -28,7 +28,7 @@ public:
String toString()
{
- return _data.toString();
+ return _data.toString(1 / 4096.f);
}
private:
```
Hello chillin_panda,
You could refer zgg's reply to get float data from BHI2 host side.