Hello,
I think that the Humidity sensor on my sensehat is broken, I have it installed on a Raspberry pi 3 Model B.
I wrote the following python script:
from sense_hat import SenseHat
sense = SenseHat()
while True:
t = sense.get_temperature()
th = sense.get_temperature_from_humidity()
tp = sense.get_temperature_from_pressure()
p = sense.get_pressure()
h = sense.get_humidity()
t = round(t, 1)
th = round(th, 1)
tp = round(tp, 1)
p = round(p, 1)
h = round(h, 1)
msg = "Temp = {0} C, Temp From humidity {1} C, Temp From pressure {2} C, Pressure = {3}, Humidity = {4}".format(t, th, tp, p, h)
print(msg)
and when I use the follow APIs I get back strange values (see below):
sense.get_temperature() # I read that sense.get_temperature() is just a wrapper for sense.get_temperature_from_humidity()
sense.get_temperature_from_humidity()
sense.get_humidity()
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Thu Jan 12 18:02:25 2017
SSH is enabled and the default password for the 'pi' user has not been changed.
This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.
pi@home:~ $ date
Thu 12 Jan 18:04:39 EST 2017
pi@home:~ $ sudo rpi-update
*** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
*** Performing self-update
*** Relaunching after update
*** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
*** Your firmware is already up to date
pi@home:~ $ sudo apt-get update
Hit http://mirrordirector.raspbian.org jessie InRelease
Hit http://archive.raspberrypi.org jessie InRelease
Hit http://mirrordirector.raspbian.org jessie/main armhf Packages
Hit http://archive.raspberrypi.org jessie/main armhf Packages
Hit http://mirrordirector.raspbian.org jessie/contrib armhf Packages
Hit http://mirrordirector.raspbian.org jessie/non-free armhf Packages
Hit http://archive.raspberrypi.org jessie/ui armhf Packages
Hit http://mirrordirector.raspbian.org jessie/rpi armhf Packages
Ign http://archive.raspberrypi.org jessie/main Translation-en_GB
Ign http://mirrordirector.raspbian.org jessie/contrib Translation-en_GB
Ign http://mirrordirector.raspbian.org jessie/contrib Translation-en
Ign http://archive.raspberrypi.org jessie/main Translation-en
Ign http://mirrordirector.raspbian.org jessie/main Translation-en_GB
Ign http://mirrordirector.raspbian.org jessie/main Translation-en
Ign http://archive.raspberrypi.org jessie/ui Translation-en_GB
Ign http://mirrordirector.raspbian.org jessie/non-free Translation-en_GB
Ign http://mirrordirector.raspbian.org jessie/non-free Translation-en
Ign http://archive.raspberrypi.org jessie/ui Translation-en
Ign http://mirrordirector.raspbian.org jessie/rpi Translation-en_GB
Ign http://mirrordirector.raspbian.org jessie/rpi Translation-en
Reading package lists... Done
pi@home:~ $ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
pi@home:~ $ sudo apt-get dist-upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
pi@home:~ $ uname -a
Linux home 4.4.41-v7+ #942 SMP Mon Jan 9 15:00:25 GMT 2017 armv7l GNU/Linux
pi@home:~ $
pi@home:~ $ cat test.py
from sense_hat import SenseHat
sense = SenseHat()
while True:
t = sense.get_temperature()
th = sense.get_temperature_from_humidity()
tp = sense.get_temperature_from_pressure()
p = sense.get_pressure()
h = sense.get_humidity()
t = round(t, 1)
th = round(th, 1)
tp = round(tp, 1)
p = round(p, 1)
h = round(h, 1)
msg = "Temp = {0} C, Temp From humidity {1} C, Temp From pressure {2} C, Pressure = {3}, Humidity = {4}".format(t, th, tp, p, h)
print(msg)
pi@home:~ $
pi@home:~ $ python test.py
Temp = -148.3 C, Temp From humidity -148.3 C, Temp From pressure 40.3 C, Pressure = 1006.0, Humidity = 3.5
Temp = -148.3 C, Temp From humidity -148.3 C, Temp From pressure 38.2 C, Pressure = 1006.0, Humidity = 3.5
Temp = -148.3 C, Temp From humidity -148.3 C, Temp From pressure 38.2 C, Pressure = 1006.0, Humidity = 3.5
Temp = -148.3 C, Temp From humidity -148.3 C, Temp From pressure 38.2 C, Pressure = 1006.0, Humidity = 3.5
Temp = -148.3 C, Temp From humidity -148.3 C, Temp From pressure 38.2 C, Pressure = 1006.0, Humidity = 3.5
Temp = -148.3 C, Temp From humidity -148.3 C, Temp From pressure 38.2 C, Pressure = 1006.0, Humidity = 3.5
Temp = -148.3 C, Temp From humidity -148.3 C, Temp From pressure 38.2 C, Pressure = 1006.0, Humidity = 3.5
Temp = -148.3 C, Temp From humidity -148.3 C, Temp From pressure 38.2 C, Pressure = 1006.0, Humidity = 3.6
Temp = -148.3 C, Temp From humidity -148.3 C, Temp From pressure 38.2 C, Pressure = 1006.0, Humidity = 3.6
Temp = -148.3 C, Temp From humidity -148.3 C, Temp From pressure 38.2 C, Pressure = 1006.0, Humidity = 3.6
Temp = -148.3 C, Temp From humidity -148.3 C, Temp From pressure 38.2 C, Pressure = 1006.0, Humidity = 3.6
Temp = -148.3 C, Temp From humidity -148.3 C, Temp From pressure 38.2 C, Pressure = 1006.0, Humidity = 3.6
Temp = -148.3 C, Temp From humidity -148.3 C, Temp From pressure 38.2 C, Pressure = 1006.0, Humidity = 3.6
Temp = -148.3 C, Temp From humidity -148.3 C, Temp From pressure 38.2 C, Pressure = 1006.0, Humidity = 3.6
Temp = -148.3 C, Temp From humidity -148.3 C, Temp From pressure 38.2 C, Pressure = 1006.0, Humidity = 3.6
^CTraceback (most recent call last):
File "test.py", line 6, in <module>
th = sense.get_temperature_from_humidity()
File "/usr/lib/python2.7/dist-packages/sense_hat/sense_hat.py", line 584, in get_temperature_from_humidity
data = self._humidity.humidityRead()
KeyboardInterrupt
pi@home:~ $
The temp from the pressure sensor seems to be accurate and so does the pressure value. I have also tested the led array and that appears to work as expected.