DIY uninterruptible power supply

Project | Article by Maarten Tromp | Published | 3502 words.

A home made uninterruptible power supply to keep some essentials running during power outages. For people who like to DIY and could use an UPS.

DIY uninterruptible power supply
DIY uninterruptible power supply

In this article:

Background

A few months ago I made an automatic transfer switch. Several people contacted me about building their own, for use during load shedding. Inspired by their stories, I started this project to create an uninterruptible power supply that is straightforward, cost-effective, easy to build, and customisable to individual requirements. Like the ATS It won't be the worlds most advanced solution, but it offers a DIY alternative to buying an UPS.

Design

The UPS design is based around readily available RV and maritime parts, combined with 12 V lead-acid GEL batteries. Designs with other types of battery, such as LiFePO4, are entirely possible, but outside the scope for this article.

The design is kept basic on purpose. The only thing this UPS does is provide backup power when mains power fails (off-line system). There is no generator integration, no solar panels, and no line stabilisation. However, feel free to add those yourself.

A typical UPS block diagram is shown on the left, and that's exactly how this DIY UPS is designed. Each of the blocks is explained in its own chapter, including some customisation options to best fit your requirements.

Requirements

Before we can start selecting parts, we first need to know what you require of the UPS.

My requirements

As an example I will give the requirements for my own UPS.

  • Power: my UPS has to power a router, server, wifi, and some networking equipment. Measured average power consumption is 50 W. Peak is under 100 W.
  • Run time: 4 hours should cover most outages.
  • Charge time: I'm not in a hurry to have everything charged and ready again, so I don't really care.
  • System voltage: 12 V, since I already have some 12 V parts I want to use.

Inverter

An inverter takes battery voltage (12 Vdc or 24 Vdc), and converts it to mains voltage (110 Vac or 220 Vac). It's the inverse of a battery charger, hence the name.

Tips for buying an inverter

  • If you can find an inverter with built-in battery charger (and maybe even a transfer switch), that's worth the extra money. This will enormously simplify the build.
  • Personally, I'd rather buy used professional equipment than cheap new products. There is not much that can wear out on an inverter, especially on professional units.
  • When I was searching for inverters, used 24V inverters were usually cheaper than 12V ones, but this might be a temporal or local phenomenon.
  • The cheapest, unbranded inverters are usually built down to a price, rather than quality. Those often times do not deliver what they promise. If you must use one of these, buy considerably higher power than you need.
  • When in doubt, look for chunky metal box with cooling ribs and a fan.

My inverter

My inverter is a Victron Energy Phoenix 12/500. I've had it for over 20 years, and it's been in several other projects before. The inverter runs on 12 V, can deliver 500 W continuous, and 1400 W peak. It has a cooling fan, all sorts of protections, it's durable, and (almost) idiot proof.

If I were to buy an inverter today, I would again choose a (used) professional model, but with a bit more power so I could also run some power tools. If possible, I would pick one with built-in battery charger and transfer switch.

Batteries

Choosing the right batteries is the trickiest part of the UPS build.

Battery types

There are several different subtypes of lead-acid batteries, designed for different applications. Not all types are suitable for daily use in an UPS.

Starter batteries (car batteries) are designed to deliver a short, high-current burst (for starting an engine), but not for deep discharge. In a UPS they will work a few times, then wear out quickly.

Small sealed lead-acid (SLA) bricks are cheap and compact, and often used in alarms and emergency lights. Those are fine for occasional backup, but they wear out very fast with daily cycling.

Absorbent Glass Mat (AGM) is sealed type of lead-acid that's more robust than the small SLA bricks, and often used in commercial UPS units. A good choice if your UPS is used occasionally (a few times per year), but they won't last as long as deep-cycle types under daily load shedding.

Deep-cycle flooded lead-acid are inexpensive and durable if properly maintained. Can handle daily cycling and last for years, but they need to be topped up with distilled water and kept in a ventilated space.

GEL batteries are sealed and maintenance-free. They tolerate deep discharge well and are best suited for modest power draw over a long period of time. Often marketed as household, traction, or solar batteries. These are among the best types for daily use in an UPS.

Using multiple batteries

