alphanumeric
Posts: 1538
Joined: Tue Jan 19, 2016 2:17 pm
Location: Sydney, Nova Scotia, Canada

Sense Hat % Humididty reads erroneously high?

Mon Aug 13, 2018 1:09 pm

I have two Sense Hats here that read too high a value for the % Humidity. Environment Canada lists it at 75%. My on the wall mechanical meter reads 70%. My BME680 reads it at 63%. My sense hat reads it at 86%. Swapped Sense Hats and it reads 88%. The higher the humidity is the bigger the error is. They quit often read above 100% when the actual humidity is around 80% to 90%.
Just redid my SD Card with the latest Raspbian and same deal. They read on the high side of what the actual humidity is. Any suggestions?
Is there a newer firmware for the sense hat, and can they be flashed?

Code: Select all

import os
import time, datetime
from sense_hat import SenseHat, ACTION_PRESSED, ACTION_HELD, ACTION_RELEASED
        
sense = SenseHat()
sense.set_rotation(180)
sense.set_imu_config(False, False, False)
sense.low_light = True

s=(0.065) # scroll speed
w=(0) # color all white toggle
o=(140)
x=(2) #shutdown variable

# is really stick down
def pushed_up(event):
    if event.action == ACTION_PRESSED:
       sense.low_light = True
        
# is really stick up
def pushed_down(event):
    if event.action == ACTION_PRESSED:
       sense.low_light = False

#is really stick right
def pushed_left(event):
    global w
    global o
    if event.action == ACTION_PRESSED:
        w = (255)
        o = (255)
        
# is really stick left
def pushed_right(event):
    global w
    global o
    if event.action == ACTION_PRESSED:
        w = (0)
        o = (140)
        
def pushed_middle(event):
    global x
    if event.action == ACTION_PRESSED:
        x = (0)

sense.stick.direction_up = pushed_up
sense.stick.direction_down = pushed_down
sense.stick.direction_left = pushed_left
sense.stick.direction_right = pushed_right
sense.stick.direction_middle = pushed_middle

while True:

    dateString = "%A %B %-d %-I:%M:%p"
    msg = "It is %s" % (datetime.datetime.now().strftime(dateString))
    sense.show_message(msg, scroll_speed=s, text_colour=(w, 255, 255))

    t = sense.get_temperature()
    t = round(t)
          
    if t <= 0: 
        tc = [w, w, 255]  # Blue
    elif t > 0 and t < 13:
        tc = [255, 255, w]  # Yellow
    elif t >= 13 and t <= 25:
        tc = [w, 255, w]  # Green
    elif t > 25 and t <30:
        tc = [255, o, w]   # Orange
    elif t >= 30:
        tc = [255, w, w]   # Red   

    msg = "and %sc" % (t)
    sense.show_message(msg, scroll_speed=s, text_colour=tc)

    h = sense.get_humidity()
    h = round(h)

    if h < 0:
        h = 0

    if h > 100:
        h = 100

    if h < 30:
        hc = [255, w, w]  # Red
    elif h >= 30 and h <= 60:
        hc = [w, 255, w]  # Green
    elif h > 60 and h < 80:
        hc = [255, 255, w]  # Yellow
    elif h >= 80:
        hc = [255, w, w]  # Red

    msg = "with %s%% Humidity" % (h)
    sense.show_message(msg, scroll_speed=s, text_colour=hc)

    p = sense.get_pressure()
    p = round(p)
        
    if p > 0 and p < 982:
        pc = [255, w, w]  # Red
        msg = "- Barometer is Very Low @ %smb - Storm Watch" % (p)
        sense.show_message(msg, scroll_speed=s, text_colour=pc)
    elif p >= 982 and p < 1004:
        pc = [255, 255, w]  # Yellow
        msg = "- Barometer is Low @ %smb - Possible Percipitation" % (p)
        sense.show_message(msg, scroll_speed=s, text_colour=pc)
    elif p >= 1004 and p < 1026:
        pc = [w, 255, w]  # Green
        msg = "- Barometer is Mid Range @ %smb" % (p)
        sense.show_message(msg, scroll_speed=s, text_colour=pc)
    elif p >= 1026 and p < 1048:
        pc = [w, w, 255]  # Blue
        msg = "- Barometer is High @ %smb" % (p)
        sense.show_message(msg, scroll_speed=s, text_colour=pc)
    elif p >= 1048:
        pc = [255, w, w]  # Red
        msg = "- Barometer is Very High @ %smb - Expect Dry Conditions" % (p) 
        sense.show_message(msg, scroll_speed=s, text_colour=pc)
        
    if x == 0:
        sense.clear()
        os.system("sudo shutdown now -P")
        time.sleep(30)
    elif x == 1:
        sense.clear()
        raise SystemExit
        time.sleep(30)

# Last edited on Aug 10th 2018
# run sudo crontab -e
# add
# @reboot python3 /home/pi/THP.py &





alphanumeric
Posts: 1538
Joined: Tue Jan 19, 2016 2:17 pm
Location: Sydney, Nova Scotia, Canada

Re: Sense Hat % Humididty reads erroneously high?

Fri Sep 14, 2018 9:11 pm

Fixed by adding a BME680 breakout and getting my data from it. LED matrix is all I'm using on the Sense Hat now to display my readings. :(

alphanumeric
Posts: 1538
Joined: Tue Jan 19, 2016 2:17 pm
Location: Sydney, Nova Scotia, Canada

Re: Sense Hat % Humididty reads erroneously high?

Mon Sep 17, 2018 3:46 pm

Can that sensor be contaminated by residue buildup / condensation etc? Would cleaning / applying isopropyl alcohol damage it?

Return to “Astro Pi”