I2C Data Signal – How to Block or Allow an I2C Data Signal to Pass to Another Device

atmegadigital-logicswitches

I have three devices which I'm working on and one of them needs to control i2c communication between the other two.

Each of the devices is based on an AtMega or AtTiny chip. The Controller (based on some external input not known to either the Master or Slave) needs to be able to decide whether or not to pass on the i2c signals to the Slave.

I'm assuming you can just 'block' the data signal (no need to stop the clock signal being passed through) in some way. I've looked at devices like Single Fet Bus Switches but I wonder if that is the best way or not.

The setup looks like: Master –i2c-> Controller –i2c-> Slave

Best Answer

While pulling the clock line low might work for some instances, it highly depends on how the master and the slave are coded. It might result in failed arbitration attempts or freezing due to unexpected clock stretching.

There are two simple options. One, would be to connect the slave's Clock Line, through a transistor, as you would a simple level translating setup. But instead of connecting the transistor to always on, on a different voltage, the base will be connected to your controller's enable pin. If on, the SCL line is connected to the slave, allowing it to see the Clock Pulses. If off, the slave doesn't see any pulsing on the clock line, so sits idle, and the master doesn't see anything different on the line.

The other options are an i2c buffer, bus expander, or switch, with an enable pin. Some of those tend to require an extra i2c address byte to allow communication to the other side.

schematic