zephyr/samples/boards/96b_argonkey/sensors
Gerard Marull-Paretas 79e6b0e0f6 includes: prefer <zephyr/kernel.h> over <zephyr/zephyr.h>
As of today <zephyr/zephyr.h> is 100% equivalent to <zephyr/kernel.h>.
This patch proposes to then include <zephyr/kernel.h> instead of
<zephyr/zephyr.h> since it is more clear that you are including the
Kernel APIs and (probably) nothing else. <zephyr/zephyr.h> sounds like a
catch-all header that may be confusing. Most applications need to
include a bunch of other things to compile, e.g. driver headers or
subsystem headers like BT, logging, etc.

The idea of a catch-all header in Zephyr is probably not feasible
anyway. Reason is that Zephyr is not a library, like it could be for
example `libpython`. Zephyr provides many utilities nowadays: a kernel,
drivers, subsystems, etc and things will likely grow. A catch-all header
would be massive, difficult to keep up-to-date. It is also likely that
an application will only build a small subset. Note that subsystem-level
headers may use a catch-all approach to make things easier, though.

NOTE: This patch is **NOT** removing the header, just removing its usage
in-tree. I'd advocate for its deprecation (add a #warning on it), but I
understand many people will have concerns.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-09-05 16:31:47 +02:00
..
src includes: prefer <zephyr/kernel.h> over <zephyr/zephyr.h> 2022-09-05 16:31:47 +02:00
CMakeLists.txt
README.rst samples: 96b_argonkey: Have README match actual code 2022-07-28 08:50:27 -05:00
prj.conf drivers: led: Remove unnecessary Kconfig settings 2022-08-11 17:46:43 +02:00
sample.yaml

README.rst

.. _ArgonKey_Sensors:

ArgonKey Board Sensors
######################

Overview
********
This sample provides an example of how to read sensor data
from the ArgonKey board. The result is displayed on the console.
It makes use of both the trigger and poll methods.

Requirements
************

This sample just requires the ArgonKey board. The board can be powered
in either one of the following two ways:

- mezzanine mode, plugging the ArgonKey to HiKey board through its 96Board
  low-speed connector
- standalone mode, supplying 5V directly on P1 connector

The user may select or unselect the sensors from
:zephyr_file:`samples/boards/96b_argonkey/sensors/prj.conf`.

Please note that all sensor related code is conditionally compiled
using the ``#ifdef`` directive, so this sample is supposed to always
build correctly. Example:

.. code-block:: c

    #ifdef CONFIG_HTS221
      struct device *hum_dev = DEVICE_DT_GET_ONE(st_hts221);

      if (!device_is_ready(hum_dev)) {
        printk("%s: device not ready.\n", hum_dev->name);
        return;
      }
    #endif

References
**********

- :ref:`96b_argonkey`

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

.. zephyr-app-commands::
    :zephyr-app: samples/boards/96b_argonkey/sensors
    :host-os: unix
    :board: 96b_argonkey
    :goals: run
    :compact:

Sample Output
=============

A USB to TTL 1V8 serial cable may be attached to the low speed connector on
the back of the board on P3.5 (TX) and P3.7 (RX). User may use a simple
terminal emulator, such as minicom, to capture the output.

 .. code-block:: console

    proxy: 1  ;
    distance: 0 m -- 09 cm;
    temp: 30.35 C; press: 97.466259
    humidity: 43.500000
    accel (0.004000 -0.540000 9.757000) m/s2
    gyro (0.065000 -0.029000 -0.001000) dps
    magn (0.049500 0.208500 -0.544500) gauss
    - (6) (trig_cnt: 1878)

    <repeats endlessly every 2s>

In this example the output is generated polling the sensor every 2 seconds.

Sensor data is printed in the following order (no data is printed for
sensors that are not enabled):

#. *VL53L0x* proximity
#. *LPS22HB* baro/temp
#. *HTS221* humidity
#. *LSM6DSL* accel
#. *LSM6DSL* gyro
#. *LIS2MDL* magnetometer (attached to *LSM6DSL*)

The proximity sensor displays two lines:

- a flag (proxy) that goes on when the distance is below 10cm
- the absolute distance from the obstacle

The last line displays a counter of how many trigger interrupts
has been received.  It is possible to display the sensor data
read for each trigger by enabling the **ARGONKEY_TEST_LOG** macro.