Go Down

Topic: Lithium battery (Read 4919 times) previous topic - next topic

guillaume55

Hello,
I want to use a lithium battery with an atmega (without arduino board) but I don't know how I can read the voltage of the battery because it's the same who power the board. I've read that I can set the analog ref to 1.1v but can I do after
The atmega powers a gps who works with a max of 3.6v and the battery can deliver 4.2v to 3v. I've seen that I can use an LM3641 (http://www.ti.com/lit/ds/symlink/lm3641.pdf) but I don't know if it's the best way.
I don't know how I can limit the battery discharge anf if I can use the battery when it's charging or if I muss deconnect it.
I'm not lock on a lithium battery but I don't have a lot of space and I want a waterproof case and that we don't have to open the case to charge the batteries.
Thanks
Guillaume

raschemmel

#1
Apr 19, 2016, 04:36 pm Last Edit: Apr 19, 2016, 06:46 pm by raschemmel
google "arduino measuring battery voltage"

We are here to help, but really, let's try not to be lazy ok ? You know Google is available.
Please restrict your forum questions to ones that are not so easily resolved with a google search. If after trying that , you still have questions, feel free to ask. We would prefer not get  questions like 'What time is it ?"


Please take a moment to Google your topic with the word "arduino" at the beginning of the search string before posting. Most questions can be answered quickly this way.
If after trying this you still have questions, then ask.

ie:

Google Search: arduino measuring battery voltage


Quote
The atmega powers a gps who works with a max of 3.6v and the battery can deliver 4.2v to 3v. I've seen that I can use an LM3641 (http://www.ti.com/lit/ds/symlink/lm3641.pdf) but I don't know if it's the best way.
I don't know how I can limit the battery discharge anf if I can use the battery when it's charging or if I muss deconnect it.
I'm not lock on a lithium battery but I don't have a lot of space and I want a waterproof case and that we don't have to open the case to charge the batteries.  
Quote
I don't know how I can limit the battery discharge anf if I can use the battery when it's charging or if I muss deconnect it.  
The first concern when measuring battery voltage of the battery powering the ATmega328 is whether or not it is less than 5V. Obviously you cannot use a battery less than 5V to measure the battery because the default analog reference is Vcc so the measurement would be inaccurate. You would need to change the analog reference to
INTERNAL and use a voltage divider to reduce the measured voltage to the midpoint between 0 V and 1.1 volts or at most to 75% of that range.

Also, as far as can you measure it while your charging it , no. You can't because you have a source in parallel with a load. You have to disconnect the source (charger) to measure the load (battery). (normally a battery is a source but when it is being charged it is a load)




You can disconnect the battery from the charger using a SPST switch.
Quote
The atmega powers a gps who works with a max of 3.6v and the battery can deliver 4.2v to 3v. I've seen that I can use an LM3641 (http://www.ti.com/lit/ds/symlink/lm3641.pdf) but I don't know if it's the best way
Only you can decide whether you need to use that chip. If you are capable of understanding the datasheet and have the chip I would say try to use it. Is it the best way ? The best way is to have two batteries and charge one while using the other and switch from bat-A to bat-B using an SPDT relay. Then you can measure the battery being used because it is not being charged and use a flag to keep track of which battery is being charged. Your code would have to account for the possibility of the arduino resetting at the moment the relay switches. The boolean flags would need to be stored i EEPROM to avoid loosing them on reset. If you add a large enough electrolytic capacitor (>= 330 uF), it should power the arduino during the 50 mS it takes for the relay to switch, eliminating the need for the EEPROM .
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Paul__B

Also, as far as can you measure it while your charging it, no. You can't because you have a source in parallel with a load. You have to disconnect the source (charger) to measure the load (battery). (normally a battery is a source but when it is being charged it is a load)
Eh?

raschemmel

#3
Apr 20, 2016, 12:23 pm Last Edit: Apr 20, 2016, 12:28 pm by raschemmel
The volage measured across a battery will not be the battery voltage if it is connected to a charger. It will be the chzrger voltage. ( regardless of battety type). You hsve to disvonnect charger to measure the battery.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

guillaume55

Thank you for your replies
raschemmel : I've already search on google, I have found what you means but I want to test the voltage of the power supply and it's repply 1023 at an analogRead().
I have forgotten, I will use an atmega32u4 without arduino board and at 8MHz
If I use the internal ref and I connect the battery to A0, could the battery stay wired to A0 or I muss disconnect it?

raschemmel

Don't connect anything, do anything or connect the vattey until you understand what you need to do.
You haven't mentioned your interface circuit so something is wrong

Post your schematic.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Paul__B

The voltage measured across a battery will not be the battery voltage if it is connected to a charger. It will be the charger voltage. ( regardless of battery type). You have to disconnect charger to measure the battery.
The OP mentioned whether it was appropriate to operate the Arduino whilst the battery was charging.

Given that he is using a single lithium cell, with a voltage on charge not exceeding 4.2 V, directly powering the Arduino via the Vcc terminal, it is perfectly safe to do so but this may exceed the specification of other connected devices rated for 3.3 V only.

Similarly, it is quite fine to measure the battery voltage during charging - indeed, quite desirable to assess the charging process - but obviously not using the Vcc supplied by the battery itself as the reference.

And yes, the OP has not properly explained what he is attempting to do.

raschemmel

