I just asked this question trying to find out if having a powered I2C slave in an ISP bus during MCU (Attiny) programming would be problematic. Apparently it would, so I need to isolate the slave(s) from the bus temporarily.

I can't just power down the slave(MPU-6050) because its inputs are not tolerant to 3.3V when its Vcc=0V.

I also found this interesting related question, but the solutions proposed do not work for me (I have limited board space and specific ICs availability are a problem for me for this projects budget).

I'm really trying to steer away from a jumper/DIP switch solution so I'm considering active ones. Here it goes:

Use a discrete bi-directional level shifter

enter image description here

But instead of a High and Low voltage side, I'd try something like this:


simulate this circuit – Schematic created using CircuitLab

When Attiny is programming, its outputs are high-impedance, R5 turns M3 off. C1 is mainly to prevent glitches on the pin from turning M3 back on again.

R7 then turns M1 and M2 off, and SCK/MOSI can "bounce" freely without disturbing the I2C slave(s).

Upon booting, the Attiny turns M3 on, providing power to the I2C bus.

Would this work? Am I overlooking or overcomplicating something?

  • \$\begingroup\$ I think you are saying that your attiny has a VCC of 0V, sometimes (powered off?) What happens when it is powered off and you have 3.3V to R5 to R6 to your off-mode attiny's gpio pin? Won't that flow through the protection diode to the VCC=0 rail? Is it low enough to be okay? (Doesn't sound like a lot.) But you may have close to 1V on your pfet gate, too. \$\endgroup\$
    – jonk
    Sep 16, 2016 at 21:09
  • \$\begingroup\$ The Attiny is always powered in these scenarios. I just need to prevent any voltage above 0.5V on the I2C bus when the Tiny is being programmed. The slave can be powered off or not if I isolate the I2C bus. I'm sorry, I'll rephrase the question. \$\endgroup\$
    – Wesley Lee
    Sep 16, 2016 at 21:12
  • \$\begingroup\$ Sorry about my misunderstanding. \$\endgroup\$
    – jonk
    Sep 16, 2016 at 21:13
  • \$\begingroup\$ @Wesley Is this for a prototype, or production? Is cost a significant factor? Same question for PCB real estate? \$\endgroup\$ Sep 16, 2016 at 21:55
  • \$\begingroup\$ @NickAlexeev -- I'm making 5~10 units.. PCB real estate is a factor, cost is not much of a factor except for the fact that I live in Brazil and if I need any specific IC I have to pay courier + import taxes, so a 2USD IC from Mouser ~= 100USD cost for me (in this case I'd just use jumpers). That's why I'm preferring a discrete solution. Also using this situation to design and learn something maybe. \$\endgroup\$
    – Wesley Lee
    Sep 16, 2016 at 22:05

1 Answer 1


You have the right idea, but I think your circuit can be simplified.

In the idle condition both SCL and SDA should be high, so connect R1 and R2 directly to +3.3V. M1 and M2 have body diodes that must not be allowed to transfer logic low from the ATTiny to the MPU-6050, so you need to swap their Source and Drain connections.

The Gates of M1 and M2 can be driven directly from a GPIO pin, then M3 and R7 are not required. C1 and R5 now connect to Ground instead of +3.3V, and the GPIO pin pulls high to enable the I2C connection.

An I2C 'Start' condition is defined as SDA going from high to low while SCL is high. A slave device shouldn't drive SCL unless it is busy and wants to slow down the data transfer, so SCL should be safe from interference unless the MPU-6050 sees a Start condition while it is busy doing something else. With SDA held high (by R2 with M2 switched off) the MPU-6050 won't see a Start condition so it should leave SCL alone, and M1 and R3 are not required.


simulate this circuit – Schematic created using CircuitLab

  • \$\begingroup\$ Nice, I didn't realize I didn't need M3. I think that for an extra NFET+Resistor though I'll add isolation on the SCL bus too. R1~R4 will probably be an array, so the extra resistor doesn't affect anything and putting M1 back should also give me a prototype for a discrete I2C switch/"mux" so I'll try that. Good point about the body diodes and I2C idle condition. For some reason I thought it would be low after turning the devices off -- but again, you made me realize I don't even need to turn them off, just make them idle. \$\endgroup\$
    – Wesley Lee
    Sep 17, 2016 at 23:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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