The perfect battery for your UPS (in terms of voltage and capacity) might not exist, but it's perfectly fine to combine multiple batteries into a battery pack. Just make sure all the batteries are identical (same brand, model, capacity, and age), because the whole pack will only perform as well as the weakest battery, and mixing and different types leads to imbalance, heat build-up, and premature failure.

Increase voltage (series connection): Connecting batteries in series adds their voltage. For example, two 12 V batteries in series make one 24 V battery pack. The capacity (Ah) stays the same: 2 × 12 V, 50 Ah in series = 24 V, 50 Ah

Increase capacity (parallel connection): Connecting batteries in parallel adds their capacity. For example, two 50 Ah batteries in parallel make one 100 Ah battery pack. The voltage stays the same: 2 × 12 V, 50 Ah in parallel = 12 V, 100 Ah

Combine series and parallel: With four 12 V, 50 Ah batteries you can make one 24 V, 100 Ah battery pack by wiring two sets in series, then putting those sets in parallel.

Wiring up multiple batteries is explained in more detail, and with photos in this tutorial.

Battery life

The service life of all types of batteries depends on several factors. Most important are charging and discharging rate, and temperature. The values used below describe GEL and similar sealed lead-acid batteries.

Discharge current: GEL batteries are most suitable for modest discharge rates. A safe maximum is around 0.2 C meaning 20% of the battery capacity (in Ah). For example, a 100 Ah battery should ideally not be discharged at more than 20 A. Higher currents are possible, but shorten the lifespan.

Charge current: A good rule of thumb is to charge at about 0.1 C. For a 100 Ah battery, that means ~10 A. Anything between 0.07 C and 0.15 C is acceptable. Charging outside this range shortens the lifespan.

Depth of discharge (DoD): The deeper you discharge a battery, the fewer cycles it will last. To maximise life, try to keep the battery above 50% charge, ideally above 80%. A larger capacity battery helps: it lowers the relative discharge per cycle, reduces current stress, and allows faster charging.

Temperature: Heat drastically reduce lifespan. At 25 °C, lead-acid batteries can achieve their rated lifespan. For every 10 °C above that, the expected service life is cut roughly in half. So keep your batteries in a cool, ventilated space (basement, cellar, garage, or shaded shed). You probably don't want them inside your living room anyway.

Battery sizing

All these factors (and a few more) come together when calculating the required battery capacity. To make life easier I've put together an UPS battery calculator that does the maths for you. Just fill in the values you know, and it will give you a minimum battery capacity.

The most interesting value to tweak is the depth of discharge (DoD). A smaller battery will be pushed harder: it has to deliver higher currents relative to its size, and it will be cycled deeper. Both of these cause more wear. A larger battery pack, on the other hand, runs "loafing along" at lower C-rates and shallower cycles, which usually means a much longer service life.

If the UPS is only for emergency backup, deep cycling is quite common, usually combined with AGM batteries. In that case, a DoD of up to 50 % (AGM) or even 80 % (flooded deep-cycle) may be acceptable. But if the UPS is used daily, for example during load-shedding, GEL batteries with a conservative DoD of about 20 % are often the better choice.

A bit of over-sizing is always a good idea, since battery capacity will degrade over time, and you may want to power more appliances from the UPS in the future.

Tips for buying batteries

New deep-cycle batteries are great, but they're expensive. You can save quite a bit with used batteries, if you know what to look for, but it will always be a bit of a gamble.

  • Touring coach batteries are often replaced on a fixed schedule, regardless of condition, which means you might find lightly used ones for cheap.
  • Marine household batteries are generally cheaper than batteries marketed for RV or camper use, even though they're often very similar inside.
  • If you're buying more than one battery, stick to identical units (same brand, model, capacity, and age). A mixed pack will lead to disappointment.

