zephyr/samples/sensor/thermometer
Maureen Helm 3f218c6cda samples: sensor: Relax twister constraints on thermometer sample
The thermometer sensor sample application can support any board that
defines the `ambient-temp0` devicetree alias, but the restrictive
`platform_allow` list prevented twister from running on all but two
selected boards. Use a more flexible `dt_alias_exists` filter instead to
allow running this sample on additional boards.

Signed-off-by: Maureen Helm <maureen.helm@analog.com>
2024-04-01 18:21:09 +01:00
..
boards samples: sensor: thermometer: add trigger support to sample 2023-06-17 08:01:16 -04:00
src samples: sensor: thermometer: add trigger support to sample 2023-06-17 08:01:16 -04:00
CMakeLists.txt cmake: increase minimal required version to 3.20.0 2021-08-20 09:47:34 +02:00
prj.conf samples: add FP formatting to all samples that require it 2020-11-17 14:44:59 -06:00
README.rst hwmv2: Introduce Hardware model version 2 and convert devices 2024-03-02 16:56:33 -05:00
sample.yaml samples: sensor: Relax twister constraints on thermometer sample 2024-04-01 18:21:09 +01:00

.. _thermometer-sample:

Thermometer sample
##################

Overview
********

This sample application periodically measures the ambient temperature
at 1Hz. The result is written to the console.

Wiring
*******

VDD pin should be connected to 2.3V to 5.5V
GND pin connected to 0V
VOUT pin connected to the ADC input pin.

.. _`MCP970X Sensor`: http://ww1.microchip.com/downloads/en/devicedoc/20001942g.pdf

An overlay is provided for the nrf52840dk/nrf52840 board with the
sensor connected to pin AIN7.

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

To build for the nrf52840dk/nrf52840 board use:

.. zephyr-app-commands::
	:zephyr-app: samples/sensor/thermometer
	:board: nrf52840dk/nrf52840
	:goals: build flash
	:compact:


To build for other boards and ambient temperature sensors, enable the sensor
node that supports ``SENSOR_CHAN_AMBIENT_TEMP`` and use an overlay to create an
alias named ``ambient-temp0`` to link to the node.  See the overlay used for the
``nrf52840dk/nrf52840`` board within this sample:
``boards/nrf52840dk_nrf52840.overlay``


Temperature Alert
=================

If the attached sensor supports alerts when the temperature drifts above or
below a threshold, the sample will enable the sensor's trigger functionality.
This will require the sensor's TRIGGER KConfig setting to be enabled. An
example of this setup is provided for the ``frdm_k22f`` board, using
``boards/frdm_k22f.conf``.

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

.. code-block:: console

        *** Booting Zephyr OS build zephyr-v3.3.0-2354-gb4f4bd1f1c22 ***
        Thermometer Example (arm)
        Temperature device is 0x525c, name is tcn75a@48
        Set temperature lower limit to 25.5°C
        Set temperature upper limit to 26.5°C
        Enabled sensor threshold triggers
        Temperature is 25.0°C
        Temperature is 25.0°C
        Temperature is 25.0°C
        Temperature is 25.0°C
        Temperature is 25.5°C
        Temperature above threshold: 26.5°C
        Temperature is 26.5°C