Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 01:06 24 May 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Calculating Humidity

Author Message
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1970
Posted: 12:38am 10 Feb 2025
Copy link to clipboard 
Print this post

My outdoor humidity sensors continually fail after a few months. I live in an area with very high humidity, commonly above 70%. I was using HTU21D then switched to AHT10 but both eventually fail.  I am toying with the idea of using two temperature sensors one wet and one dry, but can't find a formula to get humidity from wet and dry bulb. All the formulas use the dew point and to find that you need to know the humidity.
Is there a reliable sensor out there.
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6230
Posted: 01:00am 10 Feb 2025
Copy link to clipboard 
Print this post

https://www.thebackshed.com/forum/ViewTopic.php?TID=15917&PID=203964#203964#203964

That should give you a start.

Jim
VK7JH
MMedit
 
zeitfest
Guru

Joined: 31/07/2019
Location: Australia
Posts: 551
Posted: 01:49am 10 Feb 2025
Copy link to clipboard 
Print this post

Maybe try this   which sounds stable
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6230
Posted: 02:21am 10 Feb 2025
Copy link to clipboard 
Print this post

The HDC3021 has a heater built in. The heater will require operation on a regular basis when living in high humidity areas.

North Queensland needs a depth gauge rather than a humidity sensor!

Jim
VK7JH
MMedit
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1970
Posted: 02:28am 10 Feb 2025
Copy link to clipboard 
Print this post

Yes, we've had over 2000mm of rain here this month. Luckily we live on sand near the beach so all OK with us and we have a generator for when we lost power for 2 days.

Ordered a  HDC3021 I'll try that.
Edited 2025-02-10 12:31 by palcal
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
SimpleSafeName

Guru

Joined: 28/07/2019
Location: United States
Posts: 350
Posted: 02:38am 10 Feb 2025
Copy link to clipboard 
Print this post

Working in the paint shop at GM, we would use dew point (mirrored) sensors. But these weren't all that reliable, and they were crazy expensive.

Our Zurn air dryers used a humidity sensor to get the compressed air coming from our Central Utilities dried down to -70F (who would always pinky-swear that their air was already dried down to -70F. Not hardly). But I don't recall what the technology was for that one.

The suggestion being, that since the sensors tend to give you fits anyways, pick the cheaper ones. :)

Our Process Engineers would take dry bulb, wet bulb measurements and use those readings to compute the humidity from a psyhrometric chart.

If (ha!, when) our reading would differ wildly from theirs, they would pester us controls guys to do something with our meters. We would simply show them the price tag and that would be that.


The suggestion that Tassy Jim gave you is what our Process Engineers would use.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6230
Posted: 03:47am 10 Feb 2025
Copy link to clipboard 
Print this post

When I updated my sensors, I installed

BME280 for T H & P
HTU21  for T and H
BMP180 for T and P
SHT31  for T H & P
DHT22  for T and H


That's 5 temperature, 4 humidity and 3 pressure.

It's too soon to tell which one fails first.

Jim
VK7JH
MMedit
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4919
Posted: 06:57am 10 Feb 2025
Copy link to clipboard 
Print this post

Pascal,

I had a test setup with the wet bulb using two DS18B20.
It had good relation with a hygrometer, as long as you could get some form of controlled airflow over it.

However, it never made it into the tropical forest of my sun. I can see if I can find the picomite code later today, then post it here.

Volhout
Edited 2025-02-10 17:04 by Volhout
PicomiteVGA PETSCII ROBOTS
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1970
Posted: 07:32am 10 Feb 2025
Copy link to clipboard 
Print this post

@ Volhout, Thanks.
Any one got code for a HDC3021 sensor. The best I could do was ask AI to generate it.
I'll see what happens when the sensor arrives.
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4919
Posted: 11:21am 10 Feb 2025
Copy link to clipboard 
Print this post

  Volhout said  Pascal,

I had a test setup with the wet bulb using two DS18B20.
It had good relation with a hygrometer, as long as you could get some form of controlled airflow over it.

However, it never made it into the tropical forest of my son. I can see if I can find the picomite code later today, then post it here.

Volhout

PicomiteVGA PETSCII ROBOTS
 
Marcel27

Regular Member

Joined: 13/08/2024
Location: Netherlands
Posts: 81
Posted: 12:25pm 10 Feb 2025
Copy link to clipboard 
Print this post

