12-22-2022 01:51 PM
Hi,
I m writing drivers with BNO055 for embedded Linux. In the initialization state I loaded all the hex initialization configuration to the sensor. And in my application when I read from it I have floating readings when I leave the device still, no rotation or moving the device at all. Is there anything wrong with my driver?
I also have my reading code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#define IOCTL_MODULE "/dev/app_ioctl"
#define IMU_SENSOR_DATA _IOR('a',12,int32_t*)
struct bmi_sensor_data {
int16_t accel_x;
int16_t accel_y;
int16_t accel_z;
int16_t gyro_x;
int16_t gyro_y;
int16_t gyro_z;
};
int main()
{
int ret = 0;
struct bmi_sensor_data sensor_data = {0};
int fd = open(IOCTL_MODULE, O_RDWR);
if(fd < 0) {
printf("zxj ============open %s fail!\n", IOCTL_MODULE);
return -1;
}
while(1) {
ret = ioctl(fd, IMU_SENSOR_DATA, &sensor_data);
printf("App Acc_Raw_X : %d Acc_Raw_Y : %d Acc_Raw_Z : %d \n",
sensor_data.accel_x,
sensor_data.accel_y,
sensor_data.accel_z);
printf("Gyr_Raw_X : %d Gyr_Raw_Y : %d Gyr_Raw_Z : %d \n",
sensor_data.gyro_x,
sensor_data.gyro_y,
sensor_data.gyro_z);
}
close(fd);
return 0;
}
12-27-2022 07:51 AM
Hi MartinShi,
Please refer to the attached code on STM32 and test results. Use the sensor API on github(https://github.com/boschsensortec/BNO055_driver) and place BNO055 horizontally.