I'm using a PIC16LF1554 with a simple soil moisture sensor to remotely monitor houseplants. The sensor circuit will be powered by a coin cell and will spend most of its time asleep. It will wake periodically (maybe three times daily) to take a reading via ADC, transmit to an always-on master via nRF24l01+ and then go back to sleep. This is a hobby/learning project, not a commercial enterprise.

My question is about minimising current consumption in sleep mode, about which the datasheet says:

To minimize current consumption, the following conditions should be considered:

  • I/O pins should not be floating
  • External circuitry sinking current from I/O pins
  • External circuitry sourcing current from I/O pins
  • Current draw from pins with internal weak pull-ups
  • Modules using 31 kHz LFINTOSC

I'm comfortable with all but the first item, but I have a number of I/O pins that I'm not using, so I've not connected them to anything in the PCB I've designed (maybe that was stupid). The datasheet goes on to say:

I/O pins that are high-impedance inputs should be pulled to VDD or VSS externally to avoid switching currents used by floating inputs.

So, my question. Is it ok to configure my unconnected I/O pins as outputs and set them LOW (or HIGH)? Would that result in any unnecessary current draw?

  • 1
    \$\begingroup\$ iirc, your approach of driving unused outputs low is the recommended one. You might also want to consider putting pull-down resistors on all inputs - for example, SPI slaves tend to leave their data out pin in a high-impedance state when not transmitting. \$\endgroup\$
    – markt
    Jan 4, 2015 at 10:34

1 Answer 1


Digital inputs are designed to be either high or low. If they are left to float in the middle, they will draw larger amounts of current on the input part of the circuit. This is what you want to avoid for best power savings.

If you want a better understanding of this put a ammeter on your PIC and connect a potentiometer to vary an input pin. As you vary the voltage into the middle of the range, you will see an increase in current. If you were to do this for all the pins, it would add up to quite a bit of current.

Fortunately, driving an output with no external load (i.e. an unconnected pin) requires no current at all. CMOS circuits only consume significant power when switched or directly loaded.

Therefore, you should set all unconnected I/O pins as outputs. It generally doesn't matter whether you drive them high or low. In some microcontrollers, one direction will give a slightly better power savings, so perhaps some testing is would be useful. (I don't recall this being an issue with the PIC family though).

Note also, that in some PIC devices, you have registers that control outputs that don't actually exist on the chip. In reality, they exist on the silicon die, but are not bonded out to the package. For the best power savings, you should drive those out as well, since leaving them floating will increase power.

As an aside, the typical way to do this is to put an ammeter in line with your power and see how low you can get it. Microcontrollers tend to have a lot of options that draw power, and it is easy to miss a couple. You should be able to get very close to the datasheet numbers.

  • \$\begingroup\$ Ok thanks, but I'm intrigued by these "registers that control outputs that don't actually exist" - can you give me an example? Where would I find out about these? Is it not in the datasheet? \$\endgroup\$ Jan 4, 2015 at 13:09
  • 1
    \$\begingroup\$ Microchip has been better about these lately. An example that is non-microchip is from the ST part stm8l101. From the datasheet: STM8L101F3U6ATR, STM8L101G2U6ATR and STM8L101G3U6ATR part numbers (devices with COMP_REF pin), all ports available on 32-pin packages must be considered as active ports. To avoid spurious effects, you have to configure them as input pull-up. A small increase in consumption (typ. < 300 μA) may occur during the power up and reset phase until these ports are properly configured. \$\endgroup\$
    – caveman
    Jan 4, 2015 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.