Skip to content

Commit fbd6416

Browse files
authored
Merge pull request #2081 from kattni/lc709-update
Update where temp is called.
2 parents 88921d7 + 82c31f2 commit fbd6416

File tree

1 file changed

+6
-8
lines changed
  • CircuitPython_Templates/adafruit_io_cpu_temp_neopixel_color

1 file changed

+6
-8
lines changed

CircuitPython_Templates/adafruit_io_cpu_temp_neopixel_color/code.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
print("WiFi and Adafruit IO credentials are kept in secrets.py - please add them there!")
1818
raise
1919

20-
# Set your Adafruit IO Username and Key in secrets.py
20+
# Add your Adafruit IO Username and Key to secrets.py
2121
# (visit io.adafruit.com if you need to create an account,
2222
# or if you need your Adafruit IO key.)
2323
aio_username = secrets["aio_username"]
@@ -70,16 +70,14 @@ def message(client, feed_id, payload):
7070
print("Connecting to Adafruit IO...")
7171
io.connect()
7272

73-
last = 0
73+
timestamp = 0
7474
while True:
7575
# Explicitly pump the message loop.
7676
io.loop()
7777

78-
# Obtain the CPU temperature.
79-
temperature = "{:.2f}".format(microcontroller.cpu.temperature)
80-
81-
# Print and publish the CPU temperature every 10 seconds.
82-
if (time.monotonic() - last) >= 10:
78+
# Obtain the CPU temperature, print it and publish it to Adafruit IO every 10 seconds.
79+
if (time.monotonic() - timestamp) >= 10:
80+
temperature = "{:.2f}".format(microcontroller.cpu.temperature)
8381
print("Current CPU temperature: {0} C".format(temperature))
8482
io.publish("cpu-temperature", temperature)
85-
last = time.monotonic()
83+
timestamp = time.monotonic()

0 commit comments

Comments
 (0)