Battery connected to A0 for voltage monitoring

Hi,

Odd question. I have a nano that is being powered by a 3.7v lithium battery via a DC step up to give 5v. To monitor the battery voltage i have it connected to A0. If I pull the USB lead (the 5v source) the nano still gets power through what i am assuming is the battery connected to A0. Is that possible? I have checked my wiring and can not see another way power is getting to the nano.

assuming i have not made a mistake with the wiring (i am currently taking it all apart to check) and this is possible, is there a way to prevent it? I only discovered it when the lithium battery went lot and the charging control circuit cut the power but the nano stayed on. How do i stop that?

the circuit is

Battery and solar panel connected to charging device. output of charge provide power to the DC setup and the usb form the step up connects to the nano. The battery + is connected directly to the nano A0. there are a couple of sensors connected to D6 & D7 but they are powered from the nano 5v pin.

Thanks

Ian…

Really need a schematic of how it is actually wired, and this is not a programming question.

Did you connect the battery directly to A0? I hope not. In that case, the Arduino can be parasitically powered through the I/O pin substrate diodes.

Is the negative/ground output of the boost converter connected directly to the negative battery input? If not, reading the battery voltage relative to the boost converter negative might not give the right value.

Also, if the solar is charging the battery you will be reading the charger voltage, not the battery voltage.

Internally, there's a protection diode going from A0 to Vcc, so yes, the battery is powering the Arduino that way, with a one-diode drop in voltage.

You can insert a P-channel mosfet to switch the connection to A0, but you will also probably need an N-channel mosfet (or NPN bipolar transistor) to switch the P-channel, driven by a GPIO port going high. And two resistors. You can't drive the P-channel gate directly from a GPIO port because they all go to ground when the Arduino is powered down, which would turn on the mosfet. You need the mosfet to be off unless the Arduino is powered up and outputing HIGH on the GPIO pin.

There may be a simpler way to do this, but measuring battery voltage has always turned out to be more complicated for me than I thought it should be. Most of the time, I've concluded I didn't really need to do that.

But you really should post your schematic. Otherwise we're all kinda guessing.

Edit: Probably need to move this to General Electronics.

Hi,

I have asked for this to be moved (as i cant see how to), sorry for posting in the wrong group.

The layout i have is attached. I am not worried too much about the voltage during the day when the sun is out, its more to monitor the voltage when there is no power coming form the solar panel so i can get an alert if its starts getting low.

The project will be monitoring a waste water tank, so the unit in the house will beep if the battery is low or it has not received data from the remote battery powered unit in a while.

Would a solid state relay connected between the battery and A0 that is closed by setting another pin to high when i check the sensors do the job, that way the battery is only connected to A0 whist i am checking the voltage? I am guessing that is what ShermanP is suggesting but in a more elegant manor. I am yet to understand what mosfets do, but i am guessing that it the same thing so that the battery is only connected to A0 when i want to check the voltage.

Thanks
Ian…

Connect 5V power to the 5V pin, VIN pin needs at least 6.5V to get 5V from the regulator. Do not connect voltage directly to the Arduino I / O pins if it is not powered. Put a 4.7k resistor between battery + and A0.

First, I agree with JCA34F that the 5V output of your boost converter should be connected to the 5V pin of the Arduino.

wskisoft:
Would a solid state relay connected between the battery and A0 that is closed by setting another pin to high when i check the sensors do the job, that way the battery is only connected to A0 whist i am checking the voltage? I am guessing that is what ShermanP is suggesting but in a more elegant manor. I am yet to understand what mosfets do, but i am guessing that it the same thing so that the battery is only connected to A0 when i want to check the voltage.

Yes, that would work. Something small like the CPC1017N should work ok. But I'll attach a drawing of a two-transistor circuit in case you want to try that.

What are you using as your charger module and your boost regulator? And do you have an idea of how much current your Arduino and sensors draw? I ask because there's another potential issue that may have to be dealt with, and that is whether your charger will properly terminate charging when the battery has been fully charged.

18650 battery voltage.jpg

18650 battery voltage.jpg

If the Arduino is powered by 5V and the battery is 4.2V max, why do you need a MOSFET? Connect the batt to A0 with a 4.7k resistor so no harm will come from connecting batt + to an unpowered Arduino (current into A0 will be limited to 4.4V / 4700 Ohms = 0.9mA). In normal operation, A0 current will be 0.0000mA (unmeasureable).

wskisoft:
If I pull the USB lead (the 5v source) the nano still gets power through what i am assuming is the battery connected to A0. Is that possible?

Yes, its entirely possible, its called phantom powering, and its likely to damage the Arduino, or even
destroy it through a phenomenon called "CMOS latch up".

10k resistor or so in series with A0 will prevent this causing damage.

If you look in the datasheet for any CMOS chip you'll see there's an absolute maximum voltage
rating for the pins which is almost always from -0.3V to Vcc+0.3V. This is saying the input
protection diodes must not be forward biased.

Large currents flowing through these diodes can send the entire chip into latch-up - you'll also often
find a spec called "latch-up immunity".

You'll know if a chip's gone into latch-up, it will get very hot, probably melt any IC socket
it is plugging into, and often be non-functional afterwards - though if you catch it quickly
and remove power it may survive. In very simplistic terms the whole chip acts like an SCR
that's been triggered.