Commit e2472204 authored by Patrick's avatar Patrick

rp_rtc example

parent 76cfd77c
// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
#include <red_peg.h>
red_peg RP;
void setup () {
Serial.begin(115200);
Serial.println(F("start rp_rtc_ds1307"));
RP.begin();
}
void loop () {
t_SensorData the_time = RP.get(RTC);
if (the_time.sensor == RTC) {
// print the current time in ISO 8601 format
Serial.print(the_time.y);
Serial.print("-");
Serial.print(the_time.m);
Serial.print("-");
Serial.print(the_time.d);
Serial.print("-");
Serial.print("T");
Serial.print(the_time.hh);
Serial.print(":");
Serial.print(the_time.mm);
Serial.print(":");
Serial.print(the_time.ss); // DS1307 has whole secconds only
// assume UTC timestamp
Serial.print("Z");
Serial.println();
} else {
Serial.println(F("no RTC message received. \nLast message is:"));
RP.print_data(the_time);
}
delay(5000);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment