I want to turn on and off I2C Sensors with the Arduino Mega 2560.

I use one max. 0.4A NPN Transistor, which controls the Vcc line to the sensor.

When I plug my Arduino into my laptop and the sketch begins working everything is fine. The sensor is turned on and is working.

But when I set the Transistor Base to Low and cut the Vcc the sensor acts weird. The LED on the sensor breakout board shines very weak. So the sensor/breakout board is getting electricity from somewhere else; probably from the I2C connections.

Arduino Sensor Power Control Circuit

Same results with this small experiment:

  1. Breakout board directly connected to the Arduino (without Transistor)
  2. Vcc-3.3V pin wire disconnected from the Arduino female pin

How can i properly turn on and off an I2C sensor with an Arduino?

Do I have to use additional transistors for every I2C line? Are better circuit solutions available or maybe a software solution?

How should I design my circuit and my software if I have multiple I2C sensors connected to my Arduino and I want to use them independently from each other?

Used hardware: Arduino Mega, Sensor Breakout Board

Software excerpt for power control:

void setup() {

    pinMode(7, OUTPUT);
    digitalWrite(7, HIGH);   


    digitalWrite(7, LOW);    

  • 1
    Why not use MPU6050 low power mode? The power LED and power regulators on the Arduino board draws more current. Commented Sep 6, 2016 at 20:01
  • 1
    Remove the LED and put it into low power mode as suggested.
    – KIIV
    Commented Sep 6, 2016 at 20:04
  • Trying to understand your real requirement I believe what you wish to achieve is not power down the sensor but to share the same I2C line among multiple ones: am I correct? If that's the case please update your question accordingly, because otherwise you'll keep getting the same answers over and over: power your sensor down, don't turn it off Commented Sep 6, 2016 at 22:43
  • The Question is: "How to turn I2C Sensors on and off with an Arduino Mega 2560?" How to cut off their electricity, how to turn them completely off and on, controlled by the Arduino. How to turn multiple different I2C Sensors completely on and off, independent from each other, using the Arduino. Commented Sep 7, 2016 at 6:55

2 Answers 2


The SDA and SCL pins have pull up resistors on them. So their voltage is 5V. By disconnecting Vcc on the sensor you are running the sensor out of spec. since the voltage on the SDA and SCL pins exceed Vcc.

Most chips have clamping diodes. So the chip is clamping the 5V on the I2C pins to Vcc. So you are powering the chip through the pull-up resistors on the I2C pins.

This would explain why the power led is lit, but not as bright.


if your sensor does not consume more that 20ma, you can power it's GROUND pin with an arduino pin by using pinMode(sensor, OUTPUT), analogWrite(sensor, 255) : at that stage no power flows to the sensor since all its pins are high. When you want to power back the sensor, you need to lower the value of "255" to 0 , if your sensor uses 5v or to around 40 , if your sensor uses 3.3v. I have been using this system for a while without any problem. You might need a small delay(50), to give time for the sensor to power up.

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.