Quote
Similarly, it is quite fine to measure the battery voltage during charging - indeed, quite desirable to assess the charging process - but obviously not using the Vcc supplied by the battery itself as the reference. 
You can read whatever you want be it won't be the battery voltage you'll see when you disconnect the charger, for obvious reasons. Reading the charging voltage is not reading the battery. He asked about reading the battery. If you want to know what the battery voltage is you need to disconnect everything from the battery. That should be obvious.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

guillaume55

My schematic is incomplete
I will build a gps who is controlled by an atmega without board powered by a LI-ion bat but the gps work only with 3v-3.3v
When I plug the board on the computer it will transmit data and charge the bat
Could the TP4056 (bat charger) give power to the atmega and recharge the battery at the same time?

http://www.ti.com/lit/ds/symlink/ucc3954.pdf

Here a little drawing :


guillaume55

https://onedrive.live.com/redir?resid=D51A642F2BE5A217!125438&authkey=!AIQmVcJyMpq3sTw&v=3&ithint=photo%2cjpg

and
https://onedrive.live.com/redir?resid=D51A642F2BE5A217!125439&authkey=!AL4cbvBLuHMnXhU&v=3&ithint=photo%2cjpg

Sorry for the double post and tanks for your help

raschemmel

#10
Apr 20, 2016, 06:13 pm Last Edit: Apr 20, 2016, 06:16 pm by raschemmel
Dude, that's unnecessary. Just use the "Attachments and other options" link below to attach the photo.

Then click SAVE to save your changes

then right click over the attached filename and select "Copy link address"

then click MODIFY (AGAIN) and click on the attach image toolbutton (computer monitor icon to the left of the chain links icon) and paste the copied link address into the bar

then click SAVE (AGAIN)

You might need to use Microsoft Paint to resize your file or save it as a jpeg.

No, you don't HAVE to disconnect the battery but the voltage you measure will not be accurate while it is connected to the charger.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

guillaume55

Thanks
I can supply the atmega directly by the charger during charging process or it can disturb the charge?
also I can wire like this

Does a 3.3v (or 3.3v) regulator exist with an input of 4.2v to 3v? and if the curent <3v what happend? can it stops the discharge?
I've found a componement UC3954 (http://www.ti.com/lit/ds/symlink/ucc3954.pdf) but it doesn't stop the discharge.
Can a LDO makes what I want?

raschemmel

Quote
I can supply the atmega directly by the charger during charging process or it can disturb the charge?
Like I said, you can power the arduino during charging. No problem
You just can't expect the voltage measured to be the same as the battery voltage with nothing at all connected to it.



Quote
Does a 3.3v (or 3.3v) regulator exist with an input of 4.2v to 3v?
Low Dropout Regulators have a smaller overhead and thus can operate on a voltage that is only slightly higher than the output voltage.


Quote
and if the curent <3v what happend? can it stops the discharge?
current isn't measured in volts.

the atmega resets at 2.6 V (brownout theshold)

I've found a componement UC3954 (http://www.ti.com/lit/ds/symlink/ucc3954.pdf) but it doesn't stop the discharge.
No idea what your are talking about.

Quote
Can a LDO makes what I want?
I don't know what you are asking here.


Redo your drawing with inputs on the left and outputs on the right.
What country are you from ?
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

guillaume55

I'm from France (and this is why I have issues with (few) words like current etc...)

"but it doesn't stop the discharge"
the componement do not stop the discharge of the battery at 3v but when it's dead at 2.5v

Maybe it is easier to use a NiMH and increase the voltage to 3.3v
It takes nearly the same space
I will think about these two ways, I don't forgot the idea of the lithium battery
Thanks a lot for your help, now I have many informations about these battery

BigBobby

#14
Apr 20, 2016, 10:54 pm Last Edit: Apr 20, 2016, 11:02 pm by BigBobby
Thanks
I can supply the atmega directly by the charger during charging process or it can disturb the charge?
also I can wire like this

Does a 3.3v (or 3.3v) regulator exist with an input of 4.2v to 3v? and if the curent <3v what happend? can it stops the discharge?
I've found a componement UC3954 (http://www.ti.com/lit/ds/symlink/ucc3954.pdf) but it doesn't stop the discharge.
Can a LDO makes what I want?
The LTC3335 is a buck-boost regulator for these types of applications -> http://cds.linear.com/docs/en/datasheet/3335f.pdf

I am using it for something similar:  A Lithium (not Li-Ion) battery powering an Arduino with a radio (mine is GSM).  The LTC3335 is low current so I need a lot of output capacitance for when I use the radio, but the LTC3335 replenishes the charge on this capacitance in between transmissions.

Another feature of the LTC3335 is that it includes a coulomb counter.  Since your battery voltage won't change much over time, the coulomb counter gives you an estimate of how much charge is left in your battery.

If you wanted the LTC3335 to turn off automatically when the battery is lower than 3V you could need a comparator circuit connected to the EN pin.  When EN is low the LTC3335 will go into a low power state that draws 680nA (about the same as battery self discharge).  The LTC1540 shows a circuit to detect 2.9V on page 1 -> http://cds.linear.com/docs/en/datasheet/1540fas.pdf

At this point, however, you won't have 3.3V to run your Linduino.  From the block diagram you posted, I'm not sure how the TP4056 will get turned back on to recharge your dead battery.

Edited to show the OP's block diagram:

Go Up