You are reading a single comment by @user7143 and its replies. Click here to read the full conversation.
  • This seems to have fixed the fault reporting issue.

    
    
    exports.connect = function(spi,cs) {
      return new MAX31855(spi,cs);
    };
    
    
    function MAX31855(spi,cs) {
      this.spi=spi;
      this.cs=cs;
    }
    MAX31855.prototype.getTemp = function () {
      var d = this.spi.send("\0\0\0\0",this.cs); 
      var trtn={};
      trtn.temp=(d.charCodeAt(0)<<6 | d.charCodeAt(1)>>2)*0.25;
      if (d.charCodeAt(1) & 1)  {
        var fault = (d.charCodeAt(3) & 7);
        switch (fault) {
          case 1:
            return trtn.fault="No probe detected";
    
          case 3:
            return trtn.fault="Probe shorted to Ground";
     
          case 4:
            return trtn.fault="Probe shorted to VCC";
     
          default:
           return  trtn.fault=fault;
        }
      }
        else{
    
      return trtn;
        }};
    
    
About

Avatar for user7143 @user7143 started