Pages: [1] 2   Go Down
Author Topic: Hardware ideas for power outage notification?  (Read 988 times)
0 Members and 1 Guest are viewing this topic.
UTC-5
Offline Offline
Jr. Member
**
Karma: 0
Posts: 99
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have problems with occasional power outages at my house. Usually it happens during a large storm, but on Sunday morning it went out for no discernable reason (my whoe block lost power). I live at the bottom of a hill, so I have a lot of moisture and rely on two sump pumps to keep the basement dry. While I have battery powered backup pumps, I need to know when the power goes oit so I can get a generator going to power the mains. If the power is out for less than a few hours, The backup sumps are fine though.

I would like to know when my power goes out while I'm away from home, and aso when it comes back on.  That way if it comes back on, I won't have to rush home to ensure the pumps keep working.

I have a GPRS/GSM shield and am planning to send myself a text message to let me know when the power goes out, and when it comes back up. I need some help figuring out how to power the arduino though. Ideally, I'd like to have the arduino always running on AC power, but fall back to a battery when the power goes out, without interruption. My thought is to also split the line power before it goes into the Arduino and also send 5v into a pin, which will trigger a message when here is a change from HIGH to LOW, or vice-versa, meaning the power went out, or came back on.

What's a simple way of powering the Arduino in this situation?
Logged

UTC-5
Offline Offline
Jr. Member
**
Karma: 0
Posts: 99
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is there a way to have the Arduino always run off the battery, but have the battery simultaneously charging while power is connected?
Logged

UK
Offline Offline
Tesla Member
***
Karma: 135
Posts: 7695
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes. I would run the Arduino from a lead-acid battery (they are practically bullet proof) and keep the battery topped up with a trickle charger. Use a 12v battery as 6v is too low for the power input to the Arduino and too high for the Vin pin (which needs 5v). A second-hand car battery might be cheap option.

...R
Logged

Kansas City
Offline Offline
Jr. Member
**
Karma: 0
Posts: 89
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Love the idea of this project.  I have a salt water fish tank at home that needs power all the time.  When I have a power failure I have about an hour maybe two tops to get home and hook up the generator before things start going south.

Typically my PC and cable modem, switch etc. are all on a UPS and it'll sms me when power is out but if a tree falls over and takes out the power as well as the cable line I'd get no notifications.

How much does a GPRS/GPS unit cost to run?  I imagine a sim card with a cell phone carrier?
Logged

Anchorage, AK
Offline Offline
Edison Member
*
Karma: 42
Posts: 1176
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here's what I would do:  (see attached schematic)

The AC PSU in this case would be some form of battery charger.  Generally, its voltage output would be higher than the full charge voltage of the battery, so by diode-isolating the charger from the battery, you get a tap from the charger that won't be active (from the battery) when the PSU is offline.

To bring the voltage down to something that the microcontroller can cope with, I used a 3.3v Zener diode, along with a cap to ignore nuisance alarms if the power drops for very short times.

The 1k "load" resistor literally represents the load device -- your Arduino project.  It's not a literal component.

Here's the Falstad circuit sim file in case you want to play with the sim.  (In the sim, there's an additional diode from the 12v source to the load, since the simulator doesn't like voltage sources trying to "charge" other voltage sources.  It's not something that should be in the real circuit if the battery is rechargeable.)

Code:
$ 1 5.0E-6 10.20027730826997 50 5.0 50
R 240 176 208 176 0 0 40.0 16.0 0.0 0.0 0.5
R 240 256 208 256 0 0 40.0 12.0 0.0 0.0 0.5
s 240 176 304 176 0 0 false
d 240 256 304 256 1 0.805904783
d 304 176 304 256 1 0.805904783
r 304 176 368 176 0 4700.0
z 368 256 368 176 1 0.805904783 3.3
g 368 256 368 272 0
r 304 256 304 336 0 1000.0
g 304 336 304 352 0
c 416 176 416 256 0 1.0E-6 3.259522655061203
w 368 256 416 256 0
w 368 176 416 176 0
O 416 176 464 176 0
O 240 176 240 144 0
O 240 256 240 224 0
O 304 256 336 256 0
x 142 182 186 185 0 12 AC PSU
x 144 261 181 264 0 12 Battery
x 241 302 283 305 0 12 Load ->
x 365 151 422 154 0 12 3.3v Zener
w 384 192 400 160 0
x 488 183 551 186 0 12 POK Signal
o 14 64 0 34 20.0 9.765625E-5 0 -1
o 15 64 0 34 20.0 9.765625E-5 1 -1
o 16 64 0 34 20.0 9.765625E-5 2 -1
o 13 64 0 34 5.0 9.765625E-5 3 -1


* acloss.png (4.66 KB, 432x247 - viewed 45 times.)
Logged

