Nodejs Code:
var m = require('mraa'); var a0 = new m.Aio(0); a0.setBit(10); console.log("reading analog input>>>"); /*setInterval(function() { readAnalog() }, 1000);*/ function readAnalog() { var v_out; var temp; v_out = a0.read(); v_out*=.0048; v_out*=1000; temp=0.0512 * v_out -20.5128; var tempinf = temp * (9 / 5) + 32; console.log("c: " + temp.toFixed(1) + " f: " + tempinf.toFixed(1)); } readAnalog();
I am using a MCP9701. The MCP9701 is hooked to my Edison Arduino breakout board pin A0, 5v and ground.
The output temp is:
c: 25.4 f: 77.8
My room temp thermometer say 71.8 and the Edison is calculating my room temp as 77.8. The temperature is definitely NOT 77.8 in my room. What am I doing wrong and how do I get the proper temperature calculation using NodeJS?