0

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

    ...

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

    ...
}
  • 1
    Why not use MPU6050 low power mode? The power LED and power regulators on the Arduino board draws more current. – Mikael Patel Sep 6 '16 at 20:01
  • 1
    Remove the LED and put it into low power mode as suggested. – KIIV Sep 6 '16 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 – Roberto Lo Giacco Sep 6 '16 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. – William Roy Sep 7 '16 at 6:55
1

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.

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.