imcdonald
Posts: 1
Joined: Thu Jan 12, 2017 8:22 pm

Humidity sensor on new sense hat s is returning odd values

Thu Jan 12, 2017 11:32 pm

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.

rghsony9
Posts: 1
Joined: Sat Feb 16, 2019 4:40 pm

Re: Humidity sensor on new sense hat s is returning odd values

Sat Feb 16, 2019 5:30 pm

I recently ran across this question while doing my own experimenting with sense hat. I have seen quite a few discussions on temp readings on sense hat that point out that the cpu increases the sense hat temp readings. In fact this impacts the humidity readings as well. Humidity as reported by sense hat is relative humidity(RH). RH is a measure of how much water (Kg/m^3) the air contains as a fraction of the max water it could contain at that air temperature. Hotter air can contain more water so if the temperature reading is high the RH is low for the same amount of water actually contained in the air. Just like you have to calibrate the temperature reading from the sense hat to correct for the heat being put in the vicinity of the sense hat by the cpu to get the air temp in the surrounds, the same needs to be done for the humidity readings. At 40 C a 3% RH amounts to .002 Kg/m^3 water density, if the calibrated temp of the sensor was 20 C the same water density would result in a RH of about 12%. I have written a python script to both calibrate the temp reading from the sense hat (this calibration will depend on the specifics of the distance from between the sense hat sensor and the cpu as well as the thermo dynamic environment of the case - calibration is easy for a particular case but it will not be the same for different distances and cases), and to calculate the absolute humidity (Kg/m^3) and use the absolute humidity and calibrated temp to calculate the RH at the calibrated temp. If this is still an issue for anyone, I can provide the details of the both temp calibration and RH correction.

o.oldaq
Posts: 1
Joined: Fri Apr 17, 2020 6:52 pm

Re: Humidity sensor on new sense hat s is returning odd values

Fri Apr 17, 2020 6:58 pm

Do you still have the script to correct the humidity % levels?

Return to “Python”