Skip to content

Commit a6f02f7

Browse files
kking-1601John Hutcherson
authored andcommitted
Added AS6212 Temperature Alert Interrupt Sample
Signed-off-by: John Hutcherson <[email protected]>
1 parent df4c89c commit a6f02f7

File tree

6 files changed

+457
-0
lines changed

6 files changed

+457
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright (c) 2022 T-Mobile USA, Inc.
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
cmake_minimum_required(VERSION 3.20.0)
6+
7+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
8+
project(tmp108)
9+
10+
target_sources(app PRIVATE src/main.c)

samples/as6212_sample/Kconfig

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#
2+
# Copyright (c) 2021 Jimmy Johnson <[email protected]>
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
7+
mainmenu "TMP108 sample application"
8+
9+
config APP_REPORT_TEMP_ALERTS
10+
bool "Report over and under temperature alerts"
11+
default n
12+
13+
config APP_ENABLE_ONE_SHOT
14+
bool "One shot low power mode"
15+
default n
16+
help
17+
One shot requires a callback to be invoked after the tmp108 has
18+
woken up and taken a temperature reading, calling sample_fetch
19+
starts this process. Set this to enable 1 shot mode example.
20+
21+
config APP_TEMP_ALERT_HIGH_THRESH
22+
int "RH [%] high threshold for alert trigger in celsius"
23+
range 0 50
24+
default 26
25+
help
26+
Set this to enable alerts for high temperatures
27+
although this will work with one shot enabled,
28+
it requires continuous monitoring mode to be enabled
29+
to work in real time.
30+
See spec sheet for more details.
31+
32+
config APP_TEMP_ALERT_LOW_THRESH
33+
int "RH [%] low threshold for alert trigger in celsius"
34+
range 0 50
35+
default 18
36+
help
37+
Set this to enable alerts for low temperatures
38+
although this will work with one shot enabled,
39+
it requires continuous monitoring mode to be enabled
40+
to work in real time.
41+
See spec sheet for more details.
42+
43+
source "Kconfig.zephyr"

samples/as6212_sample/README.rst

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
Title: as6212_sample
2+
3+
Description:
4+
5+
An AS6212 Digital Temperature Alert sensor sample to demonstrate the
6+
capabilities of the T-Mobile DevEdge dev kit.
7+
8+
Overview:
9+
10+
This sample is provided as an example to demonstrate the high accuracy AS6212
11+
Digital Temperature sensor with Alert functionality. The sample uses the
12+
AS6212's temperature high/low alerting mechanism to generate interrupts that
13+
awaken threads, which report the temperature data to the console and
14+
subsequently enter EM2 sleep mode.
15+
16+
The alert-sourced interrupts, demonstrate the AS6212's temperature High and Low
17+
threshold alerting capability.
18+
19+
- AS6212 Digital Temperature with Alert functionality.
20+
21+
--------------------------------------------------------------------------------
22+
23+
Requirements
24+
************
25+
26+
-A T-Mobile DevEdge dev kit (https://devedge.t-mobile.com/)
27+
-A Zephyr build environment (https://docs.zephyrproject.org/latest/develop/getting_started/index.html)
28+
29+
Building and Running Project:
30+
31+
How this project can be built:
32+
33+
-Checkout the T-Mobile downstream zephyr repo:
34+
cd ~/zephyrproject
35+
git clone https://github.com/tmobile/DevEdge-IoTDevKit-ZephyrRTOS zephyr
36+
37+
-Checkout the T-Mobile zephyr-tmo-sdk repo:
38+
cd ~/zephyrproject
39+
git clone https://github.com/tmobile/DevEdge-IoTDevKit-ZephyrSDK tmo-zephyr-sdk
40+
41+
-Run 'west update'
42+
cd ~/zephyrproject
43+
west update
44+
45+
-Build this sample:
46+
cd ~/zephyrproject
47+
west build ~/zephyrproject/DevEdge-IoTDevKit-ZephyrSDK/samples/as6212_sample -p -b tmo_dev_edge
48+
(substitute your home folder for '<home folder>' in the command above)
49+
50+
-Connect DevEdge dev kit:
51+
Connect the USB-C port furthest from the pushbutton to your computer. (The
52+
other USB-C port can be connected; however, it's not used for this sample.)
53+
54+
-Flash as6212_sample
55+
cd ~/zephyrproject
56+
west flash
57+
58+
Sample Output
59+
=============
60+
61+
.. code-block:: console
62+
*** Booting Zephyr OS build 4d07b602dd77 ***
63+
64+
Welcome to T-Mobile DevEdge!
65+
66+
This application aims to demonstrate the Gecko's Energy Mode 2 (EM2) (Deep Sleep
67+
Mode) and Wake capabilities in conjunction with the temperature interrupt
68+
of DevEdge's (tmo_dev_edge) AMS OSRAM AS6212 Digital Temperature Sensor.
69+
70+
Set SENSOR_ATTR_UPPER_THRESH (44)
71+
Set SENSOR_ATTR_LOWER_THRESH (38)
72+
73+
Set temperature_alert
74+
75+
Call enable_temp_alerts
76+
get_temperature(): temperature is 29.2656C
77+
78+
as6212_thread1(): running
79+
get_temperature(): temperature is 29.2656C
80+
81+
as6212_thread2(): running
82+
get_temperature(): temperature is 29.2656C
83+
84+
85+
Awaiting the AS6212 temperature threshold-high/threshold-low (interrupt) alerts.
86+
87+
While observing the console output, use a hair dryer (or similar forced air
88+
heat source) to momentarily raise the temperature of DevEdge board, triggering
89+
the AS6212 temperature-high alert. Remove the heat source and wait for the
90+
AS6212 temperature-low alert.
91+
92+
93+
as6212_intr_callback(): Received AS6212 Temperature Sensor ALERT Interrupt (1)
94+
as6212_thread1(): running
95+
get_temperature(): temperature is 44.0312C
96+
97+
as6212_thread2(): running
98+
get_temperature(): temperature is 44.0312C
99+
100+
101+
as6212_intr_callback(): Received AS6212 Temperature Sensor ALERT Interrupt (2)
102+
as6212_thread1(): running
103+
get_temperature(): temperature is 37.9766C
104+
105+
as6212_thread2(): running
106+
get_temperature(): temperature is 37.9766C
107+

samples/as6212_sample/prj.conf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CONFIG_SENSOR=y
2+
CONFIG_STDOUT_CONSOLE=y
3+
CONFIG_CBPRINTF_FP_SUPPORT=y
4+
CONFIG_I2C=y
5+
CONFIG_TMP108=y
6+
CONFIG_ASSERT=y
7+
CONFIG_TMP108_ALERT_INTERRUPTS=y
8+
#Power Managment
9+
CONFIG_PM=y
10+
CONFIG_PM_DEVICE=y
11+
CONFIG_APP_REPORT_TEMP_ALERTS=y

samples/as6212_sample/sample.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
sample:
2+
name: TMP 108 Temperature Sensor Sample
3+
tests:
4+
sample.sensor.tmp108:
5+
harness: console
6+
tags: sensors
7+
depends_on: i2c gpio
8+
filter: dt_compat_enabled("ti,tmp108")
9+
harness_config:
10+
type: multi_line
11+
regex:
12+
- "temperature is *.*C"

0 commit comments

Comments
 (0)