UTC-5
Offline Offline
Jr. Member
**
Karma: 0
Posts: 99
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes. I would run the Arduino from a lead-acid battery (they are practically bullet proof) and keep the battery topped up with a trickle charger. Use a 12v battery as 6v is too low for the power input to the Arduino and too high for the Vin pin (which needs 5v). A second-hand car battery might be cheap option.

...R

Thanks. That's not a bad idea. I thought about using the cheapest UPS battery backup I can find, seeing that most are made for computers, and expect a far larger draw than an Arduino. I would then use a USB wall wart into a pin in the Arduino (from the wall, not the UPS) to detect whether the power is on or off.

I also did more searching after posting this thread and found this shield. It allows you to use a Lithium Polymer battery with the Arduino, and the Arduino will keep it charged while the battery isn't being used. I have my doubts that it would power the Arduino for more than a few hours from even the biggest battery they have (I think 2000mAh), but all I really need is for it to stay on long enough to send out an SMS message that says "The power has gone out". I can have the Arduino send out a "System is powering up" message in the setup so when it comes back on, I'll get my 'power restored' notification.

How much does a GPRS/GPS unit cost to run?  I imagine a sim card with a cell phone carrier?
The one I have is the Seeedstudio unit that costs $60. For service, the best deal I can find is a pre-paid SIM from T-Mobile that costs $10 and is good for 3 months. The actual SMS messages are $0.10 each, so you get 100 messages over a 3 month period. I really wish they had low-use, SMS-only options that could get the price down even more, but that's the best I can find. Even if they just made the period last a year, rather than 3 months, it would be more than I'd ever need.

Here's what I would do:  (see attached schematic)
Thanks for your suggestion, but that looks way beyond my abilities. I'm not a total beginner, but I haven't graduated much into more medium to complicated understanding of the programming or the electronics.
Logged

UTC-5
Offline Offline
Jr. Member
**
Karma: 0
Posts: 99
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I would run the Arduino from a lead-acid battery...

As soon as I posted my reply above and re-read it, an idea hit me: I could tap off of the battery used for one of my backup sump pumps. It's already there, and it's already being kept charged by that system.

I'd still need a way to detect when the main power goes out, but the USB wall wart into an Arduino pin should do it.

Logged

Anchorage, AK
Offline Offline
Edison Member
*
Karma: 42
Posts: 1176
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You still have to verify the voltage from the USB wall wart is never higher than the Arduino's power supply.  Which means you're back to the circuit I posted above, plus you'll need a diode to Vcc to protect the Arduino if its supply is missing or the battery is really low but AC is available (if/when that can happen.)  smiley-wink
Logged

UTC-5
Offline Offline
Jr. Member
**
Karma: 0
Posts: 99
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So help me understand SirNickity. Let's assume I power the Arduino off my backup sump pump's 12v deep cycle lead acid battery.

I assume a standard 5v power regulator between the battery and the Arduino (I've made a few breadboard Arduinos, I'd assume I wire them the same, but have the power coming from the battery rather than a wall wart). Then the USB wall wart could be regulated down to 3.3 volts.

If I go with the deep cycle battery, I'm unconcerned about the battery ever being low. The sump pump system warns me if the battery needs attention. It's usually something like I need to add water to the cells. As long as I respond to the alerts, the system works.

I am probably missing something. What are your thoughts?
Logged

Offline Offline
Edison Member
*
Karma: 30
Posts: 2494
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If the wallmart spit out 5.8v for example ...

I know vcc can just about handle a 6v input, wether or not a digitital pin can handle 6v .. no idea.

But, place a diode or 2, to lower the voltage or a voltage divider, or a zener... if you're worried, if digitalRead(wallmartpin) is HIGH we have power, you might wish to use a capacitor to stop any unwanted noise which might give a false reading along with a bleed resistor or it will think power is on when it's not... a 1k resistor would give it 2 - 3 seconds or so to make sure power is really off not just flickred on and off .   After the cap bleeds, arduino sees low and you do what you need.


I can draw a circuit....
Logged

Anchorage, AK
Offline Offline
Edison Member
*
Karma: 42
Posts: 1176
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I assume a standard 5v power regulator between the battery and the Arduino (I've made a few breadboard Arduinos, I'd assume I wire them the same, but have the power coming from the battery rather than a wall wart). Then the USB wall wart could be regulated down to 3.3 volts.

Yes, you can build your monitor circuit the same way you would with a breadboard Arduino.  In theory, since the wall-wart would always* be lower voltage than the 5v regulated from the battery, it would work fine that way.

But, you shouldn't assume that two independent power sources are going to be completely predictable.  The most likely case is that you'll make a mistake some time -- maybe during your installation, or during testing, or maintenance -- or something could break and conditions won't be what you expect.  It may sound overly cautious, but things like that tend to happen quite frequently, and with a couple additional diodes, you've protected your circuit from that inevitability.

