RTC - Using DS1307/DS3231 RTC as time source

Preparation

  • Ameba x 1
  • DS1307/DS3231 RTC x 1

Example

In this example we use DS1307/DS3231 RTC module as time source. The main difference between DS1307 and DS3231 is that DS3231 provides higher precision. The following two libraries are required:
Time:
https://github.com/ambiot/amb1_arduino/raw/master/Arduino_libraries/Time-1.0.1.zip
The detailed description of DS1307/DS3231 please refer to the example of DS1307/DS3231.

If you are using TinyRTC, please connect the wires as follows:
1

As for DS3231, please refer to the figure below:
2

RTL8710 wiring diagram:
2

Open the sample code in “File” -> “Examples” -> “AmebaTime” -> “TimeRTC”, compile and upload the sample to Ameba and press reset button. Then open the serial monitor, you should see messages similar to the figure:
3

Code Reference

This example uses RTC as time source:

setSyncProvider(RTC.get)

RTC.get() returns current time in unix-like format, and the returned value would be the time source of Time library.

Please confirm that QQ communication software is installed