Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Importing modules
- from sense_emu import SenseHat
- import json, os, time
- ###################################################
- # Grabbing temperature range from config.json
- ###################################################
- class TempRanges:
- def __init__(self):
- self.__dict__ = json.load(open("config.json", "r"))
- def mainfunc(self):
- tempranges = []
- for tempkey, tempvalue in self.__dict__.items():
- tempranges.append(tempvalue)
- return tempranges
- tempRanges = TempRanges()
- #print (tempRanges.mainfunc()[3])
- ###################################################
- class getAccurateTemp:
- def __init__(self):
- self.temp_hum = SenseHat().get_temperature_from_humidity()
- self.temp_pre = SenseHat().get_temperature_from_pressure()
- def get_cpu_temp(self):
- res = os.popen("vcgencmd measure_temp").readline()
- return float(res.replace("temp=","").replace("'C\n",""))
- def calc_temp(self):
- temp_cpu = self.get_cpu_temp()
- temp_incorr = (self.temp_hum + self.temp_pre) / 2
- temp_corr = temp_incorr - ((temp_cpu - temp_incorr) / 1.3)
- print(self.temp_hum)
- accurateTemp = getAccurateTemp()
- accurateTemp.calc_temp()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement