# Using Accelerometer on MangOH Red

**URL:** <https://mangoh.discourse.group/t/using-accelerometer-on-mangoh-red/1716>\
**Category:** mangOH Red\
**Created:** [July 15, 2018, 1:00pm UTC](https://mangoh.discourse.group/t/using-accelerometer-on-mangoh-red/1716 "2018-07-15T13:00:00Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bobby](https://avatars.discourse-cdn.com/v4/letter/b/df788c/32.png) [@Bobby](https://mangoh.discourse.group/u/Bobby)\
**Post date:** [July 15, 2018, 1:00pm UTC](https://mangoh.discourse.group/t/using-accelerometer-on-mangoh-red/1716/1 "2018-07-15T13:00:00Z")

</div>

Hello:  
We are trying to use the Accelerometer on the MangOH Red and are wondering about the sensor data output and format that MangOH Red can provide.

If someone has experience using this sensor on MangoOh Red, can you please provide some insights (and documentation) that lays out the sensor parameters that the Accelerometer (such as X,Y, Z axis displacement etc?) can provide and data format there of (floating point, or other).

Appreciate the help.

---

<div class="post-metadata">

**Author:** ![ktanikel](https://avatars.discourse-cdn.com/v4/letter/k/bcef8e/32.png) [@ktanikel](https://mangoh.discourse.group/u/ktanikel)\
**Post date:** [July 16, 2018, 5:40pm UTC](https://mangoh.discourse.group/t/using-accelerometer-on-mangoh-red/1716/2 "2018-07-16T17:40:02Z")

</div>

You can see the RedSensorToCloud app for an example on accelerometer usage. It reports x, y, z readings in m/s2.

---

<div class="post-metadata">

**Author:** ![Bobby](https://avatars.discourse-cdn.com/v4/letter/b/df788c/32.png) [@Bobby](https://mangoh.discourse.group/u/Bobby)\
**Post date:** [August 2, 2018, 2:14pm UTC](https://mangoh.discourse.group/t/using-accelerometer-on-mangoh-red/1716/3 "2018-08-02T14:14:03Z")

</div>

Thanks ktanikel.

We are able to see the raw X, Y, Z accelerometer reading now. However, we are not sure what’s the sampling rate used by the accelerometer chip to sample these values.

Is there an API or an alternate mechanism to know/change the sampling frequency. I understand the chip support 1600Hz sampling frequency but not sure how to set it up.

Any help wold be appreciated.

---

<div class="post-metadata">

**Author:** ![dfrey](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dfrey/32/303_2.png) [@dfrey](https://mangoh.discourse.group/u/dfrey)\
**Post date:** [August 3, 2018, 12:57am UTC](https://mangoh.discourse.group/t/using-accelerometer-on-mangoh-red/1716/4 "2018-08-03T00:57:56Z")

</div>

The bmi160 driver hooks into the iio subsystem of Linux and provides a more advanced way of reading the data than just reading one sample from one channel at a time. Exploring that interface some more is on my to-do list.

---

<div class="post-metadata">

**Author:** ![asyal](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/asyal/32/78_2.png) [@asyal](https://mangoh.discourse.group/u/asyal)\
**Post date:** [August 3, 2018, 3:11am UTC](https://mangoh.discourse.group/t/using-accelerometer-on-mangoh-red/1716/5 "2018-08-03T03:11:48Z")

</div>

@Bobby as @dfrey said we are investigating this feature. we think this feature is doable and will provide this integration in Q4.

---

<div class="post-metadata">

**Author:** ![Bobby](https://avatars.discourse-cdn.com/v4/letter/b/df788c/32.png) [@Bobby](https://mangoh.discourse.group/u/Bobby)\
**Post date:** [August 8, 2018, 4:07pm UTC](https://mangoh.discourse.group/t/using-accelerometer-on-mangoh-red/1716/6 "2018-08-08T16:07:19Z")

</div>

Thanks @dfrey and @asyal, for your feedback.

Ashish - I sent you an email this morning. Kindly review and let us know how do we move forward with the testing please.

Regards

---

<div class="post-metadata">

**Author:** ![ktanikel](https://avatars.discourse-cdn.com/v4/letter/k/bcef8e/32.png) [@ktanikel](https://mangoh.discourse.group/u/ktanikel)\
**Post date:** [October 3, 2018, 11:48pm UTC](https://mangoh.discourse.group/t/using-accelerometer-on-mangoh-red/1716/7 "2018-10-03T23:48:36Z")

</div>

Hi @dfrey, by a ‘more advanced way’ are you talking about setting up iio triggered buffers so that the application can process a chunk of data at a time? I have an accelerometer based application in which I’m polling the sysfs entries for samples - however this is obviously very expensive to do in user space. I’m looking for alternate ways to achieve this and wondering if you’ve made any way headway or if there’s an ETA. Thanks!

---

<div class="post-metadata">

**Author:** ![dfrey](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dfrey/32/303_2.png) [@dfrey](https://mangoh.discourse.group/u/dfrey)\
**Post date:** [October 4, 2018, 2:51am UTC](https://mangoh.discourse.group/t/using-accelerometer-on-mangoh-red/1716/8 "2018-10-04T02:51:34Z")

</div>

I have made progress on this. There is a branch of the mangOH repository named bmi160\_fifo which contains my progress. There are still some to-do items, but it’s working at 100hz. Take a look at samples/bufferedImuRead in the mangOH repository for a sample app.

This does depend on kernel changes that I haven’t published yet. But at least you can take a look.
