user25974: 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.


Same results with this small experiment: 

Breakout board directly connected to the Arduino (without Transistor)
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);   

    ...

    delay(10000);                       
    digitalWrite(7, LOW);    

    ...
}


user2881: 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. 

25974: <p>I want to <strong>turn on and off</strong> I2C Sensors with the Arduino Mega 2560.</p>

<hr>

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

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

<p><strong>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.</strong></p>

<p><a href="https://i.stack.imgur.com/3J9Vw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3J9Vw.png" alt="Arduino Sensor Power Control Circuit"></a></p>

<hr>

<p>Same results with this small experiment: </p>

<ol>
<li>Breakout board directly connected to the Arduino (without Transistor)</li>
<li>Vcc-3.3V pin wire disconnected from the Arduino female pin</li>
</ol>

<hr>

<p>How can i properly turn on and off an I2C sensor with an Arduino?</p>

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

<p>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?</p>

<hr>

<p>Used hardware: Arduino Mega, Sensor Breakout Board</p>

<hr>

<p>Software excerpt for power control: </p>

<pre><code>void setup() {

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

    ...

    delay(10000);                       
    digitalWrite(7, LOW);    

    ...
}
</code></pre>
 2881: <p>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. </p>

<p>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. </p>

<p>This would explain why the power led is lit, but not as bright. </p>
