README.rst
1.. zephyr:code-sample:: proximity_polling
2 :name: Proximity sensor
3 :relevant-api: sensor_interface
4
5 Get proximity data from up to 10 proximity sensors (polling mode).
6
7Overview
8********
9
10This sample demonstrates how to use one or multiple proximity sensors.
11
12Building and Running
13********************
14
15The sample supports up to 10 proximity sensors. The number of the sensors will
16automatically detected from the devicetree, you only need to set aliases from
17``prox-sensor-0`` to ``prox-sensor-9``.
18
19For example:
20
21.. code-block:: devicetree
22
23 / {
24 aliases {
25 prox-sensor0 = &tmd2620;
26 };
27 };
28
29After creating the devicetree overlay you can build the sample with:
30
31.. zephyr-app-commands::
32 :zephyr-app: samples/sensor/proximity_polling
33 :board: <your_board>
34 :goals: build flash
35 :compact:
36
37Sample Output
38=============
39
40.. code-block:: console
41
42 *** Booting Zephyr OS build zephyr-v3.2.0-210-gd95295f08646 ***
43 Proximity sensor sample application
44 Found 1 proximity sensor(s): tmd2620@29
45 Proximity on tmd2620@29: 202
46 Proximity on tmd2620@29: 205
47 Proximity on tmd2620@29: 204
48 Proximity on tmd2620@29: 60
49 Proximity on tmd2620@29: 1
50