• var i2c = new I2C();
    i2c.setup({ scl : D5, sda: D4 });
    
    var b = new ArrayBuffer(4);
    var v = new DataView(b);
    
    setInterval( function() {
       var d = i2c.readFrom(0x40, 4);
        print(d);
        v.setUint8(1,d[0]);
        v.setUint8(0,d[1]);
        v.setUint8(3,d[2]);
        v.setUint8(2,d[3]);
        var temp =(v.getUint16(1)/65536)*165-40;
        var hum =(v.getUint16(3)/65536)*100;
        print(temp);
        print(hum);
    
      setTimeout(function(){
      i2c.writeTo(0x40, 0);
      },500);
    }, 1000 );
    
  • Thr 2019.08.22

    Nice compact little snippet @Alexandr

    Would you mind posting some output so that we may better visualize the solution while sampling please.

About

Avatar for Robin @Robin started