Try this, it's similar to the code from the playground example but it does not use any data from the serial port to set the time. If this sequences ok then you need to look at what is coming down the serial port.
#include <DateTime.h>
#include <DateTimeStrings.h>
#define TIME_HEADER 255
unsigned long count = 1254422090; // a starting count
void setup(){
Serial.begin(19200);
pinMode(13,OUTPUT); // we flash the LED each second
DateTime.sync(count);
}
void loop(){
unsigned long prevtime;
prevtime = DateTime.now();
while( prevtime == DateTime.now() ) // wait for the second to rollover
{
digitalWrite(13,!digitalRead(13)); // toggle the LED
delay(250);
}
DateTime.available(); //refresh the Date and time properties
digitalClockDisplay( ); // update digital clock
Serial.print( TIME_HEADER,BYTE); // this is the header for the current time
Serial.println(DateTime.now());
while(Serial.available() )
Serial.print((char)Serial.read()) ;
Serial.println();
}
void digitalClockDisplay(){
// digital clock display of current date and time
Serial.print(DateTime.Hour,DEC);
printDigits(DateTime.Minute);
printDigits(DateTime.Second);
Serial.print(" ");
Serial.print(DateTimeStrings.dayStr(DateTime.DayofWeek));
Serial.print(" ");
Serial.print(DateTimeStrings.monthStr(DateTime.Month));
Serial.print(" ");
Serial.println(DateTime.Day,DEC);
}
void printDigits(byte digits){
// utility function for digital clock display: prints preceding colon and leading 0
Serial.print(":");
if(digits < 10)
Serial.print('0');
Serial.print(digits,DEC);
}
The code will print incoming serial data in this format:
18:35:28 Thursday October 2
ÿ1254422128
18:35:29 Thursday October 2
ÿ1254422129
18:35:30 Thursday October 2
ÿ1254422130
asdfasdf << this is data received on the serial port
18:35:31 Thursday October 2
ÿ1254422131