1

Without getting into the specifics of the project, I have a situation where I'm having to electronically add and remove devices from the I2C bus due to addressing concerns. If I can just isolate one line (SDA) instead of both (SDA and SCL) it reduces the complexity and hardware costs.

The scenario (simplified) is I have enough I2C devices that they begin to share addresses. I'm hoping to electronically isolate them into banks and switch between the banks electronically. I was planning on leaving the clock line communicating to all devices, and only worry about switching based on the SDA line.

The question is: does the addressing information travel exclusively over SDA, and thus will isolating just the SDA line be enough to avoid address conflicts?

1
  • 1
    Without giving this a great deal of thought I'd remove the clock rather than the data. Why not just use an I2C bus multiplexor such as the TCA9548A, which exists to cater for address clashes?
    – joan
    Commented Feb 14, 2017 at 18:37

3 Answers 3

1

There are two I2C busses on the RPI. Bus 1 using pins 3 & 5 and Bus 0 using pins 27 & 28. If you are not using a hat with a EEPROM, I believe you can use Bus 0 for additional devices. This may simplify your problem.

0

I2C address conflicts can also be resolved by creating an additional I2C bus on open GPIO pins, see Raspberry PI Multiple I2C Devices.

1
  • 1
    This is a bit of a link-only answer. Please include the relevant details from the link. Commented Jun 27, 2019 at 5:03
-1

The direct answer to your question is that the address is encoded only on the SDA line. The SCL line tells devices when to check the level on SDA, but it carries no other data, including the address data.

But if you let one block of devices see the SCL line alternating while "disconnected" from the SDA bus in some way, those devices will still register the clock signals and read from their SDA pins. What they read will depend on what exactly you did to "disconnect" the SDA bus from that block. Could be high, low, or essentially random depending on what you did. So even though no address information is carried on SCL, you may still have your "disconnected" block of devices responding.

As noted in the comment by Joan, there are external ICs that can be used to change the apparent address of devices on a bus. That may be a better solution for you.

Edit

The comments seem to be vandalism at this point. Lest someone come along later and be confused by them, the schematic below illustrates the issue. The OP doesn't specify how or where he planned to disconnect. If SW2 is closed but SW1 is open, that would disconnect SDA from anything in the box. In that case the pull-up will keep the data pins on anything in the box high, and as the clock alternates, each device will read a high bit. If SW2 is open but SW1 is closed, that would also disconnect SDS from anything in the box. But now the data pins are not pulled-up and may take any state depending a on variety of factors including what's in the box (e.g. is there another point where the line is pulled-up?), how ideal the switch is, etc.

If there's confusion, perhaps it's that both the Pi (the master) and the devices in the box (the slaves) have SDA pins. The master's pin ultimately needs to be connect to a pull-up for the protocol to work. That's distinct from what happens on the slaves.

schematic

simulate this circuit – Schematic created using CircuitLab

8
  • "So even though no address information is carried on SCL, you may still have your "disconnected" block of devices responding." - I think this statement is incorrect and misleading.
    – tlfong01
    Commented Jun 5, 2019 at 0:12
  • In what way is in incorrect? Each time the SCL line cycles, every device reads its own data pin. That's the whole system.
    – Brick
    Commented Jun 5, 2019 at 0:34
  • You said the following - "What they read will depend on what exactly you did to "disconnect" the SDA bus from that block. Could be high, low, or essentially random depending on what you did." The point is that SDA line disconnected I2C device still has its SDA pin pulled high to Vcc. So it will always read High.
    – tlfong01
    Commented Jun 5, 2019 at 0:43
  • It depends on where the circuit is broken relative to the point where the pull-up is. That was my point. If you disconnect the device from the SDA line, the SDA line is presumably pulled high, but your now-disconnect pin isn't tied to that any more.
    – Brick
    Commented Jun 5, 2019 at 0:45
  • Yes, this I agree, It depends on how you "disconnect". (1) If you disconnect the SDA pin from bus's SDA line, connect it to ground, it will read Low. (2) If connect to Vcc, then will read High, (3) If SDA pin float, it will read anything. Original NXP/TI design is all I2C devices, matter master or slave, have SDA pins pull high. This SCL/SDA pull high is the crux of the matter of design principle. I suggest you to read TI/NXP on I2C protocol first, then we can have some common ground to discuss further. (Yes, I spent more than 1,000+ hours studying and experimenting I2C stuff.)
    – tlfong01
    Commented Jun 5, 2019 at 1:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.