You are reading a single comment by @d0773d and its replies. Click here to read the full conversation.
  • 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);
      }
    
About

Avatar for d0773d @d0773d started