now using a version that returns an array of ids
var isDevice = function isDeviceOnBus(i2cBus,id) { try { return i2cBus.readFrom(id,1); } catch(err) { return -1; } }; var detect = function(i2c,first, last) { first = first | 0; last = last | 0x77; var idsOnBus = Array(); for (var id = first; id < last; id++) { if ( ! isDevice(i2c,id) ) { idsOnBus.push(id); } } return idsOnBus; }; I2C1.setup({sda: D4, scl: D5} ); console.log(detect(I2C1));
@MaBe started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
now using a version that returns an array of ids