Pages: [1]   Go Down
Author Topic: Power Outage Timer  (Read 2062 times)
0 Members and 1 Guest are viewing this topic.
Seattle, WA
Offline Offline
Jr. Member
**
Karma: 0
Posts: 57
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm new to Arduino, but I have a project idea and I think Arduino is the answer.  I live in a rural area, and we have frequent power failures in the winter.  What I'd like is a device that you plug into the wall and detects power outages, then uses a battery backup to start a timer.  When the power comes on, a text file is written to a USB memory stick showing the date, time, and event (power off or power on).  Could use some advice on where to start.

Thanks!
Tom
Logged

Germany
Online Online
Faraday Member
**
Karma: 57
Posts: 3036
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Use an SD Card instead of USB Stick, and where do you get Date/Time from ?
There's a DataLogger shield providing just those functions: RTC + SD Card Adapter.

Then you either need a dual power supply, or you simply assume to return from Power Off after a restart, and check until when you have been alive before ( implies writing temporary info to the
RTC RAM )
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Instead of writing to a text file I was thinking about triggering a battery powered timer to start when power is lost and stopped when it comes back on and make sure it doesn't reset every time it starts.  That way you'll know the total length of power outage from the last time you checked the timer.  I would definitely like to build something like this but have no idea where to start.  I just registered today.
Logged

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 538
Posts: 27071
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Battery backed RTC chips have coin cell battery backed SRAM also (such as CR2032, 36 cents here qty 1
http://www.dipmicro.com/store/index.php?act=viewProd&productCode=BAT-CR2032) that will run the RTC for 5 or 10 years.

Write a simple sketch that reads the time once a second, and stores that time to SRAM. Can even use the 1 HZ oscillator from the RTC to signal when to read the time.
The next second, read the time and store it again, and note if just 1 second had elapsed.
When you find a time that is more than 1 second different, send out a serial message, or display on a display, the time difference found - there's your power-off time counter.

Or, get a battery powered clock and a normally closed relay. When power is on, the relay is held in the open position, when power is lost the relay reverts to the normally closed position and the clock runs for as long as the battery holds out, or until power comes back. Don't know how you'd tell when more than 12 or 24 hours had gone by, guess that would depend on the clock used.

Hearing we might have a winter that makes up for last year's relative lack of snow.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 95
Posts: 4084
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Recently I've been playing with the Microchip MCP79412 RTC. It records power down and power up times in internal registers. If you're only interested in logging power outages after the fact, as opposed to knowing about them while they are occurring, then no external backup battery, timer, etc. would be needed. As part of the initialization (setup), the sketch would check the RTC to see if an outage had occurred, and if so, save the power down and power up times. The MCP79412 has on-board battery-backed SRAM and also EEPROM. Like most, the RTC itself does require a coin cell to keep it running during outages; as CrossRoads says, these are usually good for quite a few years.

I've had a few breakout boards made to facilitate development, and am currently working on a library. If the MCP79412 RTC sounds like it would fit your application, I'd be willing to send you a board (pictures below) for the price of testing the library and letting me know how it works for you.

I'm liking the MCP79412 a lot. The DS1307 seems to be the standard go-to workhorse, and it's a fine chip, but the MCP79412 has several advantages. I've only had them running for less than a week, but they're looking more accurate than has been my experience with DS1307s, and there is the ability to trim them even closer. I also like the fact that they will run on less than 5V.

Feature MCP79412 DS1307
On-Chip Calibration ±127 ppm N/A
Alarms Dual alarms (single output) N/A
Power Fail/Restore Timestamps Yes N/A
Unique ID 64-bit ID N/A
EEPROM 128 bytes N/A
Battery-Backed SRAM 64 bytes 56 bytes
Vcc 1.8 - 5.5V 4.5 - 5.5V
I2C Interface Clock Frequency 400 kHz (Vcc ≥ 2.5V) 100 kHz
Square-Wave Output 1, 4096, 8192 or 32,768 Hz 1, 4096, 8192 or 32,768 Hz


* rtcTop.jpg (140.16 KB, 800x737 - viewed 28 times.)

* rtcBot.jpg (159.9 KB, 794x726 - viewed 28 times.)
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Offline Offline
Edison Member
*
Karma: 29
Posts: 2449
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I had a similar idea except i used a small 12v battery to power it (always with a 12v battery charger) and then i use the desktop computer's USB power supply to check for power out when it is..

the light will come on and buzzer goes off, i can also go to


www.myarduino.info (and view status directly).


But that RTC with SRAM is a really good option, i might get one soon to play with.
Logged

Seattle, WA
Offline Offline
Jr. Member
**
Karma: 0
Posts: 57
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Or, get a battery powered clock and a normally closed relay. When power is on, the relay is held in the open position, when power is lost the relay reverts to the normally closed position and the clock runs for as long as the battery holds out, or until power comes back. Don't know how you'd tell when more than 12 or 24 hours had gone by, guess that would depend on the clock used.
[/color]

That gets me thinking - just to start out, what's the mechanism (parts and accompanying code) for detecting what power source the Arduino is using?  Say, for example, a basic sketch that lights a multi-color LED in pin 13 green when using power through the USB jack and red LED if using power from the 9V battery?
Logged

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 538
Posts: 27071
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You would have to add some wires to the board to monitor the output of the LM358 that compares Vusb to Vin.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

SW Scotland
Offline Offline
Edison Member
*
Karma: 17
Posts: 1389
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In the good (or was it bad) old days of mains powered clocks they were ideal for logging outages (of minutes or hours durations).  All you had to do was ensure the clock was set to the correct time then view it several hours/days later.  If there had been an outage, the clock was slow by the total length of outage duration.  OK it wasn't rocket science but it worked.
Logged

Offline Offline
Newbie
*
Karma: 2
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am testing one of Jack's RTC boards.  As he indicates, these are really neat RTC chips, with many features.  The power up and power down logging is especially interesting for my data logging arduino's. My board has been running for ~10 days (Jack can correct me on the last time set as he did it before delivery) and I just checked the time against the NPT source.  The error is 7 seconds slow (I have not trimmed it yet -  I want to see the out of the box accuracy).
What you are looking for is included in the library Jack wrote, as an example sketch.
Duck
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 95
Posts: 4084
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

In the good (or was it bad) old days of mains powered clocks they were ideal for logging outages (of minutes or hours durations).  All you had to do was ensure the clock was set to the correct time then view it several hours/days later.  If there had been an outage, the clock was slow by the total length of outage duration.  OK it wasn't rocket science but it worked.

I always used to have an inexpensive electric (synchronous motor-driven) clock on my workbench for just that purpose. Unfortunately, the ones I've had must have been cheap as well as inexpensive, after a couple years they'd get noisy and eventually stop or not keep accurate time. I have a relatively complex microcontroller-based system in place now that will notify me via SMS of power outages as they occur, but I might also go ahead and rig up one of these RTCs into a nice little self-contained device.
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 95
Posts: 4084
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I am testing one of Jack's RTC boards.  As he indicates, these are really neat RTC chips, with many features.  The power up and power down logging is especially interesting for my data logging arduino's. My board has been running for ~10 days (Jack can correct me on the last time set as he did it before delivery) and I just checked the time against the NPT source.  The error is 7 seconds slow (I have not trimmed it yet -  I want to see the out of the box accuracy).
What you are looking for is included in the library Jack wrote, as an example sketch.
Duck

The specs on the crystals I used were 20ppm, but the three we've tried so far seem to be doing better than that, which is not something I can say of the DS1307s I have. Without any calibration, one is within 2ppm after 13 days, and another is within 5ppm after 6 days. Just sent the latter unit to tlharv this afternoon. Lost track of the numbers on the one that Duck has.
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Grand Rapids, MI, USA
Offline Offline
Sr. Member
****
Karma: 10
Posts: 276
Yes, I remember
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Lots of cool ideas here.  If you get one working please post as I might want to build one myself. You might consider having the resolution to measure short term power outages (sub 1 second).  Around here our service provider doesn't consider anything less than 30 seconds a power outage.  That is fine, but I happen to believe that any service disruption is a problem.  If it makes my computer die and my stereo loose it's presets its a problem. 

At the business I worked at this summer we had a flywheel that provided instant transitional power for our test equipment to cover short outages until the generator fired up. The flywheel has a counter that displays the number of times it has been activated.  Everyone is always surprised to see how often it runs.
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 95
Posts: 4084
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Lots of cool ideas here.  If you get one working please post as I might want to build one myself. You might consider having the resolution to measure short term power outages (sub 1 second).  Around here our service provider doesn't consider anything less than 30 seconds a power outage.  That is fine, but I happen to believe that any service disruption is a problem.  If it makes my computer die and my stereo loose it's presets its a problem. 

At the business I worked at this summer we had a flywheel that provided instant transitional power for our test equipment to cover short outages until the generator fired up. The flywheel has a counter that displays the number of times it has been activated.  Everyone is always surprised to see how often it runs.

Unfortunately, the MCP79412 RTC power down/up timestamps only record to the minute. Shorter outages will be captured, but it's not possible to tell from the timestamps whether they were one second or 20 or ...
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Pages: [1]   Go Up
Jump to: