1.. zephyr:code-sample:: sensor_shell 2 :name: Sensor shell 3 :relevant-api: sensor_interface 4 5 Interact with sensors using the shell module. 6 7Overview 8******** 9This is a simple shell module to get data from sensors presented in the system. 10 11Building and Running 12******************** 13 14Build the sample app by choosing the target board that has sensors drivers 15enabled, for example: 16 17.. zephyr-app-commands:: 18 :zephyr-app: samples/sensor/sensor_shell 19 :board: reel_board 20 :goals: build flash 21 22For boards that do not have a sensor, a simple fake sensor driver is provided, for example: 23 24.. zephyr-app-commands:: 25 :zephyr-app: samples/sensor/sensor_shell 26 :board: qemu_riscv64 27 :goals: run 28 :gen-args: -DCONFIG_SAMPLES_SENSOR_SHELL_FAKE_SENSOR=y 29 30Shell Module Command Help 31========================= 32 33.. code-block:: console 34 35 sensor - Sensor commands 36 Subcommands: 37 get :Get sensor data. Channel names are optional. All channels are read when 38 no channels are provided. Syntax: 39 <device_name> <channel name 0> .. <channel name N> 40 info :Get sensor info, such as vendor and model name, for all sensors. 41 42 43**get**: prints all the sensor channels data for a given sensor device name. 44Optionally, a single channel name or index can be passed to be printed out. The 45device name and channel name are autocompleted. 46 47Output example (reel_board): 48 49.. code-block:: console 50 51 uart:~$ sensor get mma8652fc@1d 52 channel idx=0 accel_x = 0.000000 53 channel idx=1 accel_y = 0.268150 54 channel idx=2 accel_z = 9.959878 55 channel idx=3 accel_xyz x = 0.000000 y = 0.268150 z = 9.959878 56 57 uart:~$ sensor get mma8652fc@1d accel_z 58 channel idx=2 accel_z = 9.959878 59 60 uart:~$ sensor get mma8652fc@1d 2 61 channel idx=2 accel_z = 9.959878 62 63.. note:: 64 A valid sensor device name should be passed otherwise you will get an 65 undefined behavior like hardware exception. This happens because the shell 66 subsystem runs in supervisor mode where API callbacks are not checked before 67 being called. 68 69**info**: prints vendor, model, and friendly name information for all sensors. 70This command depends on enabling :kconfig:option:`CONFIG_SENSOR_INFO`. 71 72.. code-block:: console 73 74 uart:~$ sensor info 75 device name: apds9960@39, vendor: Avago Technologies, model: apds9960, friendly name: (null) 76 device name: mma8652fc@1d, vendor: NXP Semiconductors, model: fxos8700, friendly name: (null) 77 device name: ti_hdc@43, vendor: Texas Instruments, model: hdc, friendly name: (null) 78 device name: temp@4000c000, vendor: Nordic Semiconductor, model: nrf-temp, friendly name: (null) 79