add bus 2 scanning

pull/252/head
alanbjohnston 3 years ago committed by GitHub
parent 19d9f8018d
commit 49bb44c5f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -4454,7 +4454,7 @@ void prompt_for_input() {
byte error, address; byte error, address;
int nDevices; int nDevices;
Serial.println("Scanning..."); Serial.println("Scanning I2C Bus 1");
nDevices = 0; nDevices = 0;
for(address = 1; address < 127; address++ ) for(address = 1; address < 127; address++ )
@ -4467,7 +4467,7 @@ void prompt_for_input() {
if (error == 0) if (error == 0)
{ {
Serial.print("I2C device found at address 0x"); Serial.print("I2C device found at bus 1 address 0x");
if (address<16) if (address<16)
Serial.print("0"); Serial.print("0");
Serial.print(address,HEX); Serial.print(address,HEX);
@ -4477,21 +4477,55 @@ void prompt_for_input() {
} }
else if (error==4) else if (error==4)
{ {
Serial.print("Unknown error at address 0x"); Serial.print("Unknown error at bus 1 address 0x");
if (address<16) if (address<16)
Serial.print("0"); Serial.print("0");
Serial.println(address,HEX); Serial.println(address,HEX);
} }
} }
if (nDevices == 0) if (nDevices == 0)
Serial.println("No I2C devices found\n"); Serial.println("No I2C devices found on bus 1\n");
else else
Serial.println("done\n"); Serial.println("done\n");
delay(5000); // wait 5 seconds for next scan delay(5000); // wait 5 seconds for next scan
}
Serial.println("Scanning I2C Bus 2");
nDevices = 0;
for(address = 1; address < 127; address++ )
{
// The i2c_scanner uses the return value of
// the Write.endTransmisstion to see if
// a device did acknowledge to the address.
Wire1.beginTransmission(address);
error = Wire1.endTransmission();
if (error == 0)
{
Serial.print("I2C device found at bus 2 address 0x");
if (address<16)
Serial.print("0");
Serial.print(address,HEX);
Serial.println(" !");
nDevices++;
}
else if (error==4)
{
Serial.print("Unknown error at bus 2 address 0x");
if (address<16)
Serial.print("0");
Serial.println(address,HEX);
}
}
if (nDevices == 0)
Serial.println("No I2C devices found on bus 2\n");
else
Serial.println("done\n");
}
Serial.println("complete"); Serial.println("complete");
break; break;

Loading…
Cancel
Save

Powered by TurnKey Linux.