I created a project to monitor 1S LiPo battery, as the schematic attached. It was strange that even removing the Arduino USB power, it remains with the LED ON high, but apparently not working.
I measured the 5V output, only with the battery connected to analog Pin (as in the schematic), without the 5V USB power, and it has about 3V, so do not turn off the Arduino completely.
I thought this happened only with the analog ports, but with the digital ports the same thing happens.
At ATmega328P datasheet, it appears that the I/O ports are connected to 5V through a diode, as attached picture.
To completely turn off the Arduino, I would have to remove the battery from the I/O port. To resolve this, I would have to use a relay or a transistor or even a switch. Someone suggests another alternative, preferably by code?
There is also possible damage to the positive clamping diode in that situation as the diodes are only rated for like 1 mA max.
I had one project where I needed a manual turn-on but auto turn off under program control. I utilized a $1 5vdc single coil latching relay. Upon manual turn on the digital output is set high to latch the power on and when wishing to turn off a low output to the digital output pin turns all power off. A nice feature of this circuit is that it draws 0 current in steady state, on or off, only drawing current during transitions.
@paul_B
as it is a 3.7 volt battery .... Why not?
How else can you monitor a 3.7V battery?
@tiagomitsuo
I have read more stories of powering the arduino over the pins. What typically happens is that "part of the board is working"
Sometimes that works out great sometimes ... well yes smoke came out.
As you do not want your battery to drain it is a good idea to have a transistor so the arduino can switch of the battery monitoring cirquit on and off.If it is default off you avoid unnecessary draining the battery.
By connecting it with a due degree of isolation as you would when monitoring any self-powered (or externally-powered) input - generally a resistor if nothing else. As you go on to say ...
Jantje:
I have read more stories of powering the Arduino over the pins. What typically happens is that "part of the board is working"
Sometimes that works out great sometimes ... well yes smoke came out.
As you do not want your battery to drain it is a good idea to have a transistor so the Arduino can switch of the battery monitoring circuit on and off. If it is default off you avoid unnecessary draining the battery.
The question is of course, "who monitors the monitor?" Will the battery being monitored also be powering the monitoring circuit itself, and if not, what will?