AnalogRead powers Arduino while measuring voltage battery pack

My battery is about 4 Volts, I use a dc booster to get it to a nice clean 5 Volts. To check if my battery is drained I want to measure it's voltage with an analog pin, so I connected the + of the battery directly to one of the pins. If I remove power from the Vcc pins of the arduino, it does not shut off: it drains power through the analog pin. This is not what I want. I fixed it by adding a 10k resistor between the + of the battery and the analog pin. It does leave me with questions:

  • was it bad to connect the battery directly to the analog pin, or is there only a problem if the Vcc gets no power ?
  • is there a more official solution to this ? is there a solution without the 10k resistor ?

Cheers,

Jack

It is very bad to apply power to the input of any unpowered IC. It is what is known as parasitic powering and can damage the IC.
The simple soloution is do not do it at all.

Thanks to hear it confirmed, I suspected something like that. But as long as the chip gets power I can connect the battery directly to an analog pin.

If I shut down power, the 10k resistor would be the right way to prevent parasitic powering?

I might actually build the on off switch in such a way that it also disconnects the wire to the analog pin, but I have a few projects where this is not the case.

CaptainJack:
Thanks to hear it confirmed, I suspected something like that. But as long as the chip gets power I can connect the battery directly to an analog pin.

If I shut down power, the 10k resistor would be the right way to prevent parasitic powering?

That can limit current to a safe value but still a small amount of current will continue to flow and if left long enough could discharge the battery below a safe value is you are using say a Li-Po cell.

I might actually build the on off switch in such a way that it also disconnects the wire to the analog pin, but I have a few projects where this is not the case.
Yes, a simple DPST switch would allow turning off both the power from the battery to the booster and also open the battery to analog input pin and the method I would use. using a battery powered project with no way to remove power from the 'system' can be a risk for the battery.