Page 1 of 2

How to Wire 5V and Battery

Posted: Thu Nov 07, 2019 2:24 am
by pixelpop
I have a project that can run on either a 5V wall wart or an internal battery, but need to know how to wire this. Can I just connect both the 5V source and the battery source to the output? Or do I need to put a switch inside that the user sets to run on 5V "or" battery in order to isolate the 5V + from the battery +?

Re: How to Wire 5V and Battery

Posted: Thu Nov 07, 2019 3:10 am
by PhatFil
NO, sorry, I think the keyword you want to use in your search is UPS for uninterruptible power supply. A lot has been written on the subject and its probably easier to digest first hand rather than through my paraphrasing of the collective wisdom.

Re: How to Wire 5V and Battery

Posted: Thu Nov 07, 2019 3:16 am
by pixelpop
Thanks. I read up on UPS's but I'm not really shooting for that. But I can see how it would apply to my situation. I think I'll have to use a switch that is either 5V source or battery, but keeping the two separated.

Re: How to Wire 5V and Battery

Posted: Thu Nov 07, 2019 3:21 am
by Imperf3kt
What is your "5v battery"? I do not know of any battery that outputs exactly 5v directly

Re: How to Wire 5V and Battery

Posted: Thu Nov 07, 2019 3:27 am
by pixelpop
Sorry, I wasn't clear. I am using a 5V wall PS and a 3.7V LiPo battery.

Re: How to Wire 5V and Battery

Posted: Thu Nov 07, 2019 4:17 am
by PhatFil
if your ok with shutting down the system and switching the power supply before restarting you can getaway with a basic SPDT relay or switch.

just what are your switching criteria if not in the case of power failure?

Re: How to Wire 5V and Battery

Posted: Thu Nov 07, 2019 4:59 am
by Imperf3kt
If your battery is 3.7v you should definitely not connect it to 5v, you'd cause a fire at minimum, an explosion at worst. There'd be toxic gases spewing out of your battery in either scenario.


I'm going to assume the battery is actually connected to a 5v boost circuit? Just get one that supports passthrough and switches fast enough that the Pi doesn't notice (not exactly as trivial as I make it sound)

Re: How to Wire 5V and Battery

Posted: Thu Nov 07, 2019 7:39 am
by wolf.z
Pixelpop,

your lecture suggests, you almost have no clue, what Volts are. Current source (battery) and sink (Pi) are like dishwasher and fitment cupboard. You'll never succeed in fitting a 60cm dishwasher to a 40cm cupboard.
Back to Volts, you have to involve a power converter to fit source and sink, a power converter just as a wall plug converter is form 230V AC to 5 Volt DC. And so is a UPS, and a lot more. Back to your initial question: " How to Wire 5V and Battery?"

Put a UPS in between.

Anything else will give unexpected results.

Re: How to Wire 5V and Battery

Posted: Thu Nov 07, 2019 8:36 am
by pixelpop
Thank you, wolf.z, for pointing out my supposed lack of electrical knowledge.

I am, in fact, putting in a UPS even as I type this. Although it will not be used strictly as a UPS. It's a good thing that I knew a bit more than you surmised or I could have blown myself up! :shock:

Just FYI, this is the UPS I am employing. Note that most charge/discharge modules are rated at 1A or less output but I need to maintain at least 2A, thus my selection of this module.

https://www.aliexpress.com/item/3281641 ... 4c4dGDxxI1

Have a good evening.

Re: How to Wire 5V and Battery

Posted: Thu Nov 07, 2019 9:06 pm
by Imperf3kt
According to that devices description page, you need two batteries in parallel in order to reach over 5w output. Do you have two identical batteries? Or at least a BMS?

It also states there is no over discharge protection and fails to mention whether it can be used in charge and boost mode simultaneously.

And all that is before you notice the specifications are mentioned in several places, all with different specs...
The title says 10w, the description says 5w, the spec list says 50w. Output current is somehow both 2A and <2A...
I would not buy this junk.


Many of these cheap Chinese devices use the cheapest parts they can find, including recycled parts. They have a tendency to either fail easily, not work as advertised or require additional heatsinking etc in order to achieve maximum efficiency and/or not melt/fail
There's a reason you paid next to nothing for it.

