Set RTC date and time

How it's done

Open Arduino IDE with code you uploaded in step 4.

Line 19 starts with "//". These characters are used for comments, meaning that compiler will ignore that line.


This line is used to set date and time. It is inside setup function, which means that it will be executed just once when Arduino is started.

To set time, change values and delete "//" at line 19:


In this example 30 represents seconds, 9 - minutes, 11 - hours, 3 - day in week starting from Sunday, 5 - day of month, 4 - month and 16 - year.

Make changes to this line in order to set current date and time.

Upload code again like in step 5.

Activity Q&A

Need help with this activity?Add the first post