zephyr/samples/sensor/accel_trig
Maureen Helm 6fd0363f46 samples: sensor: Disable uart console when rtt console is enabled
Configures the accelerometer polling and trigger samples to disable the
uart console when the rtt console is enabled. Having both consoles
enabled simultaneously doesn't currently work on the apard32690 platform
and it's redundant anyway.

Signed-off-by: Maureen Helm <maureen.helm@analog.com>
2025-05-20 15:23:51 +02:00
..
boards samples: sensor: accel_trig: fix twister tests 2025-02-24 20:19:12 +00:00
src samples: sensor: accel_trig: add sample tap detection feature. 2025-02-14 03:15:54 +01:00
adxl345-trigger.conf samples: sensor: Add adxl345 streaming and trigger configurations 2025-05-20 15:23:51 +02:00
adxl362-trigger.conf
CMakeLists.txt
Kconfig samples: sensor: accel_trig: add sample tap detection feature. 2025-02-14 03:15:54 +01:00
prj.conf
README.rst samples: sensor: accel_trig: fix twister tests 2025-02-24 20:19:12 +00:00
sample.yaml samples: sensor: Disable uart console when rtt console is enabled 2025-05-20 15:23:51 +02:00
x_nucleo_iks01a3.overlay samples: sensor: accel_trig: fix twister tests 2025-02-24 20:19:12 +00:00

.. zephyr:code-sample:: accel_trig
   :name: Accelerometer trigger

   Test and debug accelerometer with interrupts.

Overview
********

This sample application demonstrates how to use 3-Axis accelerometers with triggers.
By default it uses a data ready trigger to read the accelerometer data and print it to the console.

If the accelerometer is enabled with a tap trigger, the sample uses the tap trigger event to
read the accelerometer data and print it to the console.

Building and Running
********************

.. code-block:: devicetree

  / {
    aliases {
      accel0 = &fxos8700;
    };
  };

Make sure the aliases are in devicetree, then build and run with:

.. zephyr-app-commands::
   :zephyr-app: samples/sensor/accel_trig
   :board: <board to use>
   :goals: build flash
   :compact:

With this example, you can also detect a double tap with an accelerometer by activating the
:kconfig:option:`CONFIG_SAMPLE_TAP_DETECTION`.
In this example we use a x_nucleo_iks01a3 shield with a LIS2DW12 accelerometer.
You can build it with the following command:

.. zephyr-app-commands::
   :zephyr-app: samples/sensor/accel_trig
   :board: nrf52dk/nrf52832
   :shield: x_nucleo_iks01a3
   :goals: build
   :west-args: --extra-dtc-overlay x_nucleo_iks01a3.overlay
   :compact:


Sample Output (SENSOR_TRIG_DATA_READY)
=======================================

.. code-block:: console

     fxos8700@1d [m/s^2]:    (   -0.153229,    -0.057461,     9.931148)
     fxos8700@1d [m/s^2]:    (   -0.153229,    -0.057461,     9.931148)
     fxos8700@1d [m/s^2]:    (   -0.143653,    -0.057461,     9.921571)
     fxos8700@1d [m/s^2]:    (   -0.153229,    -0.067038,     9.931148)
     fxos8700@1d [m/s^2]:    (   -0.143653,    -0.067038,     9.921571)
     fxos8700@1d [m/s^2]:    (   -0.134076,    -0.047885,     9.931148)
     fxos8700@1d [m/s^2]:    (   -0.105345,    -0.038308,     9.940725)
     fxos8700@1d [m/s^2]:    (   -0.105345,    -0.019154,     9.931148)
     fxos8700@1d [m/s^2]:    (   -0.105345,    -0.028731,     9.921571)
     fxos8700@1d [m/s^2]:    (   -0.095769,    -0.028731,     9.931148)
     fxos8700@1d [m/s^2]:    (   -0.095769,    -0.009577,     9.940725)


Sample Output (SENSOR_TRIG_DOUBLE_TAP)
======================================

.. code-block:: console

  TAP detected
     lis2dw12@19 [m/s^2]:    (   -1.899901,   -12.550355,    -2.742174)
  TAP detected
     lis2dw12@19 [m/s^2]:    (   12.349357,   -18.125630,     6.015556)
  TAP detected
     lis2dw12@19 [m/s^2]:    (  -11.385050,    -7.274181,    -9.229117)
  TAP detected
     lis2dw12@19 [m/s^2]:    (    9.214760,    -9.286545,     2.311466)
  TAP detected
     lis2dw12@19 [m/s^2]:    (   10.090533,   -17.391034,    12.320643)
  TAP detected
     lis2dw12@19 [m/s^2]:    (   -0.478564,     2.390429,    15.876378)
  TAP detected
     lis2dw12@19 [m/s^2]:    (   -5.668596,   -13.138989,     0.741775)
  TAP detected
     lis2dw12@19 [m/s^2]:    (   -2.385644,   -10.559526,     9.899107)
  TAP detected
     lis2dw12@19 [m/s^2]:    (    7.537391,    -8.551948,    16.740187)