Re: How to Wire 5V and Battery

Posted: Fri Nov 08, 2019 1:54 am
by pixelpop
Actually, Imperf3kt, you are correct. I ended up going with one of these. Seems like they have a better reputation and still meet my requirements.

https://smile.amazon.com/gp/product/B07 ... UTF8&psc=1

Re: How to Wire 5V and Battery

Posted: Fri Nov 08, 2019 3:14 am
by Heater
I see the description of that product states:

"Allow discharge while charging. (Note: At this time output voltage 4.7 / 5V)"

Which may be problematic.

Re: How to Wire 5V and Battery

Posted: Fri Nov 08, 2019 3:31 am
by pixelpop
Nope...all power sources, battery and external, are run thru a final boost to 5.2V. And please don't tell me I'll fry the Pi (hey, nice rhyme) because I've run it for days in my system at that level.

Re: How to Wire 5V and Battery

Posted: Fri Nov 08, 2019 3:43 am
by Heater
Oops, duplicate my post....

Re: How to Wire 5V and Battery

Posted: Fri Nov 08, 2019 3:44 am
by Heater
Interesting. Can you share the schematic diagram and parts list of your final circuit ?

Re: How to Wire 5V and Battery

Posted: Fri Nov 08, 2019 5:25 am
by W. H. Heydt
pixelpop wrote:
Fri Nov 08, 2019 3:31 am
Nope...all power sources, battery and external, are run thru a final boost to 5.2V. And please don't tell me I'll fry the Pi (hey, nice rhyme) because I've run it for days in my system at that level.
5.2v is within spec, so no one is likely to warn you against it.

Re: How to Wire 5V and Battery

Posted: Fri Nov 08, 2019 6:20 am
by pixelpop
You'd be surprised...or maybe not. :o

Re: How to Wire 5V and Battery

Posted: Fri Nov 08, 2019 1:39 pm
by PhatFil
Heater wrote:
Fri Nov 08, 2019 3:14 am
I see the description of that product states:

"Allow discharge while charging. (Note: At this time output voltage 4.7 / 5V)"

Which may be problematic.
also see in the Q&A it suggests its based on a tp4056 which last time i checked ( a while back) wasnt suitable for concurrent charge/discharge,
(i refer to the pcbs sold via ebay etc under the tp4056 label with a number of different configurations. As used within the excellent Ispindel project which was quite explicit on this particular limitation iirc )

Re: How to Wire 5V and Battery

Posted: Fri Nov 08, 2019 1:56 pm
by Lewis-H
No, I don't think it is possible. You cannot connect 2 batteries. If you somehow manage to connect it you have to be very careful with the power supply. As raspberry pi gets burn if power supply is more than 3.7V

Regards,
Lewis

Re: How to Wire 5V and Battery

Posted: Fri Nov 08, 2019 1:56 pm
by pixelpop
Doesn't matter, I am not using the TP4056 in a charge/discharge scenario. I am just using it to isolate the 5V source from the 3.7 battery source. If the 5V source happens to be plugged in and there is some trickle charge to the battery, that's just a cherry, but not part of the requirements. And I am not using this as a UPS either. It doesn't matter if the Pi reboots when the 5V source is removed and operations switch to battery mode.

Re: How to Wire 5V and Battery

Posted: Fri Nov 08, 2019 2:23 pm
by PhatFil
That tells me then.. gotta say i am a little intrigued as to this top secret project..

have at it ;)

Re: How to Wire 5V and Battery

Posted: Fri Nov 08, 2019 9:01 pm
by pixelpop
Lewis-H wrote:
Fri Nov 08, 2019 1:56 pm
No, I don't think it is possible. You cannot connect 2 batteries. If you somehow manage to connect it you have to be very careful with the power supply. As raspberry pi gets burn if power supply is more than 3.7V

Regards,
Lewis
Sorry, Lewis. Wrong on both counts. Two batteries can be connected together, either in series or parallel. If connected in series, the voltage out is the sum of the individual batteries (i. e, two 3.7V 2A batteries in parallel produce 7.4V output at 2A; two 3.7V 2A batteries in series produce 3.7V output at 4A).

Here is a good tutorial: https://www.youtube.com/watch?v=_dvjGIo4gQc

