Feather M0 with BNO055, reading acceleration data

Hi guys pleasee could I have some help trying to read off values from the bno055 sensor without using the library, don't really know how to do it but this is what I have got. I also set the bandwidth to 1000hz and max g range

#include <Wire.h>`
#include <Adafruit_Sensor.h>
#define BNO055_ACC_ID           0xFB
#define BNO055_ACC_CONFIG       0x08
#define BNO055_ADDRESS          0x28
#define BNO055_PAGE_ID          0x07
#define BNO055_OPR_MODE         0x3D

#define BNO055_ACCEL_DATA_X_LSB_ADDR  0X08
#define BNO055_ACCEL_DATA_X_MSB_ADDR  0X09
#define BNO055_ACCEL_DATA_Y_LSB_ADDR  0X0A
#define BNO055_ACCEL_DATA_Y_MSB_ADDR  0X0B
#define BNO055_ACCEL_DATA_Z_LSB_ADDR  0X0C
#define BNO055_ACCEL_DATA_Z_MSB_ADDR  0X0D

enum Abw { // ACC Bandwidth
  ABW_7_81Hz = 0,
  ABW_1000Hz = 0x1C   //0x07
};

enum APwrMode { // ACC Pwr Mode
  NormalA = 0,
};

enum Ascale {  // ACC Full Scale
  AFS_2G = 0,
  AFS_16G = 0x03
};

enum OPRMode {  // BNO-55 operation modes
  CONFIGMODE = 0x00,
  ACCONLY = 0x01,
};


void setup(void)
{
  Serial.begin(115200);
  delay(30);
  Wire.begin();
  delay(30);
  Wire.setClock(100000);
  delay(30);
  settingUp();
  delay(30);
}

void loop(void)
{
  int myTime = millis();
  int array[7000][7];

  for ( int x = 0x08; x < 0xE ; x++)
  {
    byte a = readByte(BNO055_ADDRESS, x);
    Serial.print(a);
    Serial.print(",");
}
  Serial.print("\n");
}







uint8_t readByte(uint8_t address, uint8_t subAddress)
{
  uint8_t data; // `data` will store the register data
  Wire.beginTransmission(address);         // Initialize the Tx buffer
  Wire.write(subAddress);                  // Put slave register address in Tx buffer
  Wire.endTransmission(false);        // Send the Tx buffer, but send a restart to keep connection alive
  //  Wire.endTransmission(false);             // Send the Tx buffer, but send a restart to keep connection alive
  //  Wire.requestFrom(address, 1);  // Read one byte from slave register address
  Wire.requestFrom(address, (size_t) 1);   // Read one byte from slave register address
  data = Wire.read();                      // Fill Rx buffer with result
  return data;                             // Return data read from slave register
}

void writeByte(uint8_t address, uint8_t subAddress, uint8_t data)
{
  Wire.beginTransmission(address);  // Initialize the Tx buffer
  Wire.write(subAddress);           // Put slave register address in
  Wire.write(data);                 //
  Wire.endTransmission();           //
}

void settingUp() {
  writeByte(BNO055_ADDRESS, BNO055_OPR_MODE, CONFIGMODE );
  writeByte(BNO055_ADDRESS, BNO055_PAGE_ID, 0x01);
  writeByte(BNO055_ADDRESS, BNO055_ACC_CONFIG, NormalA | ABW_1000Hz |  AFS_16G );
  writeByte(BNO055_ADDRESS, BNO055_PAGE_ID, 0x00);
  writeByte(BNO055_ADDRESS, BNO055_OPR_MODE, 0x01 );
}

Why? A lot of work went into the library, and it will take a lot of work to replace it with your own code.

If code size is an issue, edit the library to remove all the bits you don't need.

Because I have been told to haha, not allowed to use the library which I know is counter intuitive but they want me to learn this way ... which I apparently can't do I'm really struggling haha

Forum members are happy to answer specific questions about programming Arduinos, and in some cases about popular sensors, but most won't write code for you.

Please see the "How to get the best out of the forum" post, linked at the head of every forum topic.

There are some decent Arduino tutorials on line about using the I2C bus to transfer data to and from various sensors.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.