For my Canadian compadres, here's a quick way I got my dashboard talking Celsius for the weathershield mote... this assumes the mote's in the field transmitting values in Fahrenheit.
Login to your raspberry pi and make a backup copy of the metrics.js file
cp /home/pi/gateway/metrics.js /home/pi/gateway/metrics.js_bak
Next nano into metrics.js
nano /home/pi/gateway/metrics.js
and modify the following line in the //WeatherShield metrics section
FH : { name:'F', regexp:/F\:(-?\d+)/i, value:'', valuation:function(value) {return (((value/100)-32)*(5/9)).toFixed(2);}, unit:'°', pin:1, graph:1, graphValSuffix$:'C', graphOptions:{ legendLbl:'Temperature', lines: { lineWidth:1 }}},
ctl-O to save and ctrl-x to exit...
reboot your pi and you ready to see Celsius...
I also altered the Value description on the web page, with a "C"...
The formula is a well know conversion of F to C
;D
Could you tell me how to add 0.7229 to the value on the pressure reading? That's my correction factor for my elevation. I tried in the sketch and failed. I assume if you can manipulate the temp reading from F to C you could add 0.7229 to the P reading. I've tried a couple things but failed. Thanks
Kilo... I would change it this way...
from...
P : { name:'P', regexp:/P\:([\d\.]+)/i, value:'', unit:'"', pin:1, },
to...
P : { name:'P', regexp:/P\:([\d\.]+)/i, value:'', valuation:function(value) {return (value+0.7229).toFixed(2);}, unit:'"', pin:1, },
hope this helps... 8)
Much thanks
tried that then sudo reboot. my gateway gui hangs up at "waiting for socket connection". if i revert to my metrics.js_bak it works fine...
Check the logs for errors.
But don't just copy paste from a non code text, note that the forum will place smiley faces where the character combination matches one.
It should be in a code block (I updated the above). Try it again.
Thanks Felix...
I'll check the log and try again. I didn't copy and paste. I manually entered it. I'll go back through and try it again. I really appreciate it
ok. i changed it to the suggested and the gateway gui wouldn't update. i checked the log and it said it "has no method 'toFixed'". i deleted ".toFixed(2)" and tried it again. i'm attaching a screenshot
http://imgur.com/gallery/B9JvX
Please post the full line as you have it in the metrics.js file. I have a hunch something is missing. Like a semicolon or a bracket.
i cut an pasted this one from the above to metrics.js:
P : { name:'P', regexp:/P\:([\d\.]+)/i, value:'', valuation:function(value) {return (value+0.7229).toFixed(2);}, unit:'"', pin:1, },
new screen shot of gateway.sys.log:
http://imgur.com/gallery/kPBEx
Kilo...
Looks like the script treats the pressure value as a string data type...
What can be done in this case is to parse the value into a float and then apply the correction factor for your area...
...lastly trimming to two decimal places, so the values look consistently formatted for display... try replacing with this code...
P : { name:'P', regexp:/P\:([\d\.]+)/i, value:'', valuation:function(value) {return (parseFloat(value)+0.7229).toFixed(2);}, unit:'"', pin:1, },
Perfect! Works like a charm. Much appreciated
Good stuff!