Hi Gordon. Setting both the variables to 0 worked. I am now receiving a negative temp reading. It has to be my math that is the issue.
Code:
function getResTempValue(x) { var temp=0; var avgTemp=0; for (var i=0;i<x;i++) { var vOut = E.getAnalogVRef() * analogRead(A0); // if you attached VOUT to Ao var vZero = 0.4; var tCoeff = 19.5 / 1000; var tempinc = (vOut - vZero) / tCoeff; var tempinf = tempinc * (9 / 5) + 32; temp = temp + tempinc; console.log(temp); if (i==x) { //avgTemp = temp / x; //temp = temp / x; } console.log(i); } temp = temp / x; console.log("Temp: " + temp + "Avg temp: " + avgTemp); return temp.toFixed(2); }
@d0773d started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hi Gordon. Setting both the variables to 0 worked. I am now receiving a negative temp reading. It has to be my math that is the issue.
Code: