Skip to content

Instantly share code, notes, and snippets.

@norbekaiser
Created March 7, 2016 08:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save norbekaiser/14ee657590245631d8a6 to your computer and use it in GitHub Desktop.
Save norbekaiser/14ee657590245631d8a6 to your computer and use it in GitHub Desktop.
Temperature Results of Sense hat, with correction via cpu temperature ( not very accurate)
norbert@raspberrypi:~ $ ./temp.py
Temperature(h): 22.962310791 C
Temperature(p): 0 C
Temperature(c): 30.4 C
Temperature: -7.43768920898
norbert@raspberrypi:~ $ ./temp.py
Temperature(h): 22.9989624023 C
Temperature(p): 22.9895839691 C
Temperature(c): 29.9 C
Temperature: 16.0885463715
norbert@raspberrypi:~ $
#!/usr/bin/env python
from sense_hat import SenseHat
import os
sense = SenseHat()
sense.clear()
#temp = sense.get_temperature()
#print("Temperature: %s C" % temp)
temph = sense.get_temperature_from_humidity()
print("Temperature(h): %s C" % temph)
tempp = sense.get_temperature_from_pressure()
print("Temperature(p): %s C" % tempp)
tempt = os.popen('/opt/vc/bin/vcgencmd measure_temp')
tempc = tempt.read()
tempc = tempc.replace('temp=','')
tempc = tempc.replace('\'C\n','')
tempc = float(tempc)
print("Temperature(c): %s C" % tempc)
temp = (tempp + temph) / 2.0
temp = temp - (tempc - temp)
msg = "%s" % int(round(temp))
print("Temperature: %s" % temp)
sense.show_message(msg)
@norbekaiser
Copy link
Author

Using the sense hat for temperature aquirisation , it is kinda impossible to get proper values from the temperature sensor
An Offset error is assumed, using the cpu heat ( without air transfer calculus) difference as an offset error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment