Difference between revisions of "Power Fail Logger by Microrusty"

From media_wiki
Jump to: navigation, search
(Created page with "'''Power Fail Logger ''' Optimized for no power at the AC plug <br> Automatic switching to battery on main power loss. '''Data Sheet''' https://www.nxp.com/docs/en/ '''F...")
 
 
(18 intermediate revisions by the same user not shown)
Line 1: Line 1:
'''Power Fail Logger ''' Optimized for no power at the AC plug <br>  
+
'''Version 1.0 Copyright © Microrusty.com 2021  ''' 
  Automatic switching to battery on main power loss.  
+
Latest Release : 04/12/2021 <br>
'''Data Sheet''' https://www.nxp.com/docs/en/
+
Software written By '''Jim Merkle''' and '''Rusty Cain''' <br>
 +
Hardware design by '''Rusty Cain''' <br>
 +
 
 +
    '''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. <br>
 +
Program sends '''SD Card reader''' status to console port.<br>
 +
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'''
 
  '''Features'''
   SPI bus SD Card for data logging power outages
+
  Microchip Atmel ATMEGA328P Microcontroller
   I2C bus for Real Time Clock with date and time
+
  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  
 
   Time Stamp provides year, month, day, hours, minutes, seconds  
 
   Automatic switching to battery on main power loss.  
 
   Automatic switching to battery on main power loss.  
Line 14: Line 46:
 
   Three time log registers triggered from battery switch-over as well as input driven events.
 
   Three time log registers triggered from battery switch-over as well as input driven events.
 
   Featuring clock output and two independent interrupt signals.
 
   Featuring clock output and two independent interrupt signals.
  ISP interface uses USBTiny
 
  SPI Interface
 
  I2C interface
 
  16-MHZ Crystal Clock.
 
 
 
  
[[File:PCF85263AT-PCB.PNG |350px|left]]
+
'''Libraries used:'''
[[File:PCF85263ATBatt.PNG |350px|mid]]
+
  #include <Wire.h>            // For I2C Interface SDA SCK
[[File:PCF85263AT-RTC.PNG |350px|mid]]
+
  #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'''
 +
  
 +
[[File:PowerLogger-Top.PNG |350px|left]]
 +
[[File:PowerLogger-Bottom.PNG|350px|mid]]
 +
==[[ Power Fail Logger by Microrusty ]]==
 +
==[[Initializing the Microcontroller]]==
 +
==[[Setting Time and Date for the DS3231 RTC]]==
 
==[[ Programming Power Fail Logger with Arduino IDE]]==
 
==[[ Programming Power Fail Logger with Arduino IDE]]==
 
+
==[[Installation and use]]==
To Set the RTC Using the Arduino IDE copy the follow program and paste in the IDE.<br>
+
----
 
+
==[[ Main Page ]]==
//  https://github.com/rodan/ds3231
 
 
 
#include <Wire.h>
 
#include <ds3231.h>
 
struct ts t;
 
 
void setup() {
 
  Serial.begin(9600);
 
  Wire.begin();
 
  DS3231_init(DS3231_CONTROL_INTCN);
 
  /*----------------------------------------------------------------------------
 
  In order to synchronise your clock module, insert timetable values below !
 
  ----------------------------------------------------------------------------*/
 
  t.hour=20;
 
  t.min=40;
 
  t.sec=0;
 
  t.mday=11;
 
  t.mon=4;
 
  t.year=2021;
 
  DS3231_set(t); //Comment out after setting RTC with time & date
 
  }
 
 
  void loop() {
 
  DS3231_get(&t);
 
  Serial.print("Date : ");
 
  Serial.print(t.mon);
 
  Serial.print("/");
 
  Serial.print(t.mday);
 
  Serial.print("/");
 
  Serial.print(t.year);
 
  Serial.print("\t Hour : ");
 
  Serial.print(t.hour);
 
  Serial.print(":");
 
  Serial.println(t.min);
 
  Serial.print(":");
 
  Serial.println(t.sec);
 
  delay(60000);
 
  }
 
  void print2digits(int number){
 
  if (number >= 0 && number < 10) {
 
    Serial.write ('0');
 
  }
 
  Serial.print(number);
 
  }
 
 
 
 
 
 
 
Connect the Power Fail Logger to the Arduino uno.<br>
 

Latest revision as of 21:51, 18 August 2021

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