Take a look at this sample schematic.  (Sorry, the sim tool is the only thing I have on this computer, so use your imagination a bit.)

... continued ....


* diag1.png (7.03 KB, 614x293 - viewed 36 times.)
« Last Edit: October 22, 2013, 10:02:38 pm by SirNickity » Logged

Anchorage, AK
Offline Offline
Edison Member
*
Karma: 42
Posts: 1176
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK, now...  The 12v source in the diagram is your battery.  You're going to use an LM7805 to regulate that down to 5v.  In addition, you'll have a wall wart with a 3.3v output (or you can use a 5v wall-wart and regulate down to 3.3v, but why not just use a 3.3v wart instead?)  Good so far?

Now, the proper way of doing this would be to hook up the 12v side, let the Arduino come online, and then connect the 3.3v input to whatever input pin (I'm using D13 here.)  As long as you do this, and the 12v battery never goes away, you're fine.  But, if you ever end up with the battery not being connected -- either +12v or Gnd -- you will potentially destroy at least the input pin, but possibly also the Arduino itself and the LM7805.

The reason why is because the Arduino will attempt to power itself through the input pin if the main power supply is not there.  The pin's current limits will likely be exceeded, and things will be damaged.

The diode from the 3.3v wart to the 5v power rail guarantees that if the 5v power supply ever goes away, power will flow through that diode to Vcc, and not backwards through the AVR itself.

Likewise, by placing the "backwards" diode around the LM7805, you ensure the regulator's input is always higher than its output also.  That way, if the 3.3v supply is powering the circuit (because the 12v battery is absent), current flows through the left diode and both sides of the LM7805 are roughly equal, making damage to the regulator far less likely.

A couple parts, that costs less than a quarter, and the whole thing is considerably more bullet-proof.  One problem we haven't covered yet is this:  If the batteries are offline, and power is coming from the wall-wart, there's nothing stopping it from going past the input of the regulator, and upstream to anything that might be there -- like the charger or a critically depleted battery, or a short to ground.  Well, the charger should be diode-isolated so no current should flow there.  The flat battery would be essentially a short to ground, so make sure the wall-wart is protected against short-circuits or over-current and you're good to go.

Going way back to my previous post... Since you're using an existing battery/charging system:  As I said, the charger will almost definitely have a diode in it to make sure power flows out of the charger and into the battery, and never the reverse.  This would be helpful to you, because the charger's output terminals will have voltage when the charger is on, but also when it's off, because of the battery.  You would need to tap from the charger before its output diode to sample the voltage without reading backflow from the battery.

However... there's a good chance you won't be able to tap the charger before the diode without tearing into its guts -- which is probably not something you want to do.  So, using an external power source (like the wall-wart) is probably your next best option.  But you should use those two extra diodes to protect the circuit against faults.  smiley-red
Logged

UTC-5
Offline Offline
Jr. Member
**
Karma: 0
Posts: 99
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for that explanation, I think I understand much better.

I was also thinking I could isolate the USB wall wart by having it power a relay. The wart would hold the relay closed, and a loss of power would open the relay. Then it would work as a simple switch, and power would never leak into the Arduino itself. A change in state would cause the Arduino to send an appropriate SMS message.

A relay is more expensive than diodes, but still a cheap way to build this.
Logged

Adelaide, Australia
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

1. Power for the Arduino comes via two diodes...

DC from mains --------->|--------+----------- Regulator-------- Arduino
                                                                    |
DC from Battery--------->|--------

2. Signal for Arduino comes via resistive divider to an analog input pin...

DC from mains----------R1------+-------- Arduino Analog input
                                                                   |
                                                                  R2
                                                                   |
                                                                 Ground

Then a loop.... if the analog input value drops to a low level, Mains supply has failed

You could also have a second analog input monitoring the Batteries.... so you know if the Power failure was long enough to drain them

Also, thinking outside the square.... Does your generator have an electric start ??
Could it be possible for the Arduino to start the generator as the backup batteries get low... ??
Logged

UTC-5
Offline Offline
Jr. Member
**
Karma: 0
Posts: 99
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Also, thinking outside the square.... Does your generator have an electric start ??
Could it be possible for the Arduino to start the generator as the backup batteries get low... ??

No, it's a fairly small generator, I think it runs at 5250 watts, peak is 6000. It's enough to run the sumps, two fridges, a freezer, the garage door opener, some lights, and a few other small things. It's normally stored in the tool shed, so I have to dig it out, hook it up, and start it. I'm considering getting one of these to be able to hook it into the house's electrical system, but even with that I'd have to manually flip the switch to change over from mains to generator.

I like the idea though!
Logged

Pages: [1] 2   Go Up
Jump to: