SparkFun gator:RTC Hookup Guide
MakeCode Examples
Now that you have added the gator:particle extension to the Editor, lets start with some example code. Plug the micro:bit into your computer using an USB micro-B cable after you have assembled your hardware with the instructions from the previous section. The micro:bit should appear on your computer as a removable storage device.
To upload new code, this is where you will be copying the downloaded .hex file to later.
Block Functions
: ___
: ___
- _____
HH:MM:SS in a 12-hour format. This block doesn't prohibit invalid entries (e.g 13:01:53 AM). Double check the time that is being set is valid; otherwise, the RTC may respond improperly when called upon.
HH- Integer value for the our in 12-hour format (i.e. The 3rd hour after 12 should be entered as3). There is also a slider that can be easily used.0to12
MM- Minutes in integer format (i.e. The 20th minute past the hour should be entered as20). There is also a slider that can be easily used.0to59
SS- Seconds in integer format (i.e. The 30th second past the minute should be entered as20). There is also a slider that can be easily used.0to59
12-Hour Period- Drop down menu to select the 12-hour period.AM- Ante meridiem (i.e. before noon).PM- Post meridiem (i.e. after noon).
, _____
- ___
- 20___
Weekday, Month - DD - 20YY. This block doesn't prohibit invalid entries (e.g Feb 29th for leap years, Sept. 31st, or YY = 100). Double check the date that is being set is valid; otherwise, the RTC may respond improperly when called upon.
Weekday- Drop down menu to select the weekday.MondayTuesdayWednesdayThursdayFridaySaturdaySunday
Month- Drop down menu to select the month.JanuaryFebruaryMarchAprilMayJuneJulyAugustSeptemberOctoberNovemberDecember
DD- Day in integer format (i.e. The 3rd should be entered as3). There is also a slider that can be easily used.0to31
YY- Year in integer format (i.e. The 2019 should be entered as19). (The calender is only leap-year accurate for the years 2000 to 2099.)0to99
set _____ to ___
This block should allows users to change a specific component of time. This block doesn't prohibit invalid entries. Double check the that the modification is valid; otherwise, the RTC may respond improperly when called upon.
Unit of Time- Drop down menu to select the unit of time you want to change.SecondsMinutesHoursDateMonthYearWeekday
Value- Value in integer format.Seconds- Input an integer:0to59
Minutes- Input an integer:0to59
Hours- Input an integer:0to12(if in 12-hour format)0to24(if in 24-hour format)
Date- Input an integer:0to31
Month- Input an integer:0to12
Year- Input an integer:0 to 99
Weekday- Input an integer:0-Monday1-Tuesday2-Wednesday3-Thursday4-Friday5-Saturday6-Sunday
value of _____
This is a value block that returns the value for the stored component of time from the RTC.
Unit of Time- Drop down menu to select the unit of time you want to retrieve.Seconds- Returns an integer:0to59
Minutes- Returns an integer:0to59
Hours- Returns an integer:0to12(if in 12-hour format)0to24(if in 24-hour format)
Date- Returns an integer:0to31
Month- Returns an integer:0to12
Year- Returns an integer:0 to 99
Weekday- Returns an integer:0-Monday1-Tuesday2-Wednesday3-Thursday4-Friday5-Saturday6-Sunday
text of weekday
This is a value block that returns a string for the weekday.
time in HH:MM:SS
This is a value block that returns a string for the time stored by the RTC in a HH:MM:SS format.
date in mm-dd-yyyy
This is a value block that returns a string for the date stored by the RTC in a mm-dd-yyyy format.
button timestamp in HH:MM:SS
This is a value block that returns a string for the previous time, marked by the RTC timestamp button in a HH:MM:SS format.
button timestamp in mm-dd-yyyy
This is a value block that returns a string for the previous date, marked by the RTC timestamp button in a mm-dd-yyyy format.
set time to ___:___:___ in 24 hour mode
This block allows users to set the time stored in the RTC. The time should take the following format: HH:MM:SS in a 24-hour format. This block doesn't prohibit invalid entries (e.g 25:01:53). Double check the time that is being set is valid; otherwise, the RTC may respond improperly when called upon.
HH- Integer value for the our in 24-hour format (i.e. The 3rd hour after midnight should be entered as3). There is also a slider that can be easily used.0to24
MM- Minutes in integer format (i.e. The 20th minute past the hour should be entered as20). There is also a slider that can be easily used.0to59
SS- Seconds in integer format (i.e. The 30th second past the minute should be entered as20). There is also a slider that can be easily used.0to59
time in yyyy-mm-ddThh:mm:ss
This is a value block returns a string for the time stored by the RTC in ISO8601 format.
date in dd-mm-yyyy
This is a value block that returns a string for the date stored in the RTC in dd-mm-yyyy format.
button timestamp in yyyy-mm-ddThh:mm:ss
This is a value block returns a string for the previous time, marked by the RTC timestamp button in ISO8601 format.
button timestamp in dd-mm-yyyy
This is a value block returns a string for the previous time, marked by the RTC timestamp button in dd-mm-yyyy format.
value of button timestamp in _____
This is a value block that returns a specific component of timestamp stored by the RTC.
Unit of Time- Drop down menu to select the unit of time you want to retrieve from timestamp.Seconds- Returns an integer:0to59
Minutes- Returns an integer:0to59
Hours- Returns an integer:0to24(in 24-hour format)
Date- Returns an integer:0to31
Month- Returns an integer:0to12
Year- Returns an integer:0 to 99
set to _____ time
This block allows users to change the time format between a 12-hour and 24-hour.
Standard- Changes the time to a 12-hour format.Military- Changes the time to a 24-hour format.
Basic Setup and Time Retrieval
Below, is a simple example of how to take simple readings from the RTC. To use this example, there are multiple options for accessing the .hex file:
- Replicate the block functions from the display below to copy the example project. Then download the 
.hexfile. - Expand the display widow to pull up the example project. Then download the 
.hexfile. - Use this link to pull up the example project. Then download the 
.hexfile. - Download the 
.hexfile from the button below or the link on the bottom of the display. 
The output is redirected over the serial port to avoid conflicts on pins P0 and P1, which are also used for serial communication. To read the sensor values, pull up your favorite serial terminal emulator. Then, connect to the serial port that the micro:bit is on; the default baud rate is 115200 bps. Below, is an example of an output of the time stored by the gator:RTC using the example code.
In the read out from the RTC, you can see with the 1.5 and 0.8 second delays that the resolution of the RTC is limited to one second intervals. (Between the change from a 1.5 to a 0.8 delay, the seconds value was reset back to 0 seconds.) Additionally, you should note the various subtleties in timing formats for the functions used.
If you are confused to how the timestamp button works, the read out in the forever loop prints out both the current time and the timestamp of the last button press. In the example readings, you can see the timestamp change from a few button presses.

