Skip to content

Commit 0683c27

Browse files
committed
Switch to randint() for data sending value.
1 parent 48e6d3b commit 0683c27

File tree

1 file changed

+6
-6
lines changed
  • CircuitPython_Templates/adafruit_io_cpu_temp_neopixel_color

1 file changed

+6
-6
lines changed

CircuitPython_Templates/adafruit_io_cpu_temp_neopixel_color/code.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
# SPDX-License-Identifier: MIT
44
import time
55
import ssl
6+
from random import randint
67
import socketpool
78
import wifi
89
import board
910
import neopixel
10-
import microcontroller
1111
import adafruit_minimqtt.adafruit_minimqtt as MQTT
1212
from adafruit_io.adafruit_io import IO_MQTT
1313

@@ -28,7 +28,7 @@
2828
wifi.radio.connect(secrets["ssid"], secrets["password"])
2929
print("Connected to %s!" % secrets["ssid"])
3030

31-
# Initialize NeoPixel
31+
# Initialise NeoPixel
3232
pixel = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.3)
3333

3434

@@ -75,9 +75,9 @@ def message(client, feed_id, payload):
7575
# Explicitly pump the message loop.
7676
io.loop()
7777

78-
# Obtain the CPU temperature, print it and publish it to Adafruit IO every 10 seconds.
78+
# Obtain the "random" value, print it and publish it to Adafruit IO every 10 seconds.
7979
if (time.monotonic() - timestamp) >= 10:
80-
temperature = "{:.2f}".format(microcontroller.cpu.temperature)
81-
print("Current CPU temperature: {0} C".format(temperature))
82-
io.publish("cpu-temperature", temperature)
80+
random_number = "{}".format(randint(0, 255))
81+
print("Current 'random' number: {}".format(random_number))
82+
io.publish("random", random_number)
8383
timestamp = time.monotonic()

0 commit comments

Comments
 (0)