If you buy new DS3231/DS3232 RTC module, usually the time
stored in internal memory (SRAM) is the manufacturer's default time (US time).
Well, if you want to set RTC time in a way that is easy and quick using Arduino,
you can follow these tips. As preparation, make a prototype circuit as in previous article, HOW TO HANDLE RTC DS3231/DS3232 WITH ARDUINO, and make sure necessary libraries already
downloaded and installed into Arduino ‘libraries’ folder. Regarding what is
needed library you can read in the article.
Easy Way to Setting Time RTC DS3231 / DS3232 with Arduino
When ready, open the example sketch 'setserial' via ‘File-Examples-DS3232RTC-setserial’
menu. This sketch is intended you can set time in RTC DS3231/DS3232. This
program is already finished so you can simply upload it to Arduino, and stayed setting
RTC time through the Serial Monitor window (Tools-Serial Monitor menu).
If you've successfully uploaded the sketch, you will find a
digital clock is displayed in Serial Monitor window. If there is a strange
character who appears in the window, you should change baudrate of serial communication
become115200 bps (must be same with baudrate in Arduino sketch). Take a look lower
right corner of Serial Monitor window. If there is no listed numbers of ‘115200’
bps, you have to change it first.
To replace the RTC time, it’s easy enough, just enter the
following code:
yy, m, d, h, m, s
with 'yy' is the year (taken last two digits), for example
if 2016 is written only '16', 'm' is the month and 'd', 'h', 'm' and 's' are
the days, hours, minutes and seconds. So if for example today was 6:22:10 and
October 24, 2016, then the characters you enter into Serial Monitor window is
'15, 7,21,8,45,30 '. Just simpy enter it into edit box beside 'Send' button then
press the button to enter the new time settings to RTC DS3231 / DS3232 internal
memory.
If so, then there should be a notification that the time RTC
has been successfully replaced
To make sure the time change has been successfully
performed, please turn off your Arduino and turn it on again. Supposedly the time
has changed now.
ConversionConversion EmoticonEmoticon