Problems setting RTC DS3231 by Linux system

Hallo,

when I use the TimeSerial eample of the Time.h library i can sync my Arduino Uno with my Linux system time by entering:
"date +T%s\n > /dev/ttyACM0" in the Linux terminal.
This works quiet well but there is a delay of exactly one houre (I guess it has something to do with time-zones?)

Can you help me formating a terminal command to sync time with the SetSerial example of the DS3232RTC.h?

/*----------------------------------------------------------------------*
 * Display the date and time from a DS3231 or DS3232 RTC every second.  *
 * Display the temperature once per minute. (The DS3231 does a          *
 * temperature conversion once every 64 seconds. This is also the       *
 * default for the DS3232.)                                             *
 *                                                                      *
 * Set the date and time by entering the following on the Arduino       *
 * serial monitor:                                                      *
 *    year,month,day,hour,minute,second,                                *
 *                                                                      *
 * Where                                                                *
 *    year can be two or four digits,                                   *
 *    month is 1-12,                                                    *
 *    day is 1-31,                                                      *
 *    hour is 0-23, and                                                 *
 *    minute and second are 0-59.                                       *
 *                                                                      *
 * Entering the final comma delimiter (after "second") will avoid a     *
 * one-second timeout and will allow the RTC to be set more accurately. *
 *                                                                      *
 * No validity checking is done, invalid values or incomplete syntax    *
 * in the input will result in an incorrect RTC setting.                *
 *                                                                      *
 * Jack Christensen 08Aug2013                                           *
 *                                                                      *
 * Tested with Arduino 1.0.5, Arduino Uno, DS3231/Chronodot, DS3232.    *
 *                                                                      *
 * This work is licensed under the Creative Commons Attribution-        *
 * ShareAlike 3.0 Unported License. To view a copy of this license,     *
 * visit http://creativecommons.org/licenses/by-sa/3.0/ or send a       *
 * letter to Creative Commons, 171 Second Street, Suite 300,            *
 * San Francisco, California, 94105, USA.                               *
 *----------------------------------------------------------------------*/

"date +T%s\n > /dev/ttyACM0"
+T is no longer important because of the "year,month,day,hour,minute,second," format.
When I enter date to terminal it says: Mi 16. Nov 12:35:27 CET 2016
Is there a way to split this whith "," ?

Thanks for your help :wink:

This works quiet well but there is a delay of exactly one houre (I guess it has something to do with time-zones?)

Or daylight savings time.

Is there a way to split this whith "," ?

Yes. How depends on how you collect the data on the Arduino.

Can you help me formating a terminal command to sync time with the SetSerial example of the DS3232RTC.h?

If you expect us to find the library, and then find the example, no. If you post YOUR code, then yes.

In my first post you can find all Information on how the time has to be formated for the library....

  • Set the date and time by entering the following on the Arduino *
  • serial monitor: *
  • year,month,day,hour,minute,second, *
  • Where *
  • year can be two or four digits, *
  • month is 1-12, *
  • day is 1-31, *
  • hour is 0-23, and *
  • minute and second are 0-59.

Source

The rest of the code should not be important to answer my little question.
One way to solve this could be sending the linux time and format it in the Arduino code but i want to know if there is a way to send the right format directly from my linux terminal.

The rest of the code should not be important to answer my little question.

So, you are looking for a way to manipulate the output of the date command on the PC?

Have you looked at the man pages?

I dont know what you mean by man pages :confused:
But im studying the "date --help" command on PC-Terminal right now.

Well i guess ive got it:

date +%Y,%m,%d,%H,%M,\n > /dev/ttyACM0

should work on Linux-Terminal for setting system time to SetSerial exaple of this DS3231 library.