Retrieve a Buffer of Data from BMI160

I would like to retrieve a buffer of data from the BMI160 instead of just single samples. Is this possible? If so how would I go about doing it from user space?


There’s a bmi160_fifo branch in the mangOH repository that takes a stab at this. There is also this corresponding app which performs a read.

I haven’t looked at this stuff in a little while, so I don’t remember the exact status of it all.

1 Like

@dfrey Thanks for pointing that out. I quickly reviewed it and I have some followup questions.

First, context. I’m trying to access, from user space, the trigger buffer of data that was captured when the interrupt fires. This should have the significant motion event. Once I have this buffer then I plan on performing some analysis in the user space.

  1. Is libiio the only way to access the trigger buffer from user space?

  2. The branch you pointed me to requires LIBIIO. I’m working with the WP85 module which doesn’t have the IIO builtin by default. Is LIBIIO compatible the WP85 as long as I am building in IIO?

  3. Currently our BMI160 driver is set to generate interrupts on significant motion. When this happens a buffer is captured in IIO. Can’t I just call fscanf in a loop and read the contents of the buffer?


The bmi160 driver sits on top of the IIO kernel framework. On wp85/75, IIO wasn’t built with the kernel. As a result, we pulled some of that code out of tree and built it as modules and bundled those modules with the Legato system.

libiio is a userspace library for accessing IIO devices. It provides convenience over manually traversing /dev and /sys/bus/iio. It’s not “magic” though, so anything you do with libiio can be achieved without it.

When I worked on the buffered reading for bmi160 I was focusing exclusively on the wp76. I don’t recall if all the necessary IIO kernel modules are provided for wp85/75.

@dfrey Thanks will dive in and give it a try. You mentioned here the Using Accelerometer on MangOH Red the the bmi160_fifo requires an unpublished kernel change. Can you elaborate further?

Unfortunately, I have forgotten what I was referring to. Let me know if you find that something is missing when you try to put this together. It may jog my memory.

Sorry if I’m late to the party, but we had pretty much the same requirement of needing chunks of data from the accelerometer instead of single samples.

I tried David’s bmi160_fifo branch, but wasn’t very familiar with IIO so ended up ditching that effort. Instead I switched to using the BMI160’s onboard FIFO to get a thousand samples every 250ms. You can tie the FIFO interrupt to your application so you know exactly when the FIFO’s full. I switched out the kernel module for BMI160 and instead used a user space driver from Bosch to achieve this.

@ktanikel Better late than never, right :wink: Thanks for the tip I will consider doing that instead.

The bmi160_fifo branch uses both an IIO kernel FIFO and the bmi160’s hardware FIFO. The idea was to sample continuously and service the buffers quickly enough such that they would never overflow.