BNO055 - How To Get Linear Acceleration Values As Float Type
![userHead](https://dfimg.dfrobot.com/dfPortrait2.png)
Hello,
As i mentioned on the topic, I need to get linear accelaration values as float but library returns integer. I am using DF Robot Library with arduino nano. My code is below and the output is like on the picture, How can i get values as float ?
![Image](https://i.hizliresim.com/PlOXVn.png)
As i mentioned on the topic, I need to get linear accelaration values as float but library returns integer. I am using DF Robot Library with arduino nano. My code is below and the output is like on the picture, How can i get values as float ?
![Image](https://i.hizliresim.com/PlOXVn.png)
Code: Select all
#include "DFRobot_BNO055.h"
#include "Wire.h"
typedef DFRobot_BNO055_IIC BNO; // ******** use abbreviations instead of full names ********
BNO bno(&Wire, 0x28); // input TwoWire interface and IIC address
void printLastOperateStatus(BNO::eStatus_t eStatus)
{
switch(eStatus) {
case BNO::eStatusOK: Serial.println("everything ok"); break;
case BNO::eStatusErr: Serial.println("unknow error"); break;
case BNO::eStatusErrDeviceNotDetect: Serial.println("device not detected"); break;
case BNO::eStatusErrDeviceReadyTimeOut: Serial.println("device ready time out"); break;
case BNO::eStatusErrDeviceStatus: Serial.println("device internal status error"); break;
default: Serial.println("unknow status"); break;
}
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
bno.reset();
while(bno.begin() != BNO::eStatusOK) {
Serial.println("bno begin faild");
printLastOperateStatus(bno.lastOperateStatus);
delay(2000);
}
Serial.println("bno begin success");
}
void loop() {
// put your main code here, to run repeatedly:
BNO::sAxisAnalog_t sLiaAnalog;
sLiaAnalog = bno.getAxis(BNO::eAxisLia); // read linear acceleration
Serial.print(" x: "); \
Serial.print(sLiaAnalog.x);
Serial.print(" y: "); \
Serial.print(sLiaAnalog.y);
Serial.print(" z: "); \
Serial.println(sLiaAnalog.z);
}