OpenMarine
HTU21D humidity value - Printable Version

+- OpenMarine (https://forum.openmarine.net)
+-- Forum: OpenPlotter (https://forum.openmarine.net/forumdisplay.php?fid=1)
+--- Forum: How do I...? (https://forum.openmarine.net/forumdisplay.php?fid=3)
+--- Thread: HTU21D humidity value (/showthread.php?tid=11)



HTU21D humidity value - Swokey - 2016-03-22

I still have a lot of fun with openplotter. Now I'm using it for a new project (creating mine own drying place for meat).  I allready have tried a lot, but I don't have a solution yet. So if anyone can help me it would be great.

The action/triggers are not a solution because I need to combine several input before I do an action.


I need the output of the humidity from the HTU21D. When I use it with openplotter I see the NMEA sentence with the correct value. So I extracted the code from the i2c.py file with that what I think need.

Why don't get I the humidity?

--------------------------------

import socket, time, pynmea2, RTIMU, math, csv

SETTINGS_FILE3 = "RTIMULib3"
s3 = RTIMU.Settings(SETTINGS_FILE3)
humidity_val = RTIMU.RTHumidity(s3)
humidity_val.humidityInit()
humidity_val_b = True

humidity=''

humidity=read[1]

hum=round(humidity,1)

print hum

humidity=''


-------------------------------

Kind regards


RE: HTU21D humidity value - Sailoog - 2016-03-22

Please, I need to see that meat dryer when is done Huh

Your code should look like this:


Code:
import RTIMU, time

SETTINGS_FILE3 = "RTIMULib3"
s3 = RTIMU.Settings(SETTINGS_FILE3)
humidity_val = RTIMU.RTHumidity(s3)
humidity_val.humidityInit()

humidity=''
temperature_h=''

#here starts the bucle
while True:
    time.sleep(1)#here you can define the frequency in seconds
    read=humidity_val.humidityRead()
    if read:
        if (read[0]):
            humidity=read[1]
        if (read[2]):
            temperature_h=read[3]

   print humidity
   print temperature_h

Not tested but it should work, let me know if you get some error.
And please when you are done please publish something in Brag Board subforum.

Should I add Meat Dryer as OpenPlotter feature? Tongue


RE: HTU21D humidity value - Swokey - 2016-03-22

(2016-03-22, 06:35 PM)Sailoog Wrote: Please, I need to see that meat dryer when is done Huh

Your code should look like this:


Code:
import RTIMU, time

SETTINGS_FILE3 = "RTIMULib3"
s3 = RTIMU.Settings(SETTINGS_FILE3)
humidity_val = RTIMU.RTHumidity(s3)
humidity_val.humidityInit()

humidity=''
temperature_h=''

#here starts the bucle
while True:
    time.sleep(1)#here you can define the frequency in seconds
    read=humidity_val.humidityRead()
    if read:
        if (read[0]):
            humidity=read[1]
        if (read[2]):
            temperature_h=read[3]

   print humidity
   print temperature_h

Not tested but it should work, let me know if you get some error.
And please when you are done please publish something in Brag Board subforum.

Should I add Meat Dryer as OpenPlotter feature? Tongue

Thanks a lot. Change the code a bit to:


Code:
import RTIMU, time

SETTINGS_FILE3 = "RTIMULib3"
s3 = RTIMU.Settings(SETTINGS_FILE3)
humidity_val = RTIMU.RTHumidity(s3)
humidity_val.humidityInit()

humidity=''
temperature_h=''

#here starts the bucle
while True:
   time.sleep(0.5)#here you can define the frequency in seconds
   read=humidity_val.humidityRead()
   if read:
       if (read[0]):
           humidity=read[1]
           print humidity

But the strange thing is that every 4th value is a strange value:

46.4964027405
46.4964027405
46.4964027405
2.17024011051e+33
46.4582557678
46.4582557678
46.4582557678
2.17024011051e+33
46.4277381897
46.4277381897
46.4277381897
2.17024011051e+33
46.4369735718
46.4369735718


RE: HTU21D humidity value - Vamonos - 2016-03-23

(2016-03-22, 09:42 PM)Swokey Wrote:
(2016-03-22, 06:35 PM)Sailoog Wrote: Please, I need to see that meat dryer when is done Huh

Your code should look like this:


Code:
import RTIMU, time

SETTINGS_FILE3 = "RTIMULib3"
s3 = RTIMU.Settings(SETTINGS_FILE3)
humidity_val = RTIMU.RTHumidity(s3)
humidity_val.humidityInit()

humidity=''
temperature_h=''

#here starts the bucle
while True:
    time.sleep(1)#here you can define the frequency in seconds
    read=humidity_val.humidityRead()
    if read:
        if (read[0]):
            humidity=read[1]
        if (read[2]):
            temperature_h=read[3]

   print humidity
   print temperature_h

Not tested but it should work, let me know if you get some error.
And please when you are done please publish something in Brag Board subforum.

Should I add Meat Dryer as OpenPlotter feature?[emoji14]

Thanks a lot. Change the code a bit to:


Code:
import RTIMU, time

SETTINGS_FILE3 = "RTIMULib3"
s3 = RTIMU.Settings(SETTINGS_FILE3)
humidity_val = RTIMU.RTHumidity(s3)
humidity_val.humidityInit()

humidity=''
temperature_h=''

#here starts the bucle
while True:
   time.sleep(0.5)#here you can define the frequency in seconds
   read=humidity_val.humidityRead()
   if read:
       if (read[0]):
           humidity=read[1]
           print humidity

But the strange thing is that every 4th value is a strange value:

46.4964027405
46.4964027405
46.4964027405
2.17024011051e+33
46.4582557678
46.4582557678
46.4582557678
2.17024011051e+33
46.4277381897
46.4277381897
46.4277381897
2.17024011051e+33
46.4369735718
46.4369735718
I was wondering what would happen if you slowed down the query rate. The data that I read on that sensor says that it takes 5-10 seconds to reach and report the new temperature. Some sensors don't like to be polled often (DHT11?). I couldnt find anything mention of that for this sensor, just thinking out loud.

Sent from my SM-G900V using Tapatalk


RE: HTU21D humidity value - Sailoog - 2016-03-23

Try what Vamonos suggests and if this doesn't work, add this command


Code:
del read


after


Code:
print humidity



RE: HTU21D humidity value - Swokey - 2016-03-27

Thanks guys for your replies.

First tried to set the time to 5 sec, than I got the same output. 
Changed it to 10 sec, than I got more often then strange value.

So tried to add del read, from sailoog.

Also that didn't changed anything to the output.  Huh