Closed chinswain closed 6 years ago
@chinswain What value resistors are you using for your pullups? I have not had any problem using both i2c bus's at the same time.
I use about 2.4k
You are showing one bus busy, does happen more often? Does is happen on both bus's?
This code interleaves both bus's
uint8_t present[16][2]; // array to hold presence status bit.
void check(TwoWire * xWire, uint8_t addr, uint8_t bus){
bool found = false;
xWire->beginTransmission(addr);
found = (xWire->endTransmission(true)==0);
uint8_t byteOffset = addr / 8;
uint8_t bitOffset = addr % 8;
if (found) present[byteOffset][bus] = present[byteOffset][bus] | (1<<bitOffset);
else present[byteOffset][bus] = present[byteOffset][bus] & ~(1<<bitOffset);
}
TwoWire Wire1(1);
void setup(){
Wire.begin(); //use default pins
Wire1.begin(19,23);
for( uint8_t addr=0; addr<128, addr++){
check(&Wire,addr,0);
check(&Wire1,addr,1);
}
Serial.println(" devices on Bus 0");
for(uint8_t addr = 0; addr<128), addr++){
uint8_t byteOffset = addr /8;
uint8_t bitOffset = addr % 8;
If(present[byteOffset][0] & (1<<bitOffset)) { // found it
Serial.printf("%02x ",addr);
}
else {
Serial.print(".. ");
}
if((addr & 0xf)==0xF) Serial.println();
}
Serial.println(" devices on Bus 1");
for(uint8_t addr = 0; addr<128), addr++){
uint8_t byteOffset = addr /8;
uint8_t bitOffset = addr % 8;
If(present[byteOffset][1] & (1<<bitOffset)) { // found it
Serial.printf("%02x ",addr);
}
else {
Serial.print(".. ");
}
if((addr & 0xf)==0xF) Serial.println();
}
}
Chuck.
Hi Chuck, finally got myself a scope, one of the slaves was malfunctioning - replaced with identical part and no more time outs.
Yea!
Hardware:
Board: LOLIN32 Core Installation/update date: Main + latest stickbreaker patched i2c files IDE name: Arduino IDE Flash Frequency: 40Mhz Upload Speed: 115200
Description:
Just testing the second i2c on the ESP32 with the i2c changes, seems there's an issue having both active? I've modified the scanner example to scan both, getting a busy bus error. No issues when scanning only one bus in the loop, even when beginning both.
Sketch:
Debug Messages: