Calculating absolute humidity out of rules

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Wiki
Normal user
Posts: 413
Joined: 23 Apr 2018, 17:55
Location: Germany

Calculating absolute humidity out of rules

#1 Post by Wiki » 18 Oct 2019, 19:16

Small project: I wanted to give a ventilation recommendation depending on indoor/outdoor humidity and temperature. As I learned by teacher google et al you need the absolute humidity to be compared.

Calculating the absolute humidity needs a bunch of formulas, but I've found some sources where these formulas were compressed to a useable format - useable in our rules. This is the result:

Code: Select all

  TaskValueSet,7,2,(6.112*(2.71828182845904^((17.67*[AUD#C])/([AUD#C]+253.5)))*[AUD#H]*2.1674)/(273.15+[AUD#C])   //outdoor
  TaskValueSet,7,4,(6.112*(2.71828182845904^((17.67*[AUD#IC])/([AUD#IC]+253.5)))*[AUD#IH]*2.1674)/(273.15+[AUD#IC])   //indoor
AUD#C & AUD#H are outdoor values of temperature and humidity, AUD#IC and AUD#IH the indoor ones. Comparing the results: as long as the indoor result is bigger than the outdoor one it makes sense to open the window (or switch on a blower or whatever), otherwise not.

On my site it raised the WAF concerning my electronic playground by 100%.

Might be helpful for someone else.....

Code: Select all

pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Calculating absolute humidity out of rules

#2 Post by TD-er » 18 Oct 2019, 20:36

There is already the formula present for this, but it has not (yet) made available as an external variable.
I use it in the BME280 plugin to compensate for temperature offset.

Hmm this function you describe differs from the one I used.
Do you have a source for this one?

Wiki
Normal user
Posts: 413
Joined: 23 Apr 2018, 17:55
Location: Germany

Re: Calculating absolute humidity out of rules

#3 Post by Wiki » 18 Oct 2019, 23:05

But nowhere I have found neither in the documentation of espeasy nor in this forum any information of the challenge 'out of rules'. Lack of docs? Or are you talking about dew point?

I don't have a source at once at hand, but you can find this kind of calculation at least in the sources of:

viewtopic.php?f=5&t=3672&p=20040&hilit= ... ity#p20040

Code: Select all

pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Calculating absolute humidity out of rules

#4 Post by TD-er » 19 Oct 2019, 00:48

In order to compute the correct humidity when applying an offset in the temperature, you also need to compute the absolute humidity, right?
Perhaps you're right in that it is probably the dew point. Well when I start asking myself these questions, it is often a good idea to realize it is time for some sleep :)

Wiki
Normal user
Posts: 413
Joined: 23 Apr 2018, 17:55
Location: Germany

Re: Calculating absolute humidity out of rules

#5 Post by Wiki » 19 Oct 2019, 13:16

I did a little research with google and I think, I have found the source of the formula I am using: https://carnotcycle.wordpress.com/2012/ ... -humidity/

The formula itself I had found somewhere else (don't remember where), but if you scroll through the linked blog it seems, that the above linked source is spread all over the world.

Code: Select all

pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $

Wiki
Normal user
Posts: 413
Joined: 23 Apr 2018, 17:55
Location: Germany

Re: Calculating absolute humidity out of rules

#6 Post by Wiki » 15 Feb 2021, 15:14

Update:

using the formula abilities of ESPEasy since release of 2021-01-14 the calculation of the absolute humidity may look like this:

Code: Select all

On FTemp Do
  TaskValueSet,4,1,(6.112*(exp((17.67*%eventvalue1%)/(243.5+%eventvalue1%)))*%eventvalue2%*2.1674)/(273.15+%eventvalue1%)
  Publish domoticz/in,'{"idx":45,"nvalue":0,"svalue":"[AF1#AbsFL]"}'
EndOn
Data sent by another device to concentrate the calculations for all available environment sensors in my house in one device:

Code: Select all

On Temp#T Do
  SendTo,5,'event,FTemp=[Temp#T],[Temp#H]'             //sending temperature/relative humidity from a BME280
EndOn
Display.JPG
Display.JPG (53.74 KiB) Viewed 14041 times

Code: Select all

pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $

Spacefan
New user
Posts: 8
Joined: 10 Sep 2020, 13:03

Re: Calculating absolute humidity out of rules

#7 Post by Spacefan » 05 Apr 2021, 22:49

Hey,
using D1 mini with mega-20200410 and BME280

I am calculating absolute humidity using dummy device and rules like this
on BME280#Temperature do
TaskValueSet 5,1,(6.112*(2.7182^((17.67*[BME280#Temperature])/([BME280#Temperature]+243.5)))*[BME280#Humidity]*2.1674)/(273+[BME280#Temperature]) endon

I works well, until I had negative °C temperatures today and the resulting dummy value was returned as 0.0. When it turned positive °C it gave a valid value again, so its not broken, just struggles with neg temps

anyone an idea?

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Calculating absolute humidity out of rules

#8 Post by TD-er » 05 Apr 2021, 23:22

Why do you need the absolute humidity?
If it is to compute the dew point, then you can simply use this formula (see bottom of system variables page on a 'normal' or 'custom' build)

Dew point(T,H):

Code: Select all

%c_dew_th%(18.6,67)
Resulting in: 12.31 C

About the negative numbers...
Maybe you can try to wrap the temperature places in extra () ?

Spacefan
New user
Posts: 8
Joined: 10 Sep 2020, 13:03

Re: Calculating absolute humidity out of rules

#9 Post by Spacefan » 05 Apr 2021, 23:38

because absolute humidity is the best indicator for ventilation...

added additional parentheses, but it does not work, thanks though :)

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Calculating absolute humidity out of rules

#10 Post by TD-er » 05 Apr 2021, 23:44

Maybe you can split up the formula into several let statements to store it in a variable and then use those variables later.

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Calculating absolute humidity out of rules

#11 Post by Ath » 06 Apr 2021, 07:46

Spacefan wrote: 05 Apr 2021, 22:49 using D1 mini with mega-20200410 and BME280
Updating to a (much) newer ESPEasy release can also improve things here, calculation has improved quite a bit in recent months, get the latest build here: https://github.com/letscontrolit/ESPEasy/releases
/Ton (PayPal.me)

easy-mrmomba
Normal user
Posts: 13
Joined: 24 Mar 2021, 16:53
Location: germany

Re: Calculating absolute humidity out of rules

#12 Post by easy-mrmomba » 07 Apr 2021, 16:28

Spacefan wrote: 05 Apr 2021, 22:49 Hey,
using D1 mini with mega-20200410 and BME280

I am calculating absolute humidity using dummy device and rules like this
on BME280#Temperature do
TaskValueSet 5,1,(6.112*(2.7182^((17.67*[BME280#Temperature])/([BME280#Temperature]+243.5)))*[BME280#Humidity]*2.1674)/(273+[BME280#Temperature]) endon

I works well, until I had negative °C temperatures today and the resulting dummy value was returned as 0.0. When it turned positive °C it gave a valid value again, so its not broken, just struggles with neg temps

anyone an idea?
Maybe an Idea. You have tou use KELVIN.

If you use Kelvin, you will not have negative values. 0 Kelvin is -273.15C °. Kelvin is actually used for all physical, chemical calculations. In Germany, the word "Kältebrücke" is often used when the insulation / camper is partially poor - but that is actually wrong, as there is no cold-nevative value at Kelvin. Since 0 Kelvin is the absolute zero, there are only ""Wärmebrücken". Which in turn will be interesting for the DEW-Point calculation.

Maybe you can calculate the Temperature in Kelvin - maybe like this way:
This is just for checkup: (273,15 K + [BME280#Temperature] )− 273,15 = 0 °C

And this is for calculating kelvin: 273,15 + [c°] = kelvin


Some Sidestep - Question: is there a way to calculate the PPM from an MQ2 Sensor on this way? I have tried to copy the algorithmus - but i think with no luck....

[quote=TD-er post_id=51662 time=1617657740 user_id=2996]

Dew point(T,H):
[code]
%c_dew_th%(18.6,67)
[/code]
Resulting in: 12.31 C

[/quote]


Post Reply

Who is online

Users browsing this forum: No registered users and 18 guests