Formula Length Limit

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
lyndondr
Normal user
Posts: 12
Joined: 20 Aug 2018, 22:03

Formula Length Limit

#1 Post by lyndondr » 24 Aug 2018, 19:49

It would appear the length of a formula is limited to 40 characters.
I want to use a more accurate formula for calculating dew point.

I found the following in the Misc.ino towards the bottom of the file.

// Compute the dew point temperature, given temperature and humidity (temp in Celcius)
// Formula: http://www.ajdesigner.com/phphumidity/d ... rature.php
// Td = (f/100)^(1/8) * (112 + 0.9*T) + 0.1*T - 112
float compute_dew_point_temp(float temperature, float humidity_percentage) {
return pow(humidity_percentage / 100.0, 0.125) *
(112.0 + 0.9*temperature) + 0.1*temperature - 112.0;

Is there a way to use this somewhere in the web interface?

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Formula Length Limit

#2 Post by grovkillen » 24 Aug 2018, 20:50

It's commented out but if you look in the rules tutorials you see my example on how to do this using dummy variables.

https://www.letscontrolit.com/wiki/inde ... example.29
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

lyndondr
Normal user
Posts: 12
Joined: 20 Aug 2018, 22:03

Re: Formula Length Limit

#3 Post by lyndondr » 25 Aug 2018, 02:49

Is there any reason the following formula wouldn't work in the rules? dewpoint = (%rh/100)^(1/8) * (112 + 0.9*Temp) + 0.1*Temp - 112
That formula is more accurate than the other simple one.

Some of the items in your example aren't making sense to me.

Can you explain this line ?"Publish %sysname%/DewPoint_OUTSIDE/°C,[Dew_point#°C1]"

Maybe it's because I'm using the mega-20180818 but the Rules seem very hit and miss. I seemed to have it working in Celsius but when I tried to make a conversion to Fahrenheit everything fell apart. Then I tried to go back to what seemed to work and I wasn't able to get that going.

If I'm not setting the values to a different device is it necessary to use the Publish function?

Isn't that the function of the TaskValueSet command?

I'll maybe have to try it again. I have my system name set the same as one of my devices. The log would show the values of the variables but the publishing didn't seem to work.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Formula Length Limit

#4 Post by grovkillen » 25 Aug 2018, 07:36

lyndondr wrote: 25 Aug 2018, 02:49 Is there any reason the following formula wouldn't work in the rules? dewpoint = (%rh/100)^(1/8) * (112 + 0.9*Temp) + 0.1*Temp - 112
That formula is more accurate than the other simple one.

Some of the items in your example aren't making sense to me.

Can you explain this line ?"Publish %sysname%/DewPoint_OUTSIDE/°C,[Dew_point#°C1]"

Maybe it's because I'm using the mega-20180818 but the Rules seem very hit and miss. I seemed to have it working in Celsius but when I tried to make a conversion to Fahrenheit everything fell apart. Then I tried to go back to what seemed to work and I wasn't able to get that going.

If I'm not setting the values to a different device is it necessary to use the Publish function?

Isn't that the function of the TaskValueSet command?

I'll maybe have to try it again. I have my system name set the same as one of my devices. The log would show the values of the variables but the publishing didn't seem to work.
The formula you try to do is very much ok. Only thing I suspect is the ^ part. You may need to change the ^(1/8) to ^0.125

Regarding my example it's just an example that use MQTT to tell the outside world. I use two BME280 on the same node, you don't need to do that.

I know that my calculation is the simplified one but given the fact that it's really close on temperatures when above 50% humidity I find it very useful still.

If you got it working for Celsius, you could dump that calculated value to a dummy and then do the Celsius to Fahrenheit as a separate calculation.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

lyndondr
Normal user
Posts: 12
Joined: 20 Aug 2018, 22:03

Re: Formula Length Limit

#5 Post by lyndondr » 25 Aug 2018, 19:41

Well after trying a different device using "mega-20180513" I was able to make things work. I rolled back the original device back to the 513 version and that one works now.

Here is what I am using and it seems to be working good.

on DHT22#%RH do
TaskValueSet 2,1,(([DHT22#TempF]-32)*5)/9
endon

on FtoC#TempC do
TaskValueSet 2,2,([DHT22#%RH]/100)^.125*(112+.9*[FtoC#TempC])+.1*[FtoC#TempC]-112
endon

on FtoC#DewPC do
TaskValueSet 3,1,[FtoC#DewPC]*1.8+32
endon

Post Reply

Who is online

Users browsing this forum: No registered users and 37 guests