Hi, I'm trying to set the RTC on the wildfire but I'm having some trouble. I pulled most of this code from the Angular Clock example code but it isn't working. One issue I found is that the rtc.setDateTime call in the Angular example code doesn't match the function signature in MCP7941x.h (you'll see that the .h file hasvoid setDateTime ( byte second, byte minute, byte hour, byte dayOfWeek, byte dayOfMonth, byte month, byte year );
While the Angular Clock code attempts to call this without passing in dayOfWeekrtc.setDateTime(tm.Second,tm.Minute,tm.Hour,1,tm.Day,tm.Month,tm.Year);
Even after correcting for this I still can't seem to set the RTC. Or maybe I'm setting it but just unable to pull the time from it? Here's my code, any assistance would be appreciated.
#include <Wire.h>
#include <Time.h>
#include <WildFire.h>
#include <MCP7941x.h>
MCP7941x rtc=MCP7941x();
tmElements_t tm;
WildFire wf;
void show_time_tm(char *msg){
Serial.println(msg);
Serial.println (F("DW DD-MM-YYYY"));
Serial.print(tm.Wday, DEC);
Serial.print(F(" "));
Serial.print(tm.Day, DEC);
Serial.print(F("-"));
Serial.print(tm.Month, DEC);
Serial.print(F("-"));
Serial.println(tm.Year+2000, DEC);
Serial.println(F("HH:MM:SS"));
Serial.print(tm.Hour, DEC);
Serial.print(F(":"));
Serial.print(tm.Minute, DEC);
Serial.print(F(":"));
Serial.print(tm.Second, DEC);
Serial.println();
}
void setup(){
Serial.begin(9600);
Wire.begin();
wf.begin();
delay(1000);
rtc.enableClock();
byte ss, mm, hh, dW, dM, MM, YY;
ss = 0;
mm = 0;
hh = 11;
dW = 6;
dM = 1;
MM = 12;
YY = 15;
rtc.setDateTime(ss,mm,hh,dW,dM,MM,YY);
rtc.getDateTime(&tm.Second,&tm.Minute,&tm.Hour,&tm.Wday,&tm.Day,&tm.Month,&tm.Year);
show_time_tm("RTC Clock set");
}
void loop () {
show_time_tm("RTC Clock Time:");
delay(5000);
}
Running this I don't get the date and time I put in, and the time doesn't advance. Instead I get the following output, with all sorts of values that don't make sense (like the 45th hour of the 25th month) and never change. What am I missing?
RTC Clock set DW DD-MM-YYYY 7 45-25-2165 HH:MM:SS 45:85:85 RTC Clock Time: DW DD-MM-YYYY 7 45-25-2165 HH:MM:SS 45:85:85 RTC Clock Time: DW DD-MM-YYYY 7 45-25-2165 HH:MM:SS 45:85:85