A DiY DC UPS for my homelab, not a lot of dev yet

AI Disclosure:
I used a tiny bit of AI to help me understand how components work or why they weren’t working as I expected, but the current state is and the finished project should be AI free. My main goal is to learn how to do it, not just to get it done. I’ll ask AI when something doesn’t work to help me figure out why.


This has been a long story, and I might go into more detail later, but I just want to get started with the discussion somewhere. I specifically joined the L1T forums because I heard Wendell talk about Devember and I thought this is the best place to talk about my project, get some feedback, share ideas, learn a lot of stuff and have fun.

The story begins during the dark times of 2020, when I was forced to work from home and due to some personal health issues I also started looking into home automation.

Because of wfh I decided to get a standard off-the-shelf UPS for my desktop setup, and at the time didn’t really think of any other devices needing special protection, since I didn’t really have anything critical running at home. At the same time I also got an Odroid C4 that I used as my general purpose self-hosting machine (AdGuard, HomeAssistant, Vaultwarden etc.).

Over time I was thinking “what good does my desktop UPS do me when my internet, my smart home, my sensor devices, cameras etc. don’t have battery backup. But all of these are very low power devices, getting another standard UPS is pretty expensive and terribly inefficient. Power costs are high here, every Watt I run 24/7 costs me more than 2.50€ a year.

Now I know a little bit of engineering, a bit of physics, a bit about electronics and thought to myself surely there are better ways, and with doing some research I found a few models specifically designed as “router UPS” that come in a 9V or 12V variant, you plug your router wall wart into one side and the router itself into the other, and when power goes out they keep your device running. But these are very limited in terms of what voltages and how many devices they can supply, and I didn’t feel like buying half a dozen of those, so I looked around for other solutions.

I came across this guide: DIY Mini UPS for WiFi Router V5.0 : 18 Steps (with Pictures) - Instructables which made me realize, making my own UPS is not actually that hard, but that design is not very good and not suitable when you want to keep adding outputs and increasing the load. Also I didn’t like that it was using set voltages and barrel jack connectors.

In 2025 I finally took up the idea again, because I somewhere saw a video or a post about USB-C to barrel jack adapters with built in USB-PD trigger to power various (older or recent) devices with unified USB-C chargers. That made my idea a lot easier, I could just do a generic USB-C PD output device and the little adapters would make sure it works with every device I want to power from it.

Luckily I was also aware (due to my tinkering curiosity) of the premade “PD65W” boards that you can buy in many places, a tiny module that does exactly what I just described, you feed it a DC voltage and it has a USB-C output, will auto-negotiate and auto-regulate USB-PD voltages.

Also LFP batteries have become a lot cheaper and more accessible as a safer alternative to Li-Ion for tinkering, so with all of that knowledge combined I went back to the guide for the mini-UPS and made my own variant, using an old laptop power brick, a 4S LFP configuration and 4 USB-C PD65W output modules. I’ll write a detailed component list and schematic in my next post.

This is how it looks, and it’s been running flawlessly since January, powering my Zyxel VDSL Modem, my GL.iNet Flint 2 router and my Odroid C4 Home Assistant machine while only drawing 20W at the wall. The three devices with their original wall warts drew about 18W combined, so only 2W added, and most of that is probably the old laptop charger not being very efficient. On Battery it draws about 14.5W.

It’s been through a couple of simulated power outages as well as a real one, I get about 17 hours of runtime for my 3 devices before the voltage drops too low for the Zyxel, did not test how long the other devices would last after that.

Now you might say “why are you posting your finished project in the Devember category”, but the truth is I don’t consider it finished, it is a DiY project, it is homelab related, and it will involve some dev eventually.

I hope this is okay to share in the Devember event. My point here is that I’m not building some fantasy project, I already have a proof of concept working.

