• Hi - don't add:

    var i2c = new I2C();
    i2c.setup({ scl : D25, sda: D26 });
    

    However I doubt that'd have had an effect.

    Because they are already in the code lower down. "WHO_AM_I failed" means that it couldn't communicate with the device via I2C (it asked the device what it was, and it didn't return with the code 0x15).

    You could try just:

    var P = {
      HRM_SCL : D25,
      HRM_SDA : D26
    };
    
     var i = new I2C();
      i.setup({scl:P.HRM_SCL,sda:P.HRM_SDA});
      function r(a,n) {
        i.writeTo(87,a);
        return i.readFrom(87,n);
      }
    print("WHO_AM_I", r(0xFF,1));
    

    And see if you can get it to print something that's not 255 by checking your wiring. That'd be the best way to start.

About

Avatar for Gordon @Gordon started