Skip to content

Instantly share code, notes, and snippets.

@MrDMurray
Created February 10, 2022 09:33
Show Gist options
  • Save MrDMurray/77233b2d461b4b4513ddd7a9c6f9c7b9 to your computer and use it in GitHub Desktop.
Save MrDMurray/77233b2d461b4b4513ddd7a9c6f9c7b9 to your computer and use it in GitHub Desktop.
"""
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