My plans for the next steps are, and this is where I want to learn how to do this:

  1. turn the current project board into a printable PCB that I can share with anyone interested, to be ordered from any of your favorite PCB providers
  2. on the printable PCB, replace the laptop input with USB-C and a 20V PD trigger for itself to be powered from any regular USB-C power supply (yay efficiency)
  3. add a relay to fully turn off the charging circuit when the battery is fully charged, plus little LEDs to indicate when the setup is running on battery or charging the battery, and probably a fuse to protect the battery from accidental short circuits
  4. add a microcontroller, to monitor battery state, maybe output port switching and monitoring, and make it NUT compatible so I can easily integrate it into my ecosystem
  5. design an enclosure with a display, maybe one in 10” rackmount size with external battery and one in 19” rackmount size with internal battery
  6. scale it up to use a much more powerful PSU (probably some commercial 30V or something), an 8S battery configuration and be able to output true 20V 65W (or higher) USB-PD so it can run more powerful devices, right now I’m limited to 12V output.

If anyone has some good guides to help me get started on PCB design (using KiCAD preferably) or wants to chat about the project feel free to reach out. I’m not looking for someone doing all the work, I don’t want a finished PCB, I want to learn how to do it.

I’ll provide a detailed look at the current setup in my next post, whenever that will be.

2 Likes

Looks really good. 2 watt loss less then I expected, but it’s still a 11% loss, and that ads up when you go larger. An offline UPS does not have this issue, but has other cons.

There is ESP related projects that will interface to that BMS bus and pipe that into HA for stats and automation. This is what one of mine look like with my JDB BMSes. I do have relays on the ESP board that I control the activate balancer with. I can also turn off the charging FETs if I want to stop charging. ESPHome can be programmed to do all that with a yaml file, or you can offline that automation to HA.

Note your charging set points. You want a charger that will take the batteries up to 3.45v per cell, but not float them there. I generally float the cells at 3.35v.

I like EasyEDA for simple PCB design.

1 Like

This is exactly why I want to add a relay to the charging circuit, I currently have the CC-CV module set to 13.8V (after the diode losses, I do have an extra Schottky Diode after the CC-CV module to make sure I don’t get reverse flow when on battery mode). That should give me 3.45V per cell, but since I’m not turning off the charger, that is my floating voltage. Ideally I’d probably want to charge it to 14.2V or something, and then cut the charger off until the voltage drops below 13.4V.

The BMS has a bluetooth module that I already added to my HA, so I have that data in Home Assistant even without an extra microcontroller. I can control the FETs of the BMS through that, but the suggestion I got was not to use the BMS FETs to control charging, but rather switch the charger on/off, the BMS FETs are supposed to be emergency switches.

I wouldn’t see the 2 Watt overhead as “11%”, because there are some fixed cost components in there, like the USB-PD controllers, the XORing controllers etc. These won’t scale as the load increases. Also I assume most of it is just the terribly inefficient laptop charger I’m using, a modern GaN USB-C charger will probably give me those 2 Watt right back by itself.

I’ll look into that, thanks for the suggestion

Alright time to make a writeup of my BoM. Schematics will be next post, don’t have access to my KiCAD right now.

The GOAT are these little adapters:


I bought two 4-packs in 5.5x2.5 and 5.5x2.1 barrel jack, all with a 12V PD trigger built in. You can get them with almost any output jack, in 5V, 9V, 12V, 20V variants, easy mode if you want to make your old laptop run on USB-C, there are even fancier ones where you can program the voltage they should request.

Even if you don’t care about me rambling over my UPS project, you should look these up, they let you power pretty much anything on USB-C, you could just get a multi-port USB-C charger to power your entire small device shelf or even run them on a power bank if power goes out.

The ones I got were branded “YBFBSJK” on Amazon. You’ll probably have to search for them, I don’t think this is a proper brand

Here’s the full list of everything I bought

