• Home
  • Annotate
  • current directory
Name Date Size #Lines LOC

..22-Aug-2025-

boards/22-Aug-2025-

src/22-Aug-2025-

CMakeLists.txt A D22-Aug-2025261 107

Kconfig A D22-Aug-2025262 1410

README.rst A D22-Aug-20253.1 KiB8969

adxl345-trigger.conf A D22-Aug-2025121 51

adxl362-trigger.conf A D22-Aug-2025153 62

prj.conf A D22-Aug-202572 43

sample.yaml A D22-Aug-20252.1 KiB6968

x_nucleo_iks01a3.overlay A D22-Aug-2025508 2119

README.rst

1.. zephyr:code-sample:: accel_trig
2   :name: Accelerometer trigger
3
4   Test and debug accelerometer with interrupts.
5
6Overview
7********
8
9This sample application demonstrates how to use 3-Axis accelerometers with triggers.
10By default it uses a data ready trigger to read the accelerometer data and print it to the console.
11
12If the accelerometer is enabled with a tap trigger, the sample uses the tap trigger event to
13read the accelerometer data and print it to the console.
14
15Building and Running
16********************
17
18.. code-block:: devicetree
19
20  / {
21    aliases {
22      accel0 = &fxos8700;
23    };
24  };
25
26Make sure the aliases are in devicetree, then build and run with:
27
28.. zephyr-app-commands::
29   :zephyr-app: samples/sensor/accel_trig
30   :board: <board to use>
31   :goals: build flash
32   :compact:
33
34With this example, you can also detect a double tap with an accelerometer by activating the
35:kconfig:option:`CONFIG_SAMPLE_TAP_DETECTION`.
36In this example we use a x_nucleo_iks01a3 shield with a LIS2DW12 accelerometer.
37You can build it with the following command:
38
39.. zephyr-app-commands::
40   :zephyr-app: samples/sensor/accel_trig
41   :board: nrf52dk/nrf52832
42   :shield: x_nucleo_iks01a3
43   :goals: build
44   :west-args: --extra-dtc-overlay x_nucleo_iks01a3.overlay
45   :compact:
46
47
48Sample Output (SENSOR_TRIG_DATA_READY)
49=======================================
50
51.. code-block:: console
52
53     fxos8700@1d [m/s^2]:    (   -0.153229,    -0.057461,     9.931148)
54     fxos8700@1d [m/s^2]:    (   -0.153229,    -0.057461,     9.931148)
55     fxos8700@1d [m/s^2]:    (   -0.143653,    -0.057461,     9.921571)
56     fxos8700@1d [m/s^2]:    (   -0.153229,    -0.067038,     9.931148)
57     fxos8700@1d [m/s^2]:    (   -0.143653,    -0.067038,     9.921571)
58     fxos8700@1d [m/s^2]:    (   -0.134076,    -0.047885,     9.931148)
59     fxos8700@1d [m/s^2]:    (   -0.105345,    -0.038308,     9.940725)
60     fxos8700@1d [m/s^2]:    (   -0.105345,    -0.019154,     9.931148)
61     fxos8700@1d [m/s^2]:    (   -0.105345,    -0.028731,     9.921571)
62     fxos8700@1d [m/s^2]:    (   -0.095769,    -0.028731,     9.931148)
63     fxos8700@1d [m/s^2]:    (   -0.095769,    -0.009577,     9.940725)
64
65
66Sample Output (SENSOR_TRIG_DOUBLE_TAP)
67======================================
68
69.. code-block:: console
70
71  TAP detected
72     lis2dw12@19 [m/s^2]:    (   -1.899901,   -12.550355,    -2.742174)
73  TAP detected
74     lis2dw12@19 [m/s^2]:    (   12.349357,   -18.125630,     6.015556)
75  TAP detected
76     lis2dw12@19 [m/s^2]:    (  -11.385050,    -7.274181,    -9.229117)
77  TAP detected
78     lis2dw12@19 [m/s^2]:    (    9.214760,    -9.286545,     2.311466)
79  TAP detected
80     lis2dw12@19 [m/s^2]:    (   10.090533,   -17.391034,    12.320643)
81  TAP detected
82     lis2dw12@19 [m/s^2]:    (   -0.478564,     2.390429,    15.876378)
83  TAP detected
84     lis2dw12@19 [m/s^2]:    (   -5.668596,   -13.138989,     0.741775)
85  TAP detected
86     lis2dw12@19 [m/s^2]:    (   -2.385644,   -10.559526,     9.899107)
87  TAP detected
88     lis2dw12@19 [m/s^2]:    (    7.537391,    -8.551948,    16.740187)
89