hy
hi I have a problem
i can not sync my rtc with ntp so that if the line falls the system keeps tracking time and seconds with RTC
It happens to me that every time you reset what is wrong?
void setup()
{
Serial.begin(9600);
while (!Serial) ; // Needed for Leonardo only
delay(250);
pinMode(segmentClock, OUTPUT);
pinMode(segmentData, OUTPUT);
pinMode(segmentLatch, OUTPUT);
digitalWrite(segmentClock, LOW);
digitalWrite(segmentData, LOW);
digitalWrite(segmentLatch, LOW);
previousMillis = millis();
Serial.println("Start Orologio collegamento in attesa ");
if (Ethernet.begin(mac) == 0) {
// while (1) {
Serial.println("Failed to configure Ethernet using DHCP");
delay(10000);
// }
}
Serial.print("IP number assigned by DHCP is ");
Serial.println(Ethernet.localIP());
Udp.begin(localPort);
Serial.println("waiting for sync");
setSyncProvider(getNtpTime);
if (connection != false) {
//RTC.set(getNtpTime());
// setTime(05, minute(), second(), 13, 2, 2009); //set the system time to 23h31m30s on 13Feb2009
// RTC.set(now()); //set the RTC from the system time
Serial.println("OK RTC");
}else {
Serial.println("RTC non sincronizzato");
}
setSyncInterval (timesyncro);
}
//time_t prevDisplay = 0; // when the digital clock was displayed
void loop()
{
if (connection=true) {
setTime(hour(), minute(), second(), day(), month(), year()); //set the system time to 23h31m30s on 13Feb2009
RTC.set(now());
}
// unsigned long currentMillis = millis();
// if((currentMillis - previousMillis > (interval * 3600000)) || (timeupdate == 1)) {
// previousMillis = currentMillis;
// Serial.print("PROVaaaaaaaaaaaaaaaaAAAAAAAAAAAAAAAAAAA ");
// Ethernet.maintain();
// setSyncProvider(getNtpTime);
// digitalClockDisplay();
// }
//
tmElements_t tm;
RTC.get;
minuti = minute();
ore = hour()*100;
digitalClockDisplay();
delay (1000);
showNumbersecondi(ore+minuti); //Test pattern
}