Difference between revisions of "Programming Power Fail Logger with Arduino IDE"

From media_wiki
Jump to: navigation, search
(Created page with "To Set the RTC Using the Arduino IDE copy the follow program and paste in the Arduino IDE.<br> This code can be found here:https://github.com/rodan/ds3231 #include <Wire...")
 
Line 1: Line 1:
 +
[[File:PowerLogger-PCB.PNG |200px|right]]
 +
 
To Set the RTC Using the Arduino IDE copy the follow program and paste in the Arduino IDE.<br>  
 
To Set the RTC Using the Arduino IDE copy the follow program and paste in the Arduino IDE.<br>  
 
+
DS3231 RTC Datasheet: https://datasheets.maximintegrated.com/en/ds/DS3231.pdf
 
  This code can be found here:https://github.com/rodan/ds3231
 
  This code can be found here:https://github.com/rodan/ds3231
  

Revision as of 03:10, 17 May 2021

PowerLogger-PCB.PNG

To Set the RTC Using the Arduino IDE copy the follow program and paste in the Arduino IDE.

DS3231 RTC Datasheet: https://datasheets.maximintegrated.com/en/ds/DS3231.pdf
This code can be found here: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.


Power Fail Logger by Microrusty