Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 6 of 6

Thread: Input vs Output Current Consumption

  1. #1
    Junior Member
    Join Date
    Jul 2016
    Posts
    5

    Input vs Output Current Consumption

    Hi everyone, I was wondering whether setting pins to input or output would be better in terms of extending battery life of the Teensy.

    On the Arduino digital pins tutorial, it says that input pins make very small demands on the circuit, and it seems like having a pull down resistor would also reduce the current consumption of peripheral devices. On the other hand, it states that output pins are in a low-impedance state, so they can provide a substantial amount of current to other circuits.

    So if I have the 3V pad of a sensor connected to a Teensy digital pin, and want to reduce current consumption when the sensor is not being used, would it be better to set the digital pin as an output LOW while not in use, or as an input pulldown (with output HIGH while in use)? Or perhaps as output LOW with a 1K resistor between the digital pin and the 3V pad? (It also seems that even when using output LOW to power down the sensor, there is quite a bit of current leaking through and reducing battery life)

    Additionally, for unused pins the Teensy page says to set them as output, but how does this extend battery life?

  2. #2
    Senior Member
    Join Date
    Apr 2013
    Posts
    1,936
    The setting output advice applies to unconnected pins that have inputs active (Arduino Uno, Teensy2) since they will tend to float and act as antenna, jittering across the high/low level where each transition draws current. For a T3.x you have the option of fully disabling the pins and all pins start in that state from boot (so don't worry about unused pins on T3 as long as your code does nothing to them).

    Unfortunately I don't believe there is a yet a simple pinMode(disable) so you need to directly write to a register to disable a pin if you have used it for something in your code already, and google is not currently finding the reference I'd seen to that in the forum at the moment.

    Edit, found one of the places - see https://forum.pjrc.com/threads/24087...-disable-a-pin
    Last edited by GremlinWrangler; 07-16-2016 at 02:17 PM. Reason: Found link

  3. #3
    Junior Member
    Join Date
    Jul 2016
    Posts
    5
    Thanks for the response! I tried disabling the sensor power pin using the code CORE_PIN23_CONFIG = 0; but that set pin 23 to about 2V. Is this expected? Wouldn't less current be wasted when the power pin is set to LOW at 0V so its the same voltage as the ground pin? Or does disabling the pin prevent it from sourcing or sinking current?

  4. #4
    Senior Member
    Join Date
    Apr 2013
    Posts
    1,936
    Disabling the pin should disconnect it as much as solid state can and float it, so with nothing connected it will drift to a voltage averaging those wires around it due to capacitve coupling effects. A test is to see what happens when you meter 3.3V to pin and ground to pin. If they add up to 3.3V then it's being driven to 2V and something is amiss. If they total to smaller than 3.3V then you are seeing leakage of some sort. If it really matters you could also try a low current meter and playing around with pulling it high and low and watching the actual measure current draw for changes.

  5. #5
    Junior Member
    Join Date
    Jul 2016
    Posts
    5
    Hi GremlinWrangler,

    It seems like the cause of the was the input_pullup I2C pins 29 and 30 connected to the sensor. In my code I now set all the digital pins connected to the sensor ground, 3V, and SDA/SCL to disabled when switching off the sensor, and the voltages now all read zero when off.

    I have the exact same setup with an OLED screen, and to turn off the screen I simply write the pin connected to its 3V pad to low, while the ground is connected to the ground pin of the Teensy. When turned off using digitalWrite for the pin connected to the 3V pad to LOW, there is no floating voltage on the OLED and everything measures 0V. The only difference is that the sensor I2C is setup:

    Wire1.begin(I2C_MASTER, 0x00, I2C_PINS_29_30, I2C_PULLUP_INT, I2C_RATE_100);

    and the OLED is setup:

    Wire.begin(I2C_MASTER, 0x00, I2C_PINS_18_19, I2C_PULLUP_EXT, I2C_RATE_100);

    and the OLED does not have pullup resistors set or connected.

    I'm curious, why do the I2C lines cause the voltage of the 3V and ground pads of the sensor to be driven higher? Sorry for the obvious question, this is my first arduino project!

  6. #6
    Senior Member
    Join Date
    May 2015
    Location
    USA
    Posts
    734
    > a simple pinMode(disable)

    I'd like to see this implemented.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •