• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

boards/03-Apr-2024-5850

src/03-Apr-2024-158127

CMakeLists.txtD03-Apr-2024224 96

README.rstD03-Apr-20242.1 KiB7457

prj.confD03-Apr-2024203 96

sample.yamlD03-Apr-2024267 1211

README.rst

1.. _mcp9808-sample:
2
3MCP9808 Temperature Sensor
4##########################
5
6Overview
7********
8
9This sample application periodically (0.5 Hz) measures the ambient
10temperature. The result is written to the console.
11
12If triggered measurements are enabled the sample initializes and
13maintains a |plusminus| 2 |deg| C window around the current temperature.
14When the temperature moves outside the window an alert is given, and the
15window is moved to center on the new temperature.
16
17Requirements
18************
19
20The MCP9808 digital temperature sensor converts temperatures between -20 |deg|
21C and +100 |deg| C to a digital word with |plusminus| 0.5 |deg| C (max.)
22accuracy. It is I2C compatible and supports up to 16 devices on the bus.
23
24Wiring
25*******
26
27The MCP9808 is available in a discrete component form but it is much easier to
28use it mounted on a breakout board.  We used the Adafruit `MCP9808
29Sensor`_ breakout board.
30
31.. _`MCP9808 Sensor`: https://www.adafruit.com/product/1782
32
33Building and Running
34********************
35
36After providing a devicetree overlay that specifies the sensor I2C bus
37and alert GPIO, build this sample app using:
38
39.. zephyr-app-commands::
40   :zephyr-app: samples/sensor/mcp9808
41   :board: particle_xenon
42   :goals: build flash
43
44Sample Output
45=============
46
47Note that in the capture below output from the trigger callback and the
48main thread are interleaved.
49
50.. code-block:: console
51
52   *** Booting Zephyr OS build zephyr-v2.1.0-537-gbbdeaa1ae5bb  ***
53   Alert on temp outside [24500, 25500] milli-Celsius
54   Trtrigger fired 1, temp 15.9375 C
55   iggAlert on temp outside [15437, 16437] milli-Celsius
56   er set got 0
57   0:00:00.017: 15.9375 C
58   0:00:02.020: 16 C
59   0:00:04.022: 16.125 C
60   0:00:06.024: 16.1875 C
61   trigger fired 2, temp 16.3125 C
62   Alert on temp outside [15812, 16812] milli-Celsius
63   0:00:08.027: 16.3125 C
64   0:00:10.029: 16.375 C
65   0:00:12.032: 16.5 C
66   0:00:14.034: 16.5625 C
67   0:00:16.037: 16.5625 C
68   0:00:18.039: 16.625 C
69   0:00:20.042: 16.6875 C
70   trigger fired 3, temp 16.8125 C
71   Alert on temp outside [16312, 17312] milli-Celsius
72   0:00:22.044: 16.8125 C
73   0:00:24.047: 16.875 C
74