# Analog Mux as Cheap I2C Mux?

Just looking to have two devices on a single bus with the same address. There are many I2C multiplexers available, but they seem to cost ~4x what a 2x 2:1 analog multiplexer costs.

Any reason I can't use an analog multiplexer for I2C running a 100kHz bus?

For example a TI TS3A5223RSWR is 0.63 cents, and based on the data sheet, supports bi-directional analog signals with a small ~1 Ohm impedance.

• I will also note I did not perform a comprehensive search of I2C chips, but the few I looked at seemed to be in the ~$1.5-$2 range. – MadHatter Mar 11 '18 at 7:17
• If you're running at low speed and your I2C bus can tolerate the extra capacitive load (115pF?), maybe it would work in this case. Might have to tweak the I2C pullup resistor values; would be worth checking performance with an oscilloscope. If I recall correctly I2C supports up to 400pF total bus capacitance. – MarkU Mar 11 '18 at 7:58
• @MarkU I was looking at BW and impedance, I didn’t even think about bus capacitance! Great point. I’ll drop the resistor values a bit, and of course check on a scope. – MadHatter Mar 11 '18 at 15:31

Analog multiplexers work just fine for I²C signals (if you keep the impedance and parasitic cpacitance small enough, which is usually not a problem).

I²C multiplexers are more complex because they are controlled through the I²C bus itself. You need one if you do not have a spare GPIO pin to control it.

• The point about I²C multiplexers having port selection controls that are programmable via the I²C bus itself is exactly why they cost more ... but can be an extremely valuable feature in several instances. One is if the mux needs to be remotely located from the controlling MCU it removes the need to route a GPIO to the far location along with the I²C bus. Another application is when there is a system structure where two multiplexers are daisy chained and it would be inconvenient to have to also mux a GPIO control bit for the second I²C mux. – Michael Karas Mar 11 '18 at 9:20
• Muxes are great when one segment is going off board, and could compromise the operation of on-board segments by capacitance/noise/shorts. However when the mux is addressed by the same I2C bus that goes off board, a fault on the switched leg (eg a short) blocks the whole bus preventing the mux being changed, and thus fatally blocking the whole I2C. Using the hardware reset pin on muxes is a good idea where any of the buses might be faulty. – Henry Crun Mar 12 '18 at 5:19

You don't need expensive low-R analog switches. Simple parts like 74HC4066 and 74HC4053 or the single gate versions work just fine for $0.11 - and you get 2 or 3 more switches to use for other things. (But see diode solution for$0.015...)

You can just switch the SDA line alone, and leave SCL common to all chips. Thus you only need a single mux or switch.

Make sure to have a high value (100k) pullup at each chip in addition to the bus pullup.

(this works because the start condition is SDA falling. If SDA is kept high, the chip will never see START)

"... they'd all made a big mistake coming down from the trees in the first place, and some said that even the trees had been a bad move, and that no-one should ever have left the oceans."

Using tri-state port pins for _EN1 and _EN2, you set the pin to OUTPUT-HI to BLOCK the slave, and INPUT-no-pullups to enable the slave. A BAW56 dual diode costs \$0.015. Who needs more than a diode anyway?

SCL is common and unswitched. Obviously the selection can only be changed when the bus is idle.

If this is a bit rich for you, the 2k2 master pullup can be omitted, and the 22k resistors replaced by 2k2. As one of the _EN lines is always HI, its resistor will act as the bus pullup. Now you are down to 2 resistors and 1x BAW56 vs 3 resistors+1xIC for the analog switch solution.