Also, the Pi requires at least 4.7V to just boot up and 5V is the stated requirement. It won't even boot up at 3.7V.

Re: How to Wire 5V and Battery

Posted: Sat Nov 09, 2019 3:04 am
by emma1997
pixelpop wrote:
Fri Nov 08, 2019 9:01 pm
Sorry, Lewis. Wrong on both counts. Two batteries can be connected together, either in series or parallel. If connected in series, the voltage out is the sum of the individual batteries (i. e, two 3.7V 2A batteries in parallel produce 7.4V output at 2A; two 3.7V 2A batteries in series produce 3.7V output at 4A).

Also, the Pi requires at least 4.7V to just boot up and 5V is the stated requirement. It won't even boot up at 3.7V.
Sorry, Pix. Wrong on both counts. It looks like you have the series/parallel thing backwards.

And actually Pi runs much lower than 3.7v as seen in this thread: https://www.raspberrypi.org/forums/view ... 8#p1558418 . My own tests show operation at even lower voltage assuming a stiff supply.

Whether it's a good idea is another thing entirely. Many threads lately involve running off a single lithium cell and, like here, by first post becomes evident these are not EE level punters. I made many attempts myself when starting out and after destroying several SD, one Pi, and boatload of lipos finally learned. It just don't pay to run that close to the limit. Things look great for the first few hours at kitchen table temperatures but then...

Ask yourself... Do I feel lucky? Well... do ya?

So after spending many hundreds of hours (work and play) I've concluded at least a couple cells feeding 5v converter is the best solution for battery operation. Backup from DC supply only need add a couple diodes. One can do this the cheap reliable and easy way. Or not.

PS if you want to switch manually between the two (SPDT) then a simple 470uf or so cap will prevent any momentary dropout/reset.

Re: How to Wire 5V and Battery

Posted: Sat Nov 09, 2019 4:28 am
by pixelpop
emma1997 wrote:
Sat Nov 09, 2019 3:04 am
Sorry, Pix. Wrong on both counts. It looks like you have the series/parallel thing backwards.

And actually Pi runs much lower than 3.7v as seen in this thread: https://www.raspberrypi.org/forums/view ... 8#p1558418 . My own tests show operation at even lower voltage assuming a stiff supply.

Whether it's a good idea is another thing entirely. Many threads lately involve running off a single lithium cell and, like here, by first post becomes evident these are not EE level punters. I made many attempts myself when starting out and after destroying several SD, one Pi, and boatload of lipos finally learned. It just don't pay to run that close to the limit. Things look great for the first few hours at kitchen table temperatures but then...

Ask yourself... Do I feel lucky? Well... do ya?

So after spending many hundreds of hours (work and play) I've concluded at least a couple cells feeding 5v converter is the best solution for battery operation. Backup from DC supply only need add a couple diodes. One can do this the cheap reliable and easy way. Or not.

PS if you want to switch manually between the two (SPDT) then a simple 470uf or so cap will prevent any momentary dropout/reset.
You are correct in pointing out that I got the series/parallel battery configuration swapped. Sleep deprivation does funny things to the mind. Thanks for catching that.

Thanks for confirming that my design is the proper one for my requirements. To reiterate, this design is not meant to be a UPS nor a charge/discharge design. It is just an either/or. To charge the battery it will be removed and placed in a separate charger. So I have two 3.7V batteries in parallel feeding a boost converter to get my required voltage.

But back to your post. You state, "You cannot connect 2 batteries," and then conclude here with "at least a couple cells feeding 5v converter is the best solution." Maybe we are confusing batteries and cells, I don't know. But then you go on to say, "raspberry pi gets burn if power supply is more than 3.7V." Assuming I read this correctly, you are saying that anything in excess of 3.7V to the Pi will burn it up. And clearly that is not factual.

Re: How to Wire 5V and Battery

Posted: Sat Nov 09, 2019 5:20 am
by emma1997
Lol. You confused me with a post from your friend Lewis. ( where did I leave those meds.. :) ) His comments made no sense.

If you keep that battery fully charged, above 4v, which is a good idea anyway, it should work. Not something I would use for Mars Lander or medical machine but can be a fun project. I had fun doing it.

Keep us tuned.