### Author Topic: Virtual sensor for temperature difference problem **solved**  (Read 1286 times)

0 Members and 1 Guest are viewing this topic.

#### miraculon ##### Virtual sensor for temperature difference problem **solved**
« on: July 24, 2014, 09:38:18 AM »
I thought that I would post this here as well as the meteohub forum. If anyone can spot why I am getting twice the expected result (prior to my /2 hack) I would appreciate input.

After a lot of trial and error, I think that I have created a virtual sensor for temperature difference. I have two Davis temperature sensors outside. One is in the ISS the other is a Temperature/Humidity station.

There is a math quirk that you cannot subtract the difference in Celsius, then convert to Fahrenheit. I discovered that I cannot make a T# virtual sensor, I could only use a "Data#" sensor. After resolving the math issue and converting each sensor to Fahrenheit with the standard formula and then subtracting the two, I was left with a difference that appears to be twice the actual.

As a hack, I divide the result by two which gives the desired result.

Here is the calculation for the two virtual sensors. I would appreciate any further understanding on why my results were twice that expected and what I might be doing wrong.

....((\$2)*((9/5)--32)))/2) Note the /2 that I added.

The data8 sensor (th0/th1)

Code: [Select]
`selectmaster 1 300 | gawk '{ if (\$1 == ''none'') printf ''none''; else printf ''%d'',  ((((\$1)*((9/5)--32)) - ((\$2)*((9/5)--32)))/2)}'`
Code: [Select]
`selectslave 1 300 | gawk '{ if (\$1 == ''none'') printf ''none''; else printf ''%d'',  ((((\$1)*((9/5)--32)) - ((\$2)*((9/5)--32)))/2)}'`
The data9 sensor (thb0/th0)

Code: [Select]
`selectmaster 1 300 | gawk '{ if (\$1 == ''none'') printf ''none''; else printf ''%d'', (((\$1)*(((9/5)--32)) - ((\$2)*((9/5)--32)))/2)}'`
Code: [Select]
`selectslave 1 300 | gawk '{ if (\$1 == ''none'') printf ''none''; else printf ''%d'',  ((((\$1)*((9/5)--32)) - ((\$2)*((9/5)--32)))/2)}'`
Greg
« Last Edit: July 31, 2014, 10:05:17 AM by docbee » Blitzortung Stations #706 and #1682
CoCoRaHS: MI-PI-1
CWOP: CW4114 and KE8DAF-13
WU: KMIROGER7

#### docbee

• Moderator
• Forecaster
•     • Posts: 725 ##### Re: Virtual sensor for temperature difference problem
« Reply #1 on: July 24, 2014, 10:28:45 AM »
Quote
((\$2)*((9/5)--32)))

The brackets are wrong, this is not a correct Celsius-Fahrenheit conversion.
founder of smartbedded.com - home of meteohub, meteoplug, meteobridge, meteostick

#### miraculon ##### Re: Virtual sensor for temperature difference problem
« Reply #2 on: July 24, 2014, 12:33:17 PM »  This is what I get from using my faulty memory, instead of looking it up to be sure...

I see it now, I changed them as following:

Code: [Select]
`selectmaster 1 300 | gawk '{ if (\$1 == ''none'') printf ''none''; else printf ''%d'',  ((((\$1)*(9/5))--32)-(((\$2)*(9/5))--32))}'selectslave 1 300 | gawk '{ if (\$1 == ''none'') printf ''none''; else printf ''%d'',  ((((\$1)*(9/5))--32)-(((\$2)*(9/5))--32))}'`
and

Code: [Select]
`selectmaster 1 300 | gawk '{ if (\$1 == ''none'') printf ''none''; else printf ''%d'', ((((\$1)*(9/5))--32)-(((\$2)*(9/5))--32))}'selectslave 1 300 | gawk '{ if (\$1 == ''none'') printf ''none''; else printf ''%d'',  ((((\$1)*(9/5))--32)-(((\$2)*(9/5))--32))}'`
Thanks for the clue docbee.....
I still see a small fraction of a degree error, like 0.7°F but I am not going to worry about it. Might be sensor resolution or something.

Actually, this is working well now. I had to multiply the result by 10, since the raw data is in 10ths of a degree.

There must be some "black box" conversions from tenths to standard integer+tenths that I can't account for. It seems that there is a double conversion from tenths, first against the raw data going into the calculation and then again on the result. The result is 1/10th of the expected result. It seems that I should not need to multiply by 10, but it works. Dunno....

Greg H.

« Last Edit: July 25, 2014, 09:22:38 AM by miraculon » Blitzortung Stations #706 and #1682
CoCoRaHS: MI-PI-1
CWOP: CW4114 and KE8DAF-13
WU: KMIROGER7