Electronic – arduino – Multiplexing I2C devices with MOSFETs

arduinoi2cmosfet

Ok, I understand similar questions have been asked in the past, please bear with me. Here is my problem, I have 2 I2C devices to be connected to a single I2C bus. They happen to be the same component and have the same hardware address. The address cannot be changed. My application requires the minimum possible latency. My plan is to use MOSFETs on the SDA line so that I can control when each of those devices is active. For each device there will be a MOSFET and by switching that on and off, I should be able to enable and disable them.

Would this work? If not, what would?

UPDATE: Ok, so I got my hands on MOSFETs (IRF520). I hooked up a digital pin on my arduino to the gate and the SDA lines to the source and drain (Arduino end to drain and device end to source). The thing didnt seem to be working, it gave me wrong values and would just stop entirely on bigger values. So I decreased the I2C frequency to 100kHz from 400kHz and it worked. I know the problem is in the FET because it works fine at 400kHz when the sensor is connected directly. Trouble is, I need it to work at 400kHz. What causes this issue and how can I rectify it? I was considering switching to the IRL540, would this help?

My messy diagram is as follows (I plan to repeat it for each sensor): enter image description here

Best Answer

Use a "bus switch" (i.e. NC7SZ384). They are more reliable for I2C switching, and have lower parasitic capacitance than a discrete MOSFET, and not that much more expensive.