1.. zephyr:code-sample:: argonkey_sensors 2 :name: Sensors 3 4 Read sensor data from the ArgonKey board's onboard sensors. 5 6Overview 7******** 8This sample provides an example of how to read sensor data 9from the ArgonKey board. The result is displayed on the console. 10It makes use of both the trigger and poll methods. 11 12Requirements 13************ 14 15This sample just requires the ArgonKey board. The board can be powered 16in either one of the following two ways: 17 18- mezzanine mode, plugging the ArgonKey to HiKey board through its 96Board 19 low-speed connector 20- standalone mode, supplying 5V directly on P1 connector 21 22The user may select or unselect the sensors from 23:zephyr_file:`samples/boards/96boards/argonkey/sensors/prj.conf`. 24 25Please note that all sensor related code is conditionally compiled 26using the ``#ifdef`` directive, so this sample is supposed to always 27build correctly. Example: 28 29.. code-block:: c 30 31 #ifdef CONFIG_HTS221 32 struct device *hum_dev = DEVICE_DT_GET_ONE(st_hts221); 33 34 if (!device_is_ready(hum_dev)) { 35 printk("%s: device not ready.\n", hum_dev->name); 36 return; 37 } 38 #endif 39 40References 41********** 42 43- :ref:`96b_argonkey` 44 45Building and Running 46******************** 47 48.. zephyr-app-commands:: 49 :zephyr-app: samples/boards/96boards/argonkey/sensors 50 :host-os: unix 51 :board: 96b_argonkey 52 :goals: run 53 :compact: 54 55Sample Output 56============= 57 58A USB to TTL 1V8 serial cable may be attached to the low speed connector on 59the back of the board on P3.5 (TX) and P3.7 (RX). User may use a simple 60terminal emulator, such as minicom, to capture the output. 61 62 .. code-block:: console 63 64 proxy: 1 ; 65 distance: 0 m -- 09 cm; 66 temp: 30.35 C; press: 97.466259 67 humidity: 43.500000 68 accel (0.004000 -0.540000 9.757000) m/s2 69 gyro (0.065000 -0.029000 -0.001000) dps 70 magn (0.049500 0.208500 -0.544500) gauss 71 - (6) (trig_cnt: 1878) 72 73 <repeats endlessly every 2s> 74 75In this example the output is generated polling the sensor every 2 seconds. 76 77Sensor data is printed in the following order (no data is printed for 78sensors that are not enabled): 79 80#. *VL53L0x* proximity 81#. *LPS22HB* baro/temp 82#. *HTS221* humidity 83#. *LSM6DSL* accel 84#. *LSM6DSL* gyro 85#. *LIS2MDL* magnetometer (attached to *LSM6DSL*) 86 87The proximity sensor displays two lines: 88 89- a flag (proxy) that goes on when the distance is below 10cm 90- the absolute distance from the obstacle 91 92The last line displays a counter of how many trigger interrupts 93has been received. It is possible to display the sensor data 94read for each trigger by enabling the **ARGONKEY_TEST_LOG** macro. 95