Power Fail Logger by Microrusty

From media_wiki
Jump to: navigation, search
Version 1.0 Copyright © Microrusty.com 2021    

Latest Release : 04/12/2021
Software written By Jim Merkle and Rusty Cain
Hardware design by Rusty Cain

   Notes:                                                           
 The program only writes to the SD Card when there is a change in the AC Power Status from Power Good to Power Failure back to Power Good.      
 To set the DS3231 RTC You must use another program called : DS3231-Set-Time-Date.ino See link below for How to set.
 Serial Console Settings:  9600 Baud 8 bit.

Program creates a file with the filename "REBOOTS.TXT" that captures each time the system is power cycled.

Example of REBOOTS.TXT file: 
 System Rebooted Date : 04/10/2021    Time : 14:31:37
 System Rebooted Date : 04/10/2021    Time : 17:02:21
 System Rebooted Date : 04/10/2021    Time : 20:24:53

The program checks the RTC Board and SD Card reader to ensure both devices are working.
Program sends SD Card reader status to console port.
Program sends power status to console port.

Example : 
 Initializing SD card...Setting up logging time
 Power Good
 Data written to file:
 Power Good 
Program also creates a file called DATALOG.TXT that captures the Power status with date & time. 
Example of DATALOG.TXT file: 
 Power Good : Date : 04/10/2021    Time : 17:02:21
 Power Bad  : Date : 04/10/2021    Time : 17:08:36
 Power Good : Date : 04/10/2021    Time : 20:24:53
Features
 Microchip Atmel ATMEGA328P Microcontroller
 16-MHZ Crystal Clock.
 ICSP interface uses USBTiny for programming the Microcontroller
 UART Communication Module (RS232)
 SPI Communication ATmega328P
 I2C Communication Module
 SPI SD Card for data logging power outages
 I2C Real Time Clock with date and time
 Time Stamp provides year, month, day, hours, minutes, seconds 
 Automatic switching to battery on main power loss. 
 Captures Power Failures with time and date stamp written to SD Card.
 Captures Power Restored with time and date stamp written to SD Card.
 Captures system resets with time and date stamp written to SD Card.  
 
 Three time log registers triggered from battery switch-over as well as input driven events.
 Featuring clock output and two independent interrupt signals.
Libraries used:
 #include <Wire.h>             // For I2C Interface SDA SCK
 #include <ds3231.h>           // For the DS3231 RTC library
 #include <SPI.h>              // SPI Interface that the SD card module will use
 #include <SD.h>               // for the SD card
Download the libraries using the Arduino IDE refer to: Download the Drivers in Setting Time and Date for the DS3231 RTC

PowerLogger-Top.PNG

mid

Power Fail Logger by Microrusty

Initializing the Microcontroller

Setting Time and Date for the DS3231 RTC

Programming Power Fail Logger with Arduino IDE

Installation and use


Main Page