Skip to main content
Sharat_Rao
Associate II
December 27, 2024
Solved

Using 'libiio' to read Accelerometer data from the IMU

  • December 27, 2024
  • 1 reply
  • 1376 views

 

We want to use iio buffers to read accelerometer data. I tried the following, but it did not work. 

root@FAFUSION:/sys/bus/iio/devices/iio:device2# ls
buffer current_timestamp_clock events in_accel_scale_available in_accel_y_raw mount_matrix of_node sampling_frequency scan_elements uevent
buffer0 dev in_accel_scale in_accel_x_raw in_accel_z_raw name power sampling_frequency_available subsystem waiting_for_supplier
root@FAFUSION:/sys/bus/iio/devices/iio:device2# cat name
ism330dhcx_accel
root@FAFUSION:/sys/bus/iio/devices/iio:device2#

root@FAFUSION:/sys/bus/iio/devices/iio:device2# echo 1 > scan_elements/in_accel_x_en
root@FAFUSION:/sys/bus/iio/devices/iio:device2# echo 1 > scan_elements/in_accel_y_en
root@FAFUSION:/sys/bus/iio/devices/iio:device2# echo 1 > scan_elements/in_accel_z_en
root@FAFUSION:/sys/bus/iio/devices/iio:device2# echo 1 > buffer0/in_accel_x_en
root@FAFUSION:/sys/bus/iio/devices/iio:device2# echo 1 > buffer0/in_accel_y_en
root@FAFUSION:/sys/bus/iio/devices/iio:device2# echo 1 > buffer0/in_accel_z_en
root@FAFUSION:/sys/bus/iio/devices/iio:device2# echo 1 > scan_elements/in_timestamp_en
root@FAFUSION:/sys/bus/iio/devices/iio:device2# echo 1 > buffer0/in_timestamp_en
root@FAFUSION:/sys/bus/iio/devices/iio:device2# echo 833 > sampling_frequency
root@FAFUSION:/sys/bus/iio/devices/iio:device2# echo 1 > buffer/enable

root@FAFUSION:/sys/bus/iio/devices/iio:device2# echo 1 > buffer0/enable root@FAFUSION:/sys/bus/iio/devices/iio:device2# cat buffer0/*
0
in
1
1
0
le:s16/16>>0
1
1
le:s16/16>>0
1
2
le:s16/16>>0
1
3
le:s64/64>>0
1024
1
root@FAFUSION:/sys/bus/iio/devices/iio:device2# iio_readdev ism330dhcx_accel accel_x accel_y accel_z timestamp
WARNING: High-speed mode not enabled
Unable to refill buffer: Connection timed out (110)

What is the correct way of using 'libiio' to read the accelerometer data 

Best answer by Sharat_Rao

Hi @Federica Bossi ,

The link you have provided has drivers which we are already using as part of the Mickledore distribution but it does not provide any user-space application examples to read the sensor using IIO.

Anyway, we have been able to write our own application that pulls the data out of the FIFO at a good rate.

1 reply

Federica Bossi
Technical Moderator
January 3, 2025

Hi @Sharat_Rao ,

Have you already looked at our official drivers and examples on Github?

Hope this helps!

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
Sharat_Rao
Sharat_RaoAuthorBest answer
Associate II
January 11, 2025

Hi @Federica Bossi ,

The link you have provided has drivers which we are already using as part of the Mickledore distribution but it does not provide any user-space application examples to read the sensor using IIO.

Anyway, we have been able to write our own application that pulls the data out of the FIFO at a good rate.