Part Bought at Purchased count Purchase price per unit Used count Cost for prototype
EVE C40 20Ah LFP cells nkon.nl 4 8.25€ 4 33.00€
40A 4S Daly LFP BMS with BT AliExpress 1 18.21€ 1 18.21€
25x20x8cm Project Box Amazon 1 14.85€ 1 14.85€
TI LM5050MK-1 Controller Reichelt 5 3.45€ 2 6.90€
IRLB 8721 N-ch MOSFET Reichelt 10 0.74€ 2 1.48€
PD65W USB-C modules AliExpress 5 0.91€ 4 3,64€
XL4015 CC-CV charging module AliExpress 3 1.33€ 1 1.33€
12x8cm universal PCB AliExpress 3 1.28€ 1 1.28€
MBR1045G Schottky-diode AliExpress 10 0.22€ 1 0.22€
XT30 battery plug+socket AliExpress 5 0.43€ 1 0.43€
Socket for my charger plug AliExpress 2 0.60€ 1 0.60€
USB-C to 5.5x2.5 adapter 12V Amazon 4 2.25€ 3 7.75€
USB-C to 5.5x2.1 adapter 12V Amazon 4 1.91€ 0 0€
cheapest USB-C cable Amazon 4 1.75€ 4 7.00€
various consumables all over the place 1 5.00€ 1 5.00€
Laptop Charger 19V 5A Sony 1 0.00€ (maybe 10€ on ebay) 1 0.00€ (maybe 10€ on ebay)
------------------------- ----------------- ------------------- --------------------- ----------- ----------------------
Shipping 12.35€
Total 114.04€ (+maybe 10€ on ebay)

The shipping I fully attributed to this prototype, even though for some components I ordered enough to make more prototypes, so then shipping would just be what I needed to order that time.

Consumables include various wires, shrink tube, soldering equipment, pin rows, 2x SOT23 to DIP adapters that I took from a large adapter kit I already have, though you could try soldering the LM5050 directly on the prototype board, but that’s very hard.

All of the prices are including taxes and import fees, so that is what I really paid in the end. Most of the cost is the battery itself, the cells, BMS and box add up to over 60€ already, but the way I built it allows it to easily switch out the battery, you could just buy a fully assembled 12.8V (camping) battery and wire it up to an XT30 or use any other plug.

The board design would even allow for other battery voltages, but then you’d need boost circuits to get the required output voltage (if your battery voltage is less than 12V) or to get the required charging voltage (if your battery voltage is higher than 20V). 12.8V battery works perfectly because then voltage only ever needs to be down converted which is a lot cheaper than boosting.

As far as output power goes, I’m pretty much limited by the 19V 5A laptop charger I’m using, each PD65W can go up to 36W on 12V 3A, my power MOSFETs are rated for over 60A continuous current, the XT30 has a 30A rating, the BMS a 40A and the cells can do up to 60A, but the recommended discharge is 10A.

In theory I can supply quite a bit more power from the battery than from the charger, with a microcontroller I could make an overload scenario fail over to battery

1 Like

3.45V is a bit too high for floating. I take my battery pack up to 3.45V as that is the voltage the cells start to hit near 100% and I can detect if the cells are out of balance and kick the activate balancer in. Then I drop down to 3.35V for floating.

They are. Under most conditions, the BMS is going to be doing nothing but monitoring. But under your setup, you are not pushing that BMS anywhere close to the limit with that charger, so I would not be worried about the FETs. If you are making your own PCB, you can put some FETs on it to control changing and skip the clicking relay.

Better option is to get a proper charger with 3 stage charging, but baring that, you can write some of that logic into a microcontroller controlling separate FETs to get close enough.

It’s been a few days, I started looking into EasyEDA and I think I’m getting a hang of it, but I’ll present my first progress in the next post. This time I just want to talk about my initial schematics.

As mentioned I took that instructables guide as inspiration, but I immediately disliked that it was using diodes to control which path is active, diodes are quite lossy when you get to multiple amps power draw. Also diodes would never allow the battery voltage to be higher than the input voltage, a thought I had been considering for a while. Plus a diode being so lossy would mean it needs cooling, and I’m not sure passive cooling would be enough, so that’s added complexity and cost, plus even more “always on power draw” that I was trying to avoid, so my plan was right away to switch the paths using MOSFETs.

My first plan was rather simple, use P-channel MOSFETs as power switches and N-channel MOSFETs combined with some voltage divider networks to bias the paths so when charger is connected, the charger path would be fully on and the battery path fully off.

