Gravity: I2C DS1307 RTC Module
SKU: DFR0151
Introduction
After several months "Out of Stock", DS1307 RTC module has a big upgrade. It comes with a
Gravity IIC interface, and the size is also reduced to fit miniaturization application. Gravity I2C
DS1307 RTC module is a easy-to-use Real Time Clock module. It is cheap and affordable in most
applications such as time clock, data logger, etc.. The new version DS1307 RTC module adopts
high precision crystal oscillator which reduces time error dramatically. The test conducted shows the
time error is only about 1 second in 24 hours (the average time error of Mechanical Watches is
about 20s). The module is powered by single cell CR1220 (service life: 3~5 years). It is smaller and
keeps EEPROM 4KB ROM to record information related to alarm clocks and events. Besides, you
can set the IIC address by resistance adjustment. The Gravity DS1307 RTC module uses Gravity
I2C interface and you can plug it on the DFRobot Gravity IO expansion shield directly. Cooperate
with Arduino DS1307 library developed by DFRobot, it is easy to realize functions like setting time
and time display. It can be widely used in DA (Data Acquisition).
Specification
•
•
•
•
•
•
•
•
•
•
Operating voltage: 5V
Interface: IIC/I2C (Gravity PH2.0-4P Interface & XH2.54 Pins)
IC Output Data: Hour, Minutes, Seconds, Week, Day, Month, Year
Leap-year Compensation
Accurate calendar up to year 2100
1Hz Output Pin
56 Bytes of Non-volatile memory available to user
4KB ROM of EEPROM
Size: 0.81inch x 1.06inch (22mm x 27mm)
Weight: 6g
Board Overview
Gravity: I2C DS1307 RTC Module
Num
Label
Description
1
VCC
5V
2
GND
GND
3
SCL
I2C-Clock
4
SDA
I2C-Data
5
SQ
SQ
6
VCC
5V
7
GND
GND
8
SCL
I2C-Clock
9
SDA
I2C-SDA
Tutorial
In this tutorial, you can set and read time.
Requirements
•
•
•
•
Hardware
DFRduino UNO (or similar) x 1
Gravity: I2C DS1307 RTC Module
M-M/F-M/F-F Jumper wires
•
•
Software
Arduino IDE, Click to Download Arduino IDE from Arduino®
Connection Diagram
Gravity: I2C SD2405 RTC Module Arduino Connection Diagram
Sample Code
Please download DFRobot DS1307 RTC library. How to install Libraries in Arduino IDE
Note: #define updata_flag 0 //1 updata time,0 only show time
•
•
•
When flag is 0, the sample code just shows time
When flag is 1, the sample code only to set time
Please set time first and modify the value from 1 to 0 to only show time
/***************************************************
* Real Time Clock Module
* ****************************************************
* How to apply the DS1307 clock module.
* @author Dongzi(1185787528@qq.com)
* @version
* @date
V1.0
2017-08-21
GNU Lesser General Public License.
See for details.
* All above must be included in any redistribution
* ****************************************************/
#include
#include
#define updata_flag 0 //1 updata time,0 only show time
//Modify the following data
#define TIME_YR
17
#define TIME_MTH
8
#define TIME_DATE
21
#define TIME_DOW
1
#define TIME_HR
0
#define TIME_MIN
1
#define TIME_SEC
0
char* str[]={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","
Sunday"};//week
int rtc[7];
void showtime()
//
{
RTC.get(rtc,true);
{
Serial.print( rtc[6]);
/*YEAR MONTH DATE*/
Serial.print("-");
Serial.print( rtc[5]);
Serial.print("-");
Serial.println( rtc[4]);
Serial.print( rtc[2]); /*HOUR
MIN SEC */
Serial.print(":");
Serial.print( rtc[1]);
Serial.print(":");
Serial.println( rtc[0]);
Serial.println( str[rtc[3]-1]); /********WEEK*****/
Serial.println("**********");
}
}
void setup()
{
Serial.begin(9600);
Wire.begin();
if(updata_flag)
{ Serial.println(" OldTime:
");
showtime();
RTC.stop();
RTC.set(DS1307_SEC,TIME_SEC); //---Update time---RTC.set(DS1307_MIN,TIME_MIN);
RTC.set(DS1307_HR,TIME_HR);
RTC.set(DS1307_DOW,TIME_DOW);
RTC.set(DS1307_DATE,TIME_DATE);
RTC.set(DS1307_MTH,TIME_MTH);
RTC.set(DS1307_YR,TIME_YR);
RTC.start();
Serial.println(" SetTime:
");
showtime();
}
}
void loop()
{ if(updata_flag==0)
showtime();
//Output data from serial port
delay(1000);
}
Expected Results
Appendix: EEPROM IIC Address Setting
•
Note: the default IIC address of EEPROM is 0x50, soldering
200R in the silk-screen A0~A2 then the truth value will be ON,
otherwise is will be OFF.
FAQ
For any questions, advice or cool ideas to share, please visit the DFRobot Forum.
More Documents
•
•
•
•
DFRobot DS1307 RTC Library
Schematic & Layout
DFRobot DS1307 RTC Repostory
Time Synchronization with Computer
https://www.dfrobot.com/wiki/index.php/Gravity:_I2C_DS1307_RTC_Module_SKU:_DFR0151/1-14-19
很抱歉,暂时无法提供与“DFR0151”相匹配的价格&库存,您可以联系我们找货
免费人工找货