RTC Grove D1307 & mini RTC DS3231
Both RTC modules use address 0x68 (default) for I2C exchange.
Modification is needed in the sample from SetTimeAndDisplay (arduino) by setting the following:
- // original function description deleted
- /****************************************************************************/
- #include <Wire.h>
- #include "DS1307.h"
- DS1307 clock; //define a object of DS1307 class
- void setup()
- {
- SerialUSB.begin();
- Wire.begin(16,17); // specify the software defined I2C pins 16-SDA 17-SCL
- // clock.begin(); comment out original begin() method otherwise
- // pin21 (SDA) and pin20 (SCL) are declared in Wire
- clock.fillByYMD(2014,10,18);//Jan 19,2013
- clock.fillByHMS(15,15,30);//15:28 30"
- clock.fillDayOfWeek(SAT);//Saturday
- clock.setTime();//write time to the RTC chip
- }
- void loop()
- {
- printTime();
- }
- /*Function: Display time on the serial monitor*/
- void printTime()
- {
- clock.getTime();
- SerialUSB.print(clock.hour, DEC); // use SerialUSB class to print
- SerialUSB.print(":");
- SerialUSB.print(clock.minute, DEC);