I have my Weathershield up and working and am looking to add dew point to what uploads to WU. The simplified formula for dew point I'll use is : Td=Tc-((100-RH)/5). I was wondering if someone could correct me where I'm wrong in my code:
dewptf=echo((($temp1-32)/1.8)-((100-$humidity1)/5) | bc)
Here is my current code that works fine:
https://imgur.com/gallery/LnWXf
dewpout_eu = ( celsTemp - ((100.00f - humidity) / 5.00f) );
dewpout_us = (( dewpout_eu * 1.8 ) + 32);
arduino code, but I think you can see, what you need to do
I would say, your code is ok
yeah, i've got that but i keep getting a syntax error.
dewptf=$(echo ((($temp1-32)/1.8)-((100-$humidity1)/5) | bc))
Quote from: Kilo95 on November 28, 2017, 12:32:11 PM
yeah, i've got that but i keep getting a syntax error.
dewptf=$(echo ((($temp1-32)/1.8)-((100-$humidity1)/5) | bc))
Unbalanced parenthesis and you need some double quotes. The following works in bash and ksh93:
bash-4.1$ temp1=72 # Sample temperature degrees F
bash-4.1$ humidity1=80 # Sample humidity
bash-4.1$ dewptf=$(echo "((($temp1-32)/1.8)-(100-$humidity1)/5)" | bc) # Dew point degrees C
bash-4.1$ echo $dewptf
18
bash-4.1$
By default bc uses integer math (probably close enough given the precision with which you can measure humidity) so if you want floating point results pass the scale to bc, eg:
bash-4.1$ temp1=72 # Sample temperature degrees F
bash-4.1$ humidity1=80 # Sample humidity
bash-4.1$ dewptf=$(echo "scale=2 ; ((($temp1-32)/1.8)-(100-$humidity1)/5)" | bc) # Dew point degrees C
bash-4.1$ echo $dewptf
18.22
bash-4.1$
BTW this formula gives the dew point in C so if you want F you need to convert it back via F = 1.8C + 32:
bash-4.1$ temp1=72 # Sample temperature
bash-4.1$ humidity1=80 # Sample humidity
bash-4.1$ dewptc=$(echo "scale=2 ; ((($temp1-32)/1.8)-(100-$humidity1)/5)" | bc)
bash-4.1$ dewptf=$(echo "scale=2 ; 1.8*$dewptc + 32" | bc)
bash-4.1$ echo $dewptc $dewptf
18.22 64.79
bash-4.1$ dewptf=$(echo "scale=2 ; 1.8*((($temp1-32)/1.8)-(100-$humidity1)/5) + 32" | bc) # Or just this
bash-4.1$ echo $dewptf
64.79
bash-4.1$
I am pulling the temp and humidity from a Weathershield. I want to use that to calc the dew point. I'll give this a try tomorrow. Thanks!
got it working. thanks for your help! just for a summary, i added :
dewptf=$(echo "scale=2 ; 1.8*((($temp1-32)/1.8)-(100-$humidity1)/5) + 32" | bc)
below "fi" in the code:
echo $dewptf
I added below between the barometer code and the humidity code in the curl statement.
dewptf=${dewptf%$cr}&