• When testing this i2c scanner I figured out that there is a delay of 2sec before next scan.
    A full scan over the 120 id will take about 240 seconds.

    Is there a option to change this delay/timeout?

    function getSSMS() {
      return [Date().getSeconds(),Date().getMilliseco­nds()].join(':');
    }
    
    function isDeviceOnBus(i2c,id) {
          console.log(getSSMS(),id);
          try {
            return i2c.readFrom(id,1);
          }
          catch(err) {
            return -1;
          }
    }
    
    function detect(i2c,first, last) {
          first = first | 0;
          last = last | 0x77;
          var idsOnBus = Array();
          for (var id = first; id <= last; id++) {
            if ( isDeviceOnBus(i2c,id) != -1) {
              idsOnBus.push(id);
            }
          }
          return idsOnBus;
    }
    
    SCL = B6; SDA = B7;  // PICO
    I2C1.setup({sda:SDA,scl:SCL});
    
    setTimeout(function(){
      console.log('I2C detect as array:',detect(I2C1));
    },1000);
    
    // output
    53:67 0
    55:67 1
    57:69 2
    59:70 3
    1:71 4
    3:71 5
    5:71 6
    7:70 7
    9:68 8
    11:64 9
    ......
    
About

Avatar for MaBe @MaBe started