Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. #Importing modules
  2. from sense_emu import SenseHat
  3. import json, os, time
  4. ###################################################
  5. # Grabbing temperature range from config.json
  6. ###################################################
  7. class TempRanges:
  8. def __init__(self):
  9. self.__dict__ = json.load(open("config.json", "r"))
  10.  
  11. def mainfunc(self):
  12. tempranges = []
  13. for tempkey, tempvalue in self.__dict__.items():
  14. tempranges.append(tempvalue)
  15. return tempranges
  16. tempRanges = TempRanges()
  17. #print (tempRanges.mainfunc()[3])
  18.  
  19. ###################################################
  20.  
  21. class getAccurateTemp:
  22. def __init__(self):
  23. self.temp_hum = SenseHat().get_temperature_from_humidity()
  24. self.temp_pre = SenseHat().get_temperature_from_pressure()
  25.  
  26. def get_cpu_temp(self):
  27. res = os.popen("vcgencmd measure_temp").readline()
  28. return float(res.replace("temp=","").replace("'C\n",""))
  29.  
  30. def calc_temp(self):
  31. temp_cpu = self.get_cpu_temp()
  32. temp_incorr = (self.temp_hum + self.temp_pre) / 2
  33. temp_corr = temp_incorr - ((temp_cpu - temp_incorr) / 1.3)
  34. print(self.temp_hum)
  35.  
  36. accurateTemp = getAccurateTemp()
  37. accurateTemp.calc_temp()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement