BATTERY BACKUP with charging (will not trigger arduino reset)

Hi Compadrinos… Here’s a (crude yet functional) first attempt at a 9v battery charging low-current (5V 30mA) battery backup system that will not cause your arduino to reset when power goes out. As I plan to use data logging I need a way to maintain system time using a ds1307/37 and data logging - this to indicate time and duration of a power outage. Problem is if youre using sensors (like the mq-2 gas sensor) this will drain your 9v battery in seconds… so next version will cut off relays and sensors and only maintain time and data logging functions. I’ll try a 12v version of this to maintain sensor functions as well. The main thing is it does not trigger a reset.

Project goals:

  1. disallow arduino reset
  2. maintain system time and data logging
  3. charge a 9volt battery when power comes back on.

Btw… I tried the ICL7673 but it caused a reset on power outage.

Mods, suggestions, etc, welcome.

so next version will cut off relays and sensors and only maintain time and data logging functions.

If you turn off the data collection part, what is there to log?

17:05:01 - No data
17:05:02 - No data
17:05:03 - No data

You're right.. datalogging needs at least one sensor providing feedback to make sense. Knowing how long power was off is as simple as a digitalread high when power comes back on.

Still, the idea can be taken to higher voltages and currents, so that sensors can stay on, etc.


Ok… here’s the corrected version. The first version wasn’t charging the batteries correctly… this one does.

“Im not responsible if your house blows up… heh heh.” - evil mad scientist hot on the trail

Here’s the high current version… “works like a charm”. Runs all the sensors (Im using 5 sensors including the gas guzzling mq-2) without skipping a beat (a.k.a. does not cause reset).

Ran this circuit with a dc motor at high current long enough to know the tip32b gets “very” hot… consequently I highly recommend a beefy heat sink (a 22.5 square centimeters aluminum block seems sufficient at about 1.5amps) if running high current values. As well, I have to assume the tip32, BD536 and the like will also do the job.

“task remaining”: disconnect batteries when fully charged: Use the rtc ds1307 for this? hmmm.

happy motoring!

Getting better. Try eliminating R3, D3 and the SPST relay, just return the bottom of SPDT relay coil to ground. You dont need the diode with question mark.

Good job on Q1 / U1 many folks dont know how to properly wrap a big pass transistor around a Vreg, they try to make an emitter follower instead. You can get a bit more current with Q1 running cooler, if you change 3R to 1.8R or 1.5R, that would make the 7805 regulator take a bigger share of the current, should be able to get 4amp total, 1 amp from 7805 and another 3 amp from the TIP32B if they both have decent heat sink. Note that the resistor needs to be 2 watts, or use 2 resistors in parallel, each 3R at 1w.

A little more efficiency and simplification is to put R1, 2, D2 and the batteries directly on the output of BR1. Sharing the common Gnd make it easier to add a charge regulator if you want.

Good luck on your project !

Hi.. Thanks for the tips. The tip about sharing current between the 7805 and the tip32b is definitely going into my bag of tricks. Thats a biggy.. thanks again.

  1. If you remove SPST relay and diode with question mark you get a reset on power off.

Anyway, Im moving over to 12v 4amp hour batteries to arrive at a 5-6 hour battery on time. Considering my projects draws .25 amps at power off these 12v batteries should do the job. Lets see.. 4 (amp hours) / .25 amp = 8 hours.. something tells me it doesnt work that way.. but well see. I just hooked up a .26 amp fan to one of these 12v batteries

Tried the 12v 4ah batteries and these dont deliver enough current to justify their use.. even with 2 of these wired in parallel. So Im headed back to the 9v setup for the time being.

I think that in order for a 12v system to work I will need a higher voltage transformer and a 12v battery capable of delivering higher current.

Anyway.. for now, Im going back to the 9volt setup to iron out kinks. It has met and exceeded my expectations.

Rethinking this:

1) Considering that without the mq-2 sensor and the lcd backlight and all relays disconnected my current draw is 50mA I can definitely use 12v 4ah batteries.. and achieve the 5-6 or more hours battery on time. Because the lcd with backlight on "looks cool" (hee hee) doesnt justify its usage on power off.

2) With a solar charger this could run on batteries indefinitely..

3) So.. on power off -> disconnect mq-2, lcd backlight, all relays

UPDATE: 7/11

Eureka! Just survived a real life power outage! Power came on and off 4 times, then stayed off for 55 minutes. Power is now back on and my clock has maintained time, and my arduino did not reset.


Forgive a few "dim" questions? I would love to see a good battery back-up design established.

a) Relay drawings: There's a newbie trap there, isn't there?? I spent half an hour with two copies of the schematic and colored highlighers, doing "power on" and a "power off" drawings before I had anything that made sense! One's drawn as if energized, the other as if NOT energized. True? (Q1) (Not helpful!)

My guess:

The right hand relay, the one below R3, which I'll call "Relay 1" is open until energized, right? (Q2). It's role is to prevent the other relay becoming energized until the voltage out of the bridge rises adequately. That rise could(?) be delayed more than a few centi-seconds if the battery has become significantly discharged while it was powering the Arduino. Yes? Is that the cleverness in this circuit? (Q3)

The left hand relay, the SPDT one, "Relay 2" from now on, connects R5 directly to the =ve pole of the battery when the 120Vac is ABSENT... true? (Q4)

b) Transistor: I don't understand what this is doing... apart from creating the "possibility" of hitting my Arduino's 5v rail with 12 volts! (I assume it won't do that, but to someone like me who only "understands" transistors as being similar to SPST relays, it looks scary!) Maybe there to provide a way to recharge the 50v 1000uF cap (which I'll name "C1" for future discussion) when a voltage returns above R5, after the brief outage while relays operate. I understand the transistor so poorly that I can't even ask a real question, so Q5 is just "What's the transitor there for/ what does it do?"

c) The connection of the battery to the transformer: It seems a shame that the battery is only charged by half of each AC cycle. I presume there was some reason that the connection above the diode above R1 and the connection from the negative side of the battery couldn't go "after" the bridge, and thus benefit from both halves of each cycle. If there IS a reason, I'm content to be told "there is a reason"... I don't need the details. Q6: Did the connection have to be "above" the bridge?

=== Lastly a word of caution to newbies...

While I don't understand all of it, I do believe that the circuit shown does actually work! But that doesn't mean that it will work with just any old re-chargable battery. There are a whole bunch of design considerations to master when doing UPS design, and you should become informed about them before going too far with building something like this.

Hi. There are no "dim" questions here, and yes I most definitely agree with you. A "stable" battery backup system is necessary. Unfortunately, while this system does work, it is not as stable as my needs require - so far. Ie: I require that it not "reset" on power off then power on - but it does when current/voltage flutuations are triggered by mcu events connected to other relays at the exact moment of AC power off - Otherwise it works like a charm.

As soon as I'm able, (four other projects cooking) I'll upload a schematic of what I've got so far. Considering it took about 2 hours to make, it seems someone with more experience could maybe use it as a reference point to come up with a stable system. The advantage to this kind of system is that when it does work and is hooked up to a 12 volt rechargeable battery pack your mains off/battery on time is up to you - I'm talking days not hours.

So by all means have at it, it's a "Must have" project!