But upon building a prototype like this, I quickly realized that MOSFETs don’t behave as binary switches in the real world, and while the setup was correctly providing uninterrupted output, it would always allow current to flow back into the inactive input because the system would reach an intermediate equilibrium. Feeding battery voltage back into the charger probably wouldn’t have been too big of an issue, but feeding charger voltage into the battery surely would, so that design had to be discarded.

So at this point I did some research and I ran into the TI LM5050-1 OR-ing FET controller: https://www.ti.com/lit/ds/symlink/lm5050-1.pdf. This IC, while still being fully analog, no microprocessor or firmware required, handles this exact situation in a much more sophisticated way, and what I want to do is exactly one of the recommended setups:

Plus this would allow me to use N-channel power MOSFETs which are generally more efficient than P-channel and easier to come by, and even though these LM5050-1 chips are quite expensive, every Watt I can reduce will save me money over time, so spending an extra 5€ on components for better efficiency is well worth it. So with this I updated my schematic to look like this:

I built my next prototype with a single output board and without the CC-CV module at first, and it worked absolutely flawlessly:


So then I just added 3 more output boards, the XL4015 module between charger and battery input, wired everything up and that’s what I’ve been using for almost a year now.

Next up: step 1 of my original plan, turning this exact setup into an EasyEDA project to share with anyone interested.

The EVE spec sheet for the cells recommend charging at 3.65V per Cell cutoff voltage but then obviously disconnecting the charger when charge current drops below a threshold. I chose 3.45V because I don’t have a way to make the charger turn off or change voltage, and charging at 3.35V would be really slow. Ideally I’d like to do what the spec sheet says, so charge at 3.65V per cell and then turn off the charger using a relay when charge current is below whatever they deem cutoff.

2 Likes

3.65v per cell is the max you want to ever charge a cell to. When you assemble a pack with multiple cells, you top balance them by charging them to 3.65v per cell. Normally by connecting all cells in parallel, then charging them to 3.65v until the amps drop to some amount (dependent on total ah). Then put the pack in series and it’s good. 3.65v tend to stress the cell and offers very little extra capacity, so there is no point in running them that high in daily use.

The BMS should go into a protect mode and cut charging if any of the cells goes above 3.65v per cell too. The only time you want or need to hit 3.65v per cell, is when something went wrong and you need to manually balance the cells. You don’t want to be bumping that number daily and making the BMS disconnect the pack due to cell over voltage.

This website list voltage V SOC.

https://powmr.com/blogs/news/lifepo4-voltage-chart-and-soc

3.38v is 99% full. Technically, you never need to charge past this number. Charge to 3.38v and it’s near enough to full that it’s good. Or even just 3.35v and it’s 90% full.

There is 2 problems with that tho.

  1. Because of the extremely flat voltage curve of LifePO4, you can’t really tell SOC from battery voltage in the middle of the SOC curve. The way to know exactly what the SOC is, is to measure everything going into and out of the batteries with an amp hour meter/measurement. That measurement has some error in it, and it gets off over time. This is why SOC meters get off when people set their power stations to never charge above 80% to make them last longer.

  2. Also because of the flat voltage curve, all the cells appear to have about the same voltage even if their SOC is different, so it’s not apparent when the pack gets out of balance and needs to be rebalanced.

So charging the pack up to 3.40-3.45 causes the cell voltages to shoot up, the amp hour meter/BMS then knows the pack is at 99% full and resets it’s SOC number, and the balancer can kick in if needed. But it’s well under the 3.65 that will cause the BMS to disconnect the battery for cell overvoltage protect.

Below is a screen shot of 2 of my packs. Pack 5 is not as healthy as pack 4, so you can see the balancer kicks in on pack 5 and balance it.

MOSFETs do have a partly on state, and it’s not where they like living at. Your circuit should slam them full on, or full off on the gate pin. If driven by some logic level, like from an ESP, then it’s not normally an issue. And a simple pull up or pull down resistor works. But the gate pin also has quite a bit of internal capacitance, so if you want to PWM the MOSFET to control charging, then they make MOSFET drivers that will slam the gate pin between -V and +V and take that load off the ESP chip and pulldown resistor.

With ESP chips being a few bucks now, I tend to use the minimum amount of hardware, and put the logic in the ESP chip. Code is quick to change and debug.