You are reading a single comment by @d0773d and its replies. Click here to read the full conversation.
  • DrAzzy, yes the temp is averaging around -20C. I don't think it is a wiring issue. I was getting positive readings before I attempting to implement some kind of averaging temp reading. Well, I just made a liar out of myself. I went back to my original code without the averaging stuff and I am still receiving negative readings.

    Original code:

    function onInit() {
      var phValue="";
    
      Serial4.setup(38400);
    
      Serial4.onData(function (e) {
        phValue+=e.data;
    
        if (e.data == "\r") {
          console.log(phValue);
          phValue="";
        }
      });
    
      function getResTempValue() {
        var vOut = E.getAnalogVRef() * analogRead(A0); // if you attached VOUT to Ao
        var vZero = 0.4;
        var tCoeff = 19.5 / 1000;
        var temp = (vOut - vZero) / tCoeff;
        console.log(temp);
    
        return temp.toFixed(2);
      }
    
      function getPhValue() {
        var rescomp="";
        var pfloat="";
        //on = !on;
        //digitalWrite(LED1, on);
        rescomp = getResTempValue();
        pfloat = parseFloat(rescomp);
        console.log("Temp: " + pfloat);
        Serial4.print(rescomp+"\r");
        //Serial4.print("r\r");
      }
    
      function phCalibrate4() {
      }
    
      function phCalibrate7() {
      }
    
      function phCalibrate10() {
      }
    
      var interval = setInterval(getPhValue, 5000);
    }
    
    onInit();
    
About

Avatar for d0773d @d0773d started