jesusangel
Active member
Hi, I have to move my project from teensy 3.2 to 4.0, I use an i2c device that sometimes is 0x27 address sometimes 0x3F, to use only one firmware I coded with i2c_t3.h library to scan device 0x27 and checking status I know if there is a device at this address, if not I supose is in the other, but in teensy 4.0 Wire.h lilbrary there is no status cmd to do it so I have to fix code the address and compile 2 different firmwares.
There is a way in Wire.h to scan devices like i2c_t3.h so some way check is something has responded after a transmission?
Thank you in advance
Code:
uint8_t target = 0x27;
Wire.begin(I2C_MASTER, 0x00, I2C_PINS_18_19, I2C_PULLUP_EXT, I2C_RATE_400);
//Wire.begin();
Wire.beginTransmission(target); // slave addr
Wire.endTransmission();
switch (Wire.status())
{
case I2C_WAITING:
if (DEBUG) {
Serial.println("Detectada lcd en 0x27");
}
lcd.reinit(0x27);
break;
case I2C_ADDR_NAK:
if (DEBUG) {
Serial.println("Detectada lcd en 0x3F");
}
lcd.reinit(0x3F);
break;
default:
break;
}
There is a way in Wire.h to scan devices like i2c_t3.h so some way check is something has responded after a transmission?
Thank you in advance