Created
February 10, 2022 09:33
-
-
Save MrDMurray/77233b2d461b4b4513ddd7a9c6f9c7b9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
from sense_hat import SenseHat github.com/STJRush | |
sense = SenseHat() | |
sense.clear() | |
temp = sense.get_temperature() | |
print(temp) | |
""" | |
############################################################# | |
from statistics import mean | |
import random | |
#sim temp, not you! | |
temp =random.randint(19,22) | |
listylist = [] | |
for x in range(5): | |
temp =random.randint(19,22) | |
temp=round(temp,2) | |
listylist.append(temp) | |
# GET MEAN | |
####################################################### | |
print(listylist) | |
print("The average is ", mean(listylist)) | |
averageTemp = mean(listylist) | |
# UPLOAD TO THINGSPEAK | |
######################################################### | |
import sys | |
from urllib.request import urlopen | |
f = urlopen("https://api.thingspeak.com/update?api_key=DA1K0TYF36CAE516&field1="+str(averageTemp)) | |
print(f.read()) # checks what it wrote | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment