Skip to content

Commit a6f1936

Browse files
committed
rate and averaging test example
1 parent e47c8bd commit a6f1936

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

adafruit_tmp117.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
__version__ = "0.0.0+auto.0"
5757
__repo__ = "https:#github.com/adafruit/Adafruit_CircuitPython_TMP117.git"
5858

59-
6059
_I2C_ADDR = 0x48 # default I2C Address
6160
_TEMP_RESULT = const(0x00)
6261
_CONFIGURATION = const(0x01)
@@ -98,7 +97,6 @@
9897
MEASUREMENTMODE_ONE_SHOT = const(0b11)
9998
MEASUREMENTMODE_SHUTDOWN = const(0b01)
10099

101-
102100
AlertStatus = namedtuple("AlertStatus", ["high_alert", "low_alert"])
103101

104102

examples/tmp117_rate_and_averaging_test.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# SPDX-FileCopyrightText: 2020 Bryan Siepert, written for Adafruit Industries
2+
# SPDX-FileCopyrightText: 2023 Jose David Montoya
23
#
34
# SPDX-License-Identifier: Unlicense
45
# pylint:disable=no-member
@@ -13,6 +14,20 @@
1314
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
1415
tmp117 = adafruit_tmp117.TMP117(i2c)
1516

17+
18+
# Values here for the average_measurements and measurement_delay
19+
Delay_times = {
20+
0: "DELAY_0_0015_S",
21+
1: "DELAY_0_125_S",
22+
2: "DELAY_0_250_S",
23+
3: "DELAY_0_500_S",
24+
4: "DELAY_1_S",
25+
5: "DELAY_4_S",
26+
6: "DELAY_8_S",
27+
7: "DELAY_16_S",
28+
}
29+
Average_Measure = {1: "AVERAGE_1X", 2: "AVERAGE_8X", 3: "AVERAGE_32X", 4: "AVERAGE_64X"}
30+
1631
# uncomment different options below to see how it affects the reported temperature
1732
# tmp117.averaged_measurements = adafruit_tmp117.AVERAGE_1X
1833
# tmp117.averaged_measurements = adafruit_tmp117.AVERAGE_8X
@@ -30,9 +45,9 @@
3045

3146
print(
3247
"Number of averaged samples per measurement:",
33-
tmp117.averaged_measurements,
48+
Average_Measure[tmp117.averaged_measurements],
3449
)
35-
print("Minimum time between measurements:", tmp117.measurement_delay)
50+
print("Minimum time between measurements:", Delay_times[tmp117.measurement_delay])
3651
print("")
3752

3853
while True:

0 commit comments

Comments
 (0)