| 35 | } |
| 36 | |
| 37 | void scanBus() |
| 38 | { |
| 39 | Serial.println("Scanning..."); |
| 40 | |
| 41 | unsigned nDevices{0}; |
| 42 | for(uint8_t address = 1; address < 127; address++) { |
| 43 | // The i2c_scanner uses the return value of |
| 44 | // the Write.endTransmisstion to see if |
| 45 | // a device did acknowledge to the address. |
| 46 | Wire.beginTransmission(address); |
| 47 | auto error = Wire.endTransmission(); |
| 48 | |
| 49 | WDT.alive(); // Second option: notify Watch Dog what you are alive (feed it) |
| 50 | |
| 51 | if(error == 0) { |
| 52 | Serial << _F("I2C device found at address 0x") << String(address, HEX, 2) << " !" << endl; |
| 53 | nDevices++; |
| 54 | } else if(error == 4) { |
| 55 | Serial << _F("Unknown error at address 0x") << String(address, HEX, 2) << endl; |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | Serial << nDevices << _F(" I2C devices found.") << endl << endl; |
| 60 | } |
| 61 | |
| 62 | void init() |
| 63 | { |
nothing calls this directly
no test coverage detected