When buying used batteries, here are some thing to pay extra attention to.

  • No cracks, leaks, or bulging cases.
  • Ideally less than 5 years old, check date code if possible.
  • The resting voltage should be around 12.6–12.8 V when fully charged. (Don't forget to bring your multimeter.)
  • Under moderate load, such as car headlights, the voltage should stay above 12.0 V.
  • All batteries in your set should test about the same.

My batteries

When I bought the batteries for my UPS, price was an important factor. This build is meant as prototype, rather than for daily use. I had bought the batteries before I did any research on battery chemistry, capacity, charging and discharging rate, etc, but I happened to have made a good choice.

The batteries are two used marine traction batteries. I bought them for €45 each, local pick-up. They're Exide Maxxima 900, 12 V, 50 Ah Spiral Cell GEL batteries. I have wired the batteries in parallel, making a pack of 12 V, 100 Ah, to match the inverter voltage. DoD is slightly under 20%, also more by chance than by design, but I'm happy with the resulting value.

If I were to buy batteries for daily use, I would probably get bigger ones. I found a batch of used 12 V, 230 Ah touring car batteries online for €75 each.

Battery charger

GEL and AGM batteries are delicate and can easily get damaged if improperly charged. Therefore make sure your battery charger supports the battery type you have, matches the battery voltage (12 or 24 V) and supplies the correct charging current.

Ideal charging current for GEL and AGM batteries is 0.1 C, meaning 0.1 * battery capacity (in Ah). In case of my 100 Ah battery pack, that would be a charging current of 10 A. It's usually okay to have the charging current between 0.07 and 0.15 C for GEL, and up to 0.25 C for AGM. Always check in the datasheet for your batteries, if you can find one.

Tips for buying a battery charger

Buying tips are similar to those for the inverter. I'd rather buy a used good brand battery charger, than a cheap new one. Not much can wear out on a battery charger. The better ones come in a chunky metal box with a fan.

My battery charger

I already had a battery charger I wanted to use for the UPS. Unfortunately it only supported starter batteries, so I went looking for another charger. This was before I had realised I had GEL batteries, so I spent quite a while looking for an AGM battery charger. The only used one I could find was 15 A, of a brand I'd never heard of, for €25 + shipping. The charging current is not ideal, but falls within the acceptable range of the battery. When it turned out my battery was GEL, I was lucky the charger supported both kinds. But had I realised this earlier, I would have chosen a different charger.

If I were to buy a battery charger again, I would have bought a (used) known-brand battery charger, with a charging current closer to the ideal 0.1 C.

Automatic transfer switch

Switching the load (everything you plug into the UPS) between mains power and battery backup is handled by the automatic transfer switch (ATS).

As long as mains power is available, the ATS connects your load to the grid. When mains fails, the ATS switches the load over to the inverter output to keep things running. When mains comes back, the ATS waits a little for the power to stabilise, then switches the load back.

If you're lucky, the ATS is built into your inverter. If not, you'll need a separate unit. When I went looking a few years back, I noticed there was a big gap in the market: cheap units I didn't trust, and professional ones that were way too expensive. There didn't seem to be a mid-range.

Alternatively you can skip the ATS completely and connect the load directly to the inverter. In this configuration the inverter is always on, so it's less energy-efficient, but there's no noticeable switchover delay when mains fails. This is called an "on-line" system. When you do this, make sure the charger can provide enough current to run the inverter and charge the batteries at the same time.

Tips for buying an automatic transfer switch

  • Make sure it can handle your peak load current, not just the average.
  • A good unit includes a switch-back delay (usually around 30 seconds).
  • If you go for a cheap unit, over-size it, buy one rated for more current than you actually need.

My automatic transfer switch

I ended up building my own automatic transfer switch, and that's what I'm using here. It's basically a relay in a box, and I've fully documented the design. Feel free to copy it if you'd like.

I wish I could give a simple buying recommendation, but the truth is that professional ATS units (even used ones) are very expensive, and the cheap ones are of questionable quality. So unless you find a decent mid-range model, DIY may actually be the best option.

Battery monitor

Having a battery monitor in your UPS is optional. It doesn't make the UPS work any different, but it gives you valuable insight into how much charge is left in the battery, and an estimate of how long you can run. Some modern units even come with Bluetooth and an app, which can be handy.

Tips for buying a battery monitor

  • Good battery monitors use a shunt resistor and coulomb counting (measuring all current going in and out). These give you a much better picture of actual charge and runtime than one that only monitors voltage.
  • A voltage-only battery monitor is still better than having no monitor at all.
  • Having a low-voltage alarm can help you prevent over-draw. Some battery monitors have this built-in. Some inverters also come with a low-voltage cut-off.

My battery monitor

The one I use is a used Victron Energy BMV-501, which I picked up for €25 + shipping. It was the only affordable unit I could find, but it does the job well.

Wiring

Now that we've got the main components, it's time to start wiring everything together.

Wire sizing

Wiring up the UPS is not too different from wiring mains power, only the wires are somewhat thicker. The minimum required wire cross-section is dependent on the amount of current flowing through the wire. The higher the current, the thicker the wire should be. You can use the table below to get the minimum wire size.

Typical continuous current for stranded wire. Source: ChatGPT. more details.
Square (mm²)AWGTypical continuous current (A)
1.01810
1.51615
2.51420
41230
61040
10860
16680
254100
352130
500 (1/0)160

The biggest current runs between batteries and inverter. Take my UPS for example: Current=PowerVoltage×Inverter efficiency=500W12V×0.80=52A, Looking this up in the table gives 10 mm², which matches the inverter's user manual. Use the same size wire between your batteries, if you have more than one, and wiring up the battery monitor shunt resistor.

A smaller, but still significant, current runs between charger and batteries. The wires that came with it are usually fine.

Wiring the battery monitor requires just signal wires, thin wire will do the job.

Keep high-current wiring short. Every bit of wire has resistance, resulting in voltage drop and heat. For an efficient system you will want to minimise this.

Use stranded wire, not solid core. Stranded wire is more flexible, resists vibration, and makes better connections in screw terminals.

Safety

A few safety tips.

  • Double check polarity (positive/negative) before connecting. Positive is red, negative is black.
  • Err on the safe side: if in doubt, use thicker wiring. You don't lose anything by over-sizing, except maybe a few Euros.
  • Tighten everything properly, especially the thick, stiff battery wiring. These need to be mechanically fastened as well as electrically.
  • Have a clean cable path, no running wires over contacts or sharp edges, and no chafing wires.
  • Don't forget strain relief for cables going in and out of the UPS.
  • When in doubt, look it up, ask someone with experience, and apply common sense.

My wiring

My inverter came with 10 mm² (8 AWG) wires already attached. That's way overkill for my power draw, but it's good quality wiring, so I reused the extra length for battery wiring. The battery charger had 2.5 mm² (14 AWG) wiring attached, which is fine. For the battery monitor I used an old UTP (Ethernet) cable. Battery clamps came from the hardware store and are quick release types, which is handy when moving stuff around. The most channanging bit was attaching the thick battery cabling to the battery monitor shunt resistor. For this I used crimping lugs and some big pliers.

The battery charger, inverter, and battery monitor were already fused, so there was no need to add any more myself.

Enclosure

Right now my UPS is spread out across the floor. It works, but it's not particularly tidy or safe. At some point I'd like to put everything in a proper enclosure. It's not strictly necessary, but it does make things nicer, safer, and more compact.

If you build an enclosure, keep these things in mind:

My enclosure

If I were to build a box, I'd probably use scrap plywood. I'd leave plenty of space around the top for ventilation, and make a hinged lid for easy access and taking batteries out.

Known issues

There is one issue with my UPS though. It's nothing dangerous, but it lacks elegance. The inverter standby power consumption prevents the battery charger from detecting that the battery's actually fully charged, so it never shuts off properly. This might no longer be an issue with modern inverters (mine dates from the previous century).

An easy solution would be to use a more modern inverter, or a combined battery charger/inverter unit.

A DIY fix would be to replace the inverter on/off switch with a relay, controlled by the ATS. That way the inverter is only switched on when mains power fails.

For now, I just live with it, and I don't mind a few quirks.

Open source

This project is based on information from freely available sources, such as Wikipedia and user manuals.

In turn, the information and design and this article are released into the public domain. You can find relevant files in the downloads directory of this article.

Closing thoughts

This project taught me a lot about batteries. Before, I never really thought about the differences in lead-acid chemistries, or how much charge rate, discharge rate, and even temperature can affect lifespan. Writing the calculator forced me to dig into the details, and in the process I finally started to "get" the basics.

If you want to build your own UPS, I'd recommend a bit more planning than I did. I jumped in head-first, started collecting parts, and only later began doing the research. As a result, I ended up with a pile of components that weren't quite what I needed. That said, the UPS works, and works well. And for me, the learning was at least as valuable as the end result.

The other benefit of DIY is control. You know exactly what's inside, you can repair or upgrade it yourself, and no manufacturer can disable your backup power because your "subscription" ran out or decided to stop supporting this model. The last thing you want is for your backup system to depend on someone else's business model.