Input vs Output Current Consumption

Status
Not open for further replies.

parastep

Member
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?
 
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-How-to-disable-a-pin
 
Last edited:
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?
 
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.
 
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!
 
Status
Not open for further replies.
Back
Top