You are reading a single comment by @DrAzzy and its replies. Click here to read the full conversation.
  • Updated on my site. Code is:

    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 = SPI1.send("\0\0\0\0",this.cs); 
      if (d.charCodeAt(1) & 1)  {
        var trtn = {fault: (d.charCodeAt(3) & 7)};
        switch (trtn.fault) {
          case 1:
            trtn.faultstring="No probe detected";
            break;
          case 3:
            trtn.faultstring="Probe shorted to Ground";
            break;
          case 4:
            trtn.faultstring="Probe shorted to VCC";
            break;
        }
        return trtn;
      } else {
        return {temp: (d.charCodeAt(0)<<6 | d.charCodeAt(1)>>2)*0.25, fault: 0};
      }
    };
    
About

Avatar for DrAzzy @DrAzzy started