• Your best bet is to find the function in the reference: http://www.espruino.com/Reference

    Then there's a ⇒ symbol next to the function's title. Click on that and you go to the implementation: https://github.com/espruino/Espruino/blo­b/master/src/jswrap_onewire.c#L111

    If you want actual specifics of the OneWire protocol, it's best just to google it.

    Can you try adding this to the end of your code:

    sensor.getTemp = function(callback) {
      function read(me) {
        var s = me._r();
        var temp = s[0] + (s[1]<<8);
        if (temp & 32768) temp -= 65536;
        temp = temp / ((me.type==10)?2:16);
        if (callback) callback(temp);
        return temp;
      }
      this.bus.select(this.sCode);
      this.bus.write(0x44, true);
      if (!callback) return read(this);
      var tim = {9:94, 10:188, 11:375, 12:750};
      setTimeout(read, tim[this.getRes()], this);
    };
    

    And see what it says? It'll ignore the CRC.

About

Avatar for Gordon @Gordon started