[[PageOutline]] = Accelerometer and Magnetometer Many Gateworks board families come standard with either an Accelerometer, Magnetometer, or other inertial measurement unit (IMU) options. == Supported Devices The specific devices used on our boards are described by the following table: ||= '''Family''' =||= '''Board''' =||= '''Device''' =||= '''Location''' =|| || Venice || GW82xx || LIS2DE12 accelerometer || i2c2@0x19 || || || || LIS2MDL magnetometer || i2c2@0x1e (loading option) || || || GW71xx || LIS2DE12 accelerometer || i2c2@0x19 || || || || LIS2MDL magnetometer || i2c2@0x1e (loading option) || || || GW72xx || LIS2DE12 accelerometer || i2c2@0x19 || || || || LIS2MDL magnetometer || i2c2@0x1e (loading option) || || || GW73xx || LIS2DE12 accelerometer || i2c2@0x19 || || || || LIS2MDL magnetometer || i2c2@0x1e (loading option) || || || GW74xx || LIS2DE12 accelerometer || i2c2@0x19 || || Newport || GW64xx-C+ || LIS2DE12 accelerometer || i2c0@0x19 || || || GW63xx-E+ || LIS2DE12 accelerometer || i2c0@0x19 || || || GW62xx-B+ || LIS2DE12 accelerometer || i2c0@0x19 || || Ventana || GW553x || LSM9DS1 IMU || i2c2@0x1c (mag) i2c2@0x6a (accel/gyro) || || || GW54xx || FXOS8700 accelerometer || i2c3@0x1e || || || GW53xx || FXOS8700 accelerometer || i2c3@0x1e || || || GW522x || FXOS8700 accelerometer || i2c3@0x1e || || || GW520x || FXOS8700 accelerometer || i2c3@0x1e || Individual device information: ||= '''Device''' =||= '''Datasheet''' =||= '''Notes''' =|| || LIS2DE12 || [http://dev.gateworks.com/datasheets/lis2de12.pdf link] || 3 axis accelerometer || || LSM9DS1 || [http://dev.gateworks.com/datasheets/DM00103319.pdf link] || 9 axis internal mass unit (IMU) (accel/mag/gyro) || || FXOS8700 || [http://dev.gateworks.com/datasheets/FXOS8700CQ.pdf link] || 6 axis accelerometer, defaults to low power standby mode and must be enabled || See examples below for more information. == Software Support The API used to access these devices varies depending on the device and sometimes the kernel version. ||= '''Device''' =||= Kernel API =||= Kernel Driver =|| || LIS2DE12 accelerometer || iio || IIO_ST_ACCEL_I2C_3AXIS || || LIS2MDL magnetometer || iio || IIO_ST_MAGN_I2C_3AXIS || || LSM9DS1 imu || iio || IIO_ST_MAGN_I2C_3AXIS (mag) IIO_ST_LSM6DSX_I2C (accel/gyro) || || FXOS8700 accelerometer || iio || FXOS8700_I2C || [=#iio] === Linux industrial I/O bus The modern approach to IMU devices is to use the [https://www.kernel.org/doc/html/v4.12/driver-api/iio/index.html Linux IIO subsystem]. IIO aims to fill the gap between the somewhat similar {{{hwmon}}} and {{{input}}} subsystems. While the {{{hwmon}}} API is directed at low sample rate sensors (like fan speed control or temperature measurement) the {{{input}}} API is focused on human interaction input devices (keyboard, mouse, touchscreen). In some cases there is considerable overlap between these and the {{{iio}}} API. Userspace applications can interact with an IIO driver via either: 1. {{{/sys/bus/iio/devices/iio:deviceX/}}} - represents a hardware sensor and groups together the data channels. Common attributes are {{{name}}}, {{{dev}}}, {{{sampling_frequency_available}}}, and standard attributes. See [https://elixir.bootlin.com/linux/latest/source/Documentation/ABI/testing/sysfs-bus-iio sysfs-bus-iio] for details. * Example (GW54xx with FXOS8700) {{{#!bash # cat /sys/bus/iio/devices/iio\:device0/sampling_frequency_available 1.5625 6.25 12.5 50 100 200 400 800 # echo 100 > /sys/bus/iio/devices/iio\:device0/sampling_frequency # for i in `seq 1 10`; do cat /sys/bus/iio/devices/iio\:device0/in_accel_x_raw ; done 70 70 70 70 90 90 90 90 90 90 }}} 2. {{{/dev/iio:deviceX}}} - character device node interface used for buffered data transfer and for event information retrieval 3. [https://github.com/analogdevicesinc/libiio libiio] - library for interfacing with Linux IIO devices (Ubuntu: libiio-utils iiod, OpenWrt: iio-utils iiod): * Example (GW54xx with FXOS8700) {{{#!bash # iio_info Library version: 0.18 (git tag: v0.18) Compiled with backends: local IIO context created with local backend. Backend version: 0.18 (git tag: v0.18) Backend description string: Linux OpenWrt 4.19.106 #0 SMP Tue Feb 25 22:49:24 2020 armv7l IIO context has 1 attributes: local,kernel: 4.19.106 IIO context has 1 devices: iio:device0: fxos8700 6 channels found: accel_y: (input) 5 channel-specific attributes found: attr 0: raw value: -256 attr 1: sampling_frequency ERROR: Invalid argument (-22) attr 2: sampling_frequency_available value: 1.5625 6.25 12.5 50 100 200 400 800 attr 3: scale value: 0.000244 attr 4: scale_available value: 0.000244 0.000488 0.000976 magn_z: (input) 5 channel-specific attributes found: attr 0: raw value: 0 attr 1: sampling_frequency ERROR: Invalid argument (-22) attr 2: sampling_frequency_available value: 1.5625 6.25 12.5 50 100 200 400 800 attr 3: scale value: 0.000244 attr 4: scale_available value: 0.000001200 accel_z: (input) 5 channel-specific attributes found: attr 0: raw value: 0 attr 1: sampling_frequency ERROR: Invalid argument (-22) attr 2: sampling_frequency_available value: 1.5625 6.25 12.5 50 100 200 400 800 attr 3: scale value: 0.000244 attr 4: scale_available value: 0.000244 0.000488 0.000976 magn_x: (input) 5 channel-specific attributes found: attr 0: raw value: -1660 attr 1: sampling_frequency ERROR: Invalid argument (-22) attr 2: sampling_frequency_available value: 1.5625 6.25 12.5 50 100 200 400 800 attr 3: scale value: 0.000244 attr 4: scale_available value: 0.000001200 accel_x: (input) 5 channel-specific attributes found: attr 0: raw value: 82 attr 1: sampling_frequency ERROR: Invalid argument (-22) attr 2: sampling_frequency_available value: 1.5625 6.25 12.5 50 100 200 400 800 attr 3: scale value: 0.000244 attr 4: scale_available value: 0.000244 0.000488 0.000976 magn_y: (input) 5 channel-specific attributes found: attr 0: raw value: 12800 attr 1: sampling_frequency ERROR: Invalid argument (-22) attr 2: sampling_frequency_available value: 1.5625 6.25 12.5 50 100 200 400 800 attr 3: scale value: 0.000244 attr 4: scale_available value: 0.000001200 1 device-specific attributes found: attr 0: current_timestamp_clock value: realtime }}} References: * https://wiki.analog.com/software/linux/docs/iio/iio * https://elinux.org/images/a/ac/Clausen.pdf [=#android] === Android support via the Android sensor HAL The Android BSP will register an accelerometer and a magnetometer sensor with the OS and therefore can be used with apps conforming the the Android sensor API. References: * ​http://www.tutorialspoint.com/android/android_sensors.htm