https://www.meteo-julianadorp.nl/Afbeeldingen/Calculator_bestanden/rhWetBulbFromTd.pdf
 
Pluto
Guru

Joined: 09/06/2017
Location: Finland
Posts: 375
Posted: 04:35pm 10 Feb 2025
Copy link to clipboard 
Print this post

old post

Update: One month ago I had to replace the wet temperature sensor  because the epoxy insulation had failed. New epoxied sensor and all ok again.

Source article

Pluto
 
Pluto
Guru

Joined: 09/06/2017
Location: Finland
Posts: 375
Posted: 04:40pm 10 Feb 2025
Copy link to clipboard 
Print this post

A small 12V fan driven by 5V creates an airflow over the sensors.
My system has no measurement for air-pressure. Assume it is at standard pressure in my calculations.
The calculations would be much easier to do with Picomite than with the PIC microcontroller I used!

Pluto
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4919
Posted: 05:16pm 10 Feb 2025
Copy link to clipboard 
Print this post

Hi Pascal,

This the basic that I used to determine RH in a wet climate. It runs on PicoMite (I used 5.08.00 at that time, but I think it should also work with more recent versions. It is all math, and 2 DS18B20's). It writes log to a file on SD card, and actual to a VGA/LCD screen.

 ' Dual DS18B20 measuring relative humidity
 ' gp10 is connected to the wet sock DS18B20
 ' gp11 is connected to the ambient temp DS18B20
 
 option default float
 
 ' constants
 e=2.71828172845904
 k1=6.112
 n=0.6687451584
 k2=0.00115
 k3=17.502
 k4=240.97
 
 cls
 box 0,50,320,60,2,rgb(yellow)
 text 15,130,"Data file = B:/rh.csv",,,,rgb(yellow)
 open "b:/rh.csv" for append as #1
 print #1,"date,time,Td,Tw,rH"
 close #1
 w$=""
 av=0
 do
   tempr start gp10,3
   tempr start gp11,3
   pause 900
   av=min(av+1,60)               'running average max 60
   Tw=(tempr(gp10)+(av-1)*Tw)/av 'averaging 60* (1 minute)
   Td=(tempr(gp11)+(av-1)*Td)/av 'averaging 60* (1 minute)
   
   'math from the internet
   ew=k1*e^(k3*Tw/(k4+Tw))
   ed=k1*e^(k3*Td/(k4+Td))
   rH=100*(ew-n*(1+k2*Tw)*(Td-Tw))/ed
   
   'display humidity
   text 16,10,"Room Temp: "+str$(Td,2,4)+" C",,,,rgb(green)
   text 16,30,"Sock Temp: "+str$(Tw,2,4)+" C",,,,rgb(cyan)
   text 16,70,"Humidity: "+str$(rH,3,2)+" %",,,2,rgb(yellow)
   
   if w$<>left$(time$,5) then  'every minute
     w$=left$(time$,5)
     open "b:/rh.csv" for append as #1
     print #1,date$+","+time$+","+str$(Td,2,4)+","+str$(Tw,2,4)+","+str$(rH,3,2)
     close #1
   end if
   pause 100
   
 loop while inkey$=""
end

Edited 2025-02-11 03:17 by Volhout
PicomiteVGA PETSCII ROBOTS
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1970
Posted: 08:14pm 10 Feb 2025
Copy link to clipboard 
Print this post

@ Volhout, thanks for the code.
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6230
Posted: 06:21am 19 Feb 2025
Copy link to clipboard 
Print this post

  palcal said  @ Volhout, Thanks.
Any one got code for a HDC3021 sensor. The best I could do was ask AI to generate it.
I'll see what happens when the sensor arrives.

The Adafruit module seems to be the only one available.
It now uses the HDC3022
My module arrived today and I had some time to test it.
The chip has a heater which can be turned on to recover from high humidity. I don't have high humidity to test under real conditions but it does seem to work as advertised.
I expect that whenever the humidity reaches 100% for any extended time, you will turn the heater on until the humidity reads very low.
The heater is then turned off and ~10 minutes later, the temperature and humidity readings should be realistic.
Sample output:
RUN
16:53:27        20.9    46.2
16:53:37        21.0    45.8
16:53:47        21.0    45.7
16:53:57        20.9    45.8
heater  1
16:54:07        20.9    45.8
16:54:17        22.1    45.9
16:54:27        33.3    20.5
16:54:37        34.2    18.9
16:54:47        34.7    18.4
16:54:57        35.0    17.8
16:55:07        35.3    17.4
16:55:17        35.5    17.2
16:55:27        35.7    17.0
16:55:37        35.9    16.7
16:55:47        36.0    16.5
16:55:57        36.2    16.3
16:56:07        36.3    16.2
16:56:17        36.4    16.1
16:56:27        36.5    16.0
heater  0
16:56:37        36.6    16.0
16:56:47        24.9    32.6
16:56:57        23.7    36.9
16:57:07        23.3    38.1
16:57:17        23.0    38.8
16:57:27        22.7    40.0
16:57:37        22.6    40.5
16:57:47        22.4    41.0
16:57:57        22.3    41.3
16:58:07        22.1    41.7
16:58:17        22.1    42.1
16:58:27        22.0    42.2
16:58:37        21.8    42.2
16:58:47        21.8    42.4
16:58:57        21.8    42.6
16:59:07        21.6    43.2
16:59:17        21.6    43.3
16:59:27        21.5    43.2
16:59:37        21.5    43.2
16:59:47        21.5    43.5
16:59:57        21.4    43.5
17:00:07        21.4    43.9
17:00:17        21.4    44.0


Don't set the heater too high. Start with a low setting until you know how it responds in NQ weather.

The code:
 ' HDC3022 TassyJim Feb 2025
 OPTION EXPLICIT
 OPTION DEFAULT INTEGER
 OPTION BASE 0
 DIM readnow
 DIM FLOAT mytempr, myhumid
 CONST HDCaddr = &h44
 
 SETPIN GP16, GP17, I2C
 I2C OPEN 400, 100
 SETTICK 10000, readit
 setHDCheater &h005F ' &h9F = quarter power
 DO
   IF readnow THEN readHDC3022
   IF INKEY$ = "1" THEN HDCheater 1
   IF INKEY$ = "0" THEN HDCheater 0
 LOOP
 I2C CLOSE
 
SUB readit
 readnow = 1
END SUB
 
SUB readHDC3022
 LOCAL hdc%(6)
 readnow = 0
 I2C WRITE HDCaddr, 0, 2, &h24, &h0B
 PAUSE 15
 I2C READ HDCaddr, 0, 6, hdc%()
 mytempr = 175*(hdc%(0)*256+hdc%(1))/(2^16-1)-45
 myhumid = 100*( hdc%(3)*256+hdc%(4))/(2^16-1)
 PRINT TIME$, STR$(mytempr,3,1),STR$(myhumid,3,1)
END SUB
 
 ' 1 = heater on, 0 = heater off
SUB HDCheater state
 IF state THEN
   I2C WRITE HDCaddr, 1, 2, &h30, &h6D
 ELSE
   I2C WRITE HDCaddr, 1, 2, &h30, &h66
 ENDIF
 PRINT "heater ";state
END SUB
 
SUB setHDCheater heat
 LOCAL crc%, htr%(2)
 IF heat > &h3FFF THEN heat = &h3FFF
 IF heat < 0 THEN heat = 0
 htr%(0) = heat >> 8
 htr%(1) = heat AND &hFF
 crc% = MATH(crc8 htr%(),2, &h31,&hFF)
 I2C WRITE HDCaddr, 0, 5, &h30, &h6E, htr%(0),htr%(1),crc%
END SUB


Jim
Edited 2025-02-21 08:00 by TassyJim
VK7JH
MMedit
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6230
Posted: 10:03pm 20 Feb 2025
Copy link to clipboard 
Print this post

Additional information

The SHT21 has a 5mW heater which can be used to test the humidity reading. It should reduce when the heater is turned on.
The heater will only increase temperature by 1.5 degrees C so no use for drying the sensor out.

The HTU21D also has a 5mW heater for diagnosis.

The SHT31 has a more powerful heater at about 20mW at 3.3V. The data sheet makes no mention of using the heater for device recovery but it might work. The heater output is fixed.

The HDC3022 heater can be set anywhere up to 300mW and the data sheet has plenty of information about using the heater for recovery after high humidity.

Apart from setting the heater wattage, you can use the same code for the HDC3022 and the SHT31. They appear to be closely related.

Jim
VK7JH
MMedit
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025