The latest development version of this page may be more current than this released 1.14.0 version.

FXOS8700 Accelerometer/Magnetometer Sensor

Overview

This sample application shows how to use the FXOS8700 driver. The driver supports FXOS8700 accelerometer/magnetometer and MMA8451Q, MMA8652FC, MMA8653FC accelerometers.

Building and Running

This project outputs sensor data to the console. FXOS8700 sensor is present on the NXP FRDM-K64F, NXP FRDM-KW41Z, and Hexiwear boards. Accelerometer only devices are present on the NXP FRDM-KL25Z, BBC MicroBit, and reel board boards. It does not work on QEMU.

Building and Running for FRDM-K64F

FRDM-K64F is equipped with FXOS8700CQ accelerometer and magnetometer. Sample can be built and executed for the FRDM-K64F as follows:

# On Linux/macOS
cd $ZEPHYR_BASE/samples/sensor/fxos8700
mkdir build && cd build
# On Windows
cd %ZEPHYR_BASE%\samples\sensor\fxos8700
mkdir build & cd build
cmake -GNinja -DBOARD=frdm_k64f ..
ninja
ninja flash

Example building for the FRDM-K64F with motion detection support:

# On Linux/macOS
cd $ZEPHYR_BASE/samples/sensor/fxos8700
mkdir build && cd build
# On Windows
cd %ZEPHYR_BASE%\samples\sensor\fxos8700
mkdir build & cd build
cmake -GNinja -DBOARD=frdm_k64f -DCONF_FILE="prj.conf overlay-motion.conf" ..
ninja
ninja flash

Building and Running for FRDM-KL25Z

FRDM-KL25Z is equipped with MMA8451Q accelerometer. Sample can be built and executed for the FRDM-KL25Z as follows:

# On Linux/macOS
cd $ZEPHYR_BASE/samples/sensor/fxos8700
mkdir build && cd build
# On Windows
cd %ZEPHYR_BASE%\samples\sensor\fxos8700
mkdir build & cd build
cmake -GNinja -DBOARD=frdm_kl25z -DCONF_FILE="prj_accel.conf" ..
ninja
ninja flash

Building and Running for Micro Bit

Micro Bit is equipped with MMA8653FC accelerometer. Sample can be built and executed for the Micro Bit as follows:

# On Linux/macOS
cd $ZEPHYR_BASE/samples/sensor/fxos8700
mkdir build && cd build
# On Windows
cd %ZEPHYR_BASE%\samples\sensor\fxos8700
mkdir build & cd build
cmake -GNinja -DBOARD=bbc_microbit -DCONF_FILE="prj_accel.conf" ..
ninja
ninja flash

Building and Running for reel board

The reel board is equipped with MMA8652FC accelerometer. Sample can be built and executed for the reel board as follows:

# On Linux/macOS
cd $ZEPHYR_BASE/samples/sensor/fxos8700
mkdir build && cd build
# On Windows
cd %ZEPHYR_BASE%\samples\sensor\fxos8700
mkdir build & cd build
cmake -GNinja -DBOARD=reel_board -DCONF_FILE="prj_accel.conf" ..
ninja
ninja flash

Sample Output

AX= -0.191537 AY=  0.067037 AZ=  9.902418 MX=  0.379000 MY=  0.271000 MZ= -0.056000 T= 22.080000
AX= -0.162806 AY=  0.143652 AZ=  9.940725 MX=  0.391000 MY=  0.307000 MZ= -0.058000 T= 22.080000
AX= -0.172383 AY=  0.134075 AZ=  9.969455 MX=  0.395000 MY=  0.287000 MZ= -0.017000 T= 22.080000
AX= -0.210690 AY=  0.105344 AZ=  9.911994 MX=  0.407000 MY=  0.306000 MZ= -0.068000 T= 22.080000
AX= -0.153229 AY=  0.124498 AZ=  9.950302 MX=  0.393000 MY=  0.301000 MZ= -0.021000 T= 22.080000
AX= -0.153229 AY=  0.095768 AZ=  9.921571 MX=  0.398000 MY=  0.278000 MZ= -0.040000 T= 22.080000
AX= -0.162806 AY=  0.105344 AZ=  9.902418 MX=  0.372000 MY=  0.300000 MZ= -0.046000 T= 22.080000

<repeats endlessly>