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);
...
}