03-28-2020 11:51 AM - edited 03-28-2020 12:31 PM
Hi,
actually I want to read data from BMI270 of accelerometer with Arduino Nano.
First of all I tried reading data by using this .ino file from github and the corresponding libraries.
Unfortunately there is an error occurring while compiling which I am not getting solved.
bmi2.h:1341:2: error: #endif without #if
#endif /* BMI2_H_ */
So I decided to try using just wire.h library.
The I2C device is getting recocnised, when asking for ID I receive 0x24 which is correct too.
I followed the instructions for normal power mode on page 23 of datasheet.
I read the register values and they are written correct but the accelerometer values are still zero.
This is the code I use for reading the LSB of the arduino:
#include <Wire.h> //I2C Arduino Library
#define address 0x69 //I2C 7bit address
int response;
void setup(){
//Initialize Serial and I2C communications
Serial.begin(9600);
Wire.begin();
delay(100);
Wire.setClock(400000UL);
// setting IMU270 in normal mode
Wire.beginTransmission(address);
Wire.write(0x7D); //PWR_Control Register
Wire.write(0x0E); // enable acquistion of acc,gyro and temp
Wire.endTransmission();
Wire.beginTransmission(address);
Wire.write(0x40); // Acc config
Wire.write(0xA8); //
Wire.endTransmission();
Wire.beginTransmission(address);
Wire.write(0x42); // Gyro config
Wire.write(0xA9);
Wire.endTransmission();
Wire.beginTransmission(address); //
Wire.write(0x7C); // PWR config
Wire.write(0x02);
Wire.endTransmission();
}
void loop()
{
Wire.beginTransmission(address);
Wire.write(0x0C); // reading LSB of Acc
Wire.requestFrom(address,1);
if(Wire.available()<=1)
{
response = Wire.read();
}
Wire.endTransmission();
Serial.println(response);
delay(500);
}
Thanks in advance!
Solved! Go to Solution.
03-28-2020 08:05 PM
Oh, I just realized what your problem is. You haven't uploaded the config into the device. On every boot you need to upload the full 8KB config file into the device as that's the microcode for the sensor. It won't do anything without it.
03-28-2020 11:49 PM
I skipped this step in hope it's not necessary becuase I have to figure out how to implement the BMI270_main.tbin.
I will try.
Thank you!!
08-08-2023 10:42 AM
Dear Menedee,
I am currently working on Arduino Nano BLE sense Rev2 and struggling in reading BMI270 data. Right now I can use the official code: https://github.com/arduino-libraries/Arduino_BMI270_BMM150 to achieve 200Hz sample rate, however, it is far lower than the highest sample rate. So I want to write some code based on I2C.
Do you have any progress? Would you mind teach me?