cancel
Showing results for 
Search instead for 
Did you mean: 

Using 'libiio' to read Accelerometer data from the IMU

Sharat_Rao
Associate II

 

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 

0 REPLIES 0