SAM4S Drivers for the BNO055 Xpro

Posted By on Jun 15, 2016 | 6 comments


I recently acquired an Atmel BNO055 Xplained Pro board, which features a 9-axis absolute orientation sensor, or at least that is the part I’m interested in. Then I found that the ASF does not provide BNo055 support for the SAM4S. Luckily, it does for the SAM E70. So I adapted the SAM E70 drivers to work with the SAM4S, and surprisingly it worked without any issues.

Note that the drivers in the ASF are a port from the ones provided by Bochs (BNO055 chip manufacturer).

In the downloads you will find an Atmel Studio 7 solution. The /ASF/ThirdParty/bno055 folder contains the driver’s source code, and /config/conf_bno055.h is the configuration file. It is tested for ASFv3.34.1.

The downloads also include three examples. motion_example.c demonstrates how to configure the sensor in low power mode. That is, when no motion is detected the sensor’s MCU goes to sleep, and, when it detects movement (while sleeping), it wakes up and interrupts the main MCU (SAM4S in this case). orientation_example.c configures the sensor in normal mode (no interrupts) and reads orientation values. Lastly, motion_and_orientation.c is a combination of the two, and demonstrate how to read the sensor only when it is awake.

 

Demo

 

Reading other output data

Like I mentioned above, I was not interested in anything other than orientation values, but it is possible to query the sensor for other fused and non-fused data (e.g. raw accelerometer data). I have not test them, but the SAM E70 example was using these:

struct bno055_linear_accel_t bno055_linear_accel_data;
struct bno055_gravity_t bno055_gravity_data;
struct bno055_accel_t bno055_accel_data;
struct bno055_gyro_t bno055_gyro_data;
struct bno055_mag_t bno055_mag_data;

bno055_read_accel_xyz(&bno055_accel_data);
bno055_read_gyro_xyz(&bno055_gyro_data);
bno055_read_mag_xyz(&bno055_mag_data);
bno055_read_linear_accel_xyz(&bno055_linear_accel_data);
bno055_read_gravity_xyz(&bno055_gravity_data);

 

Possibly useful documentation

 

Downloads

Atmel Studio Solution

Download

 

Use examples

Download

 

 

6 Comments

  1. BEGINNER!
    I purchased the atsamv71q21 to integrate it with bno055 at the behest that already there is an example project of samd21 with bno055 in ATMEL Studio 7. Sadly, I could not locate the latter example project in ATMEL studio 7. Albeit, an example of same70 exists with bno055. I do not have enough knowledge how to utilize the drivers from there!!!!!
    I need help, please, in installing the driver available in github for BNO055 into ATMEL studio 7. Cannot understand how to manage the .c and .h files. Please help me with some instructions on this so i can activitate the bno055. I was not successful with the driver already within ATMEL Studio 7.
    Sincerely,
    Jawad

    Post a Reply
    • The same happened to me. In my case I started from the SAME70 port available in the ASF (when you create a new SAME70 BNO055 example project ). That port, if you go and look at the source code, you’ll see it’s a port of the original Bochs drivers. You could start from that example (the ASF one), or even the example in this post. Because they both use the ASF, they may give you hints on what exactly you need to modify to make it work for the ATSAMV71Q21. (I don’t recall exactly, but there aren’t that many changes to make. Good luck)

      Cheers,
      Rafael

      Post a Reply
  2. Hello Rafael,

    first of all thanks for your working programm. I wrote a program for the BNO055 xplained and it worked well in the beginning. But then, i dont know why, it stoped with faulty values.
    Now i know that my both boards are OK.

    Is it right that the heading always shows zero when you reset the board? Can it be that euler shows only the heading relativ to the moment you start the chip?

    Post a Reply
    • I’m not entirely sure (I’d need to check the documentation), but my understanding was that position was absolute. If that’s true, then it shouldn’t start with zero. Did you added any code between the time it worked and the time it stopped working? If so, it’s most likely a bug. Verify step by step your program. Make use of Atmel Studio’s debugger—it is pretty neat. If you still can’t solve your problem, give me more specific details and maybe I can offer some hints. Rafael.

      Post a Reply
      • So, i tried it yesterday evening. It starts always with 360 degree. But it moves to the nearly correct position a little bit later. May be the internal calibration makes his job. But when you move it fast in all directions, it looses his zero position. Between 2 and 9 degree +/-
        But it comes back to his normal.
        I choosed this chip, because it has all build inside, what i need. Now i have a basis to work.

        Post a Reply
        • Good. It’s a pretty nice chip indeed. I’ve been looking to do something with it for some time already, but haven’t have the time. Hopefully you can do something interesting with it. Good luck.

          Post a Reply

Submit a Comment

Your email address will not be published. Required fields are marked *