Hello everyone,
I am a student and currently in my practical phase. I am trying to figure out what I am doing wrong when trying to read out the gyro data of the BMI270 for example.
I tried to compile the official Sensor API on Github but ran into error codes with COINES (i installed it) while compiling, so I used the latest version v2-53-2 which was without COINES, compiled it and ran into this error:
Error [-9] : Configuration load error. It occurs when failure observed while loading the configuration into the sensor
Which I couldn't figure out how to solve, so I started to write my own code as I really only want to read out the gyro data itself.
I connected the BMI270 via the quickconnect cable to the Raspberry Pi pins 1 (3.3 VDC), 3 (GPIO8 SDA1 (I2C)), 5 (GPIO 9 SCL1 (I2C)) and 9 (ground).
I am currently using the WiringPi library found here: http://wiringpi.com/
Essentially these are all the functions from the WiringPi libary for I2C:
int wiringPiI2CRead (int fd) ;
int wiringPiI2CWrite (int fd, int data) ;
int wiringPiI2CWriteReg8 (int fd, int reg, int data) ;
int wiringPiI2CWriteReg16 (int fd, int reg, int data) ;
int wiringPiI2CReadReg8 (int fd, int reg) ;
int wiringPiI2CReadReg16 (int fd, int reg) ;
There are also these functions which I wasn't able to use yet because I didn't know how I should give this function the dPin and cPin, though I saw that the cPin is 13 and dPin is 14 in the Datasheet.
uint8_t shiftIn (uint8_t dPin, uint8_t cPin, uint8_t order) ;
void shiftOut (uint8_t dPin, uint8_t cPin, uint8_t order, uint8_t val) ;
In general I tried following the Quickstart Guide in the BMI270 Datasheet when writing my code.
Console logs of my code:
------START------
Device found!
DEVICE_ID: 3
CHIP_ID: 0x24
WRITING DATA ......... --> LAST DATA: 0xC1
Initialization status: 00000000 (Bit 0 = 1 --> OK)
7D before: 00001110
7D after: 00001110
40 before: 10101000
40 after: 10101000
42 before: 11101001
42 after: 11101001
7C before: 00000000
7C after: 00000010
rateX -8-Data_14: 0
rateX2-8-Data_15: 0
rateY -8-Data_16: 0
rateY2-8-Data_17: 0
rateZ -8-Data_18: 0
rateZ2-8-Data_19: 0
rateX -8-Data_14: 0
rateX2-8-Data_15: 0
rateY -8-Data_16: 0
rateY2-8-Data_17: 0
rateZ -8-Data_18: 0
rateZ2-8-Data_19: 0
rateX -8-Data_14: 0
rateX2-8-Data_15: 0
rateY -8-Data_16: 0
rateY2-8-Data_17: 0
rateZ -8-Data_18: 0
rateZ2-8-Data_19: 0
------END------
My burst_write function is essentially just using wiringPiI2CWriteReg8(..) in a for loop. Not sure if that would be the right way to do it when you want to upload the config file. But I believe it is probably not, because when I read out the Initialization status I alway receive a 0 for the Bit 0, which according to the Datasheet means its "not ok".
All in all I believe setting bits in the register works, but for some reason I can't read out data, probably because I am doing it wrong I believe. Also I tried out a very simple python code with the BMI160 and a compatible python Driver for it to test if the I2C even works and it seems to give me data there. I didn't try anything in python with the BMI270 yet because I wanted to keep it in C/C++. Maybe there could also be a problem with the WiringPi library I am using. Or I am just missing a specific register which I didn't set properly yet?
Or recommend me a different library which I could use or even post a code sample which works simliar to mine without using the Sensor API of Bosch.
Hopefully someone can help me bringt light into this. 🙂
Best Regards
Kevin
This is how my code looks at the moment:
int rateX = wiringPiI2CReadReg8(fd, DATA_14);
// REMOVED FOR FORUMS POST