The DS1307 supports a bi-directional, 2-wire bus and data transmission protocol. A device that sends data onto the bus is defined as a transmitter and a device receiving data as a receiver.
PermalinkJoin GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upBranch:master
Find file Copy path
FILIPEFLOPBiblioteca DS13078 Arduinofeb8bacJul 15, 2015
0 contributors
/* |
DS1307.h - Arduino library support for the DS1307 I2C Real-Time Clock |
Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved |
This library has been made to easily interface and use the DS1307 RTC with |
the Arduino without needing the Wire library. |
You can find the latest version of the library at |
http://www.RinkyDinkElectronics.com/ |
This library is free software; you can redistribute it and/or |
modify it under the terms of the CC BY-NC-SA 3.0 license. |
Please see the included documents for further information. |
Commercial use of this library requires you to buy a license that |
will allow commercial use. This includes using the library, |
modified or not, as a tool to sell products. |
The license applies to all part of the library including the |
examples and tools supplied with the library. |
*/ |
#ifndef DS1307_h |
#defineDS1307_h |
#if defined(ARDUINO) && ARDUINO >= 100 |
#include'Arduino.h' |
#else |
#include'WProgram.h' |
#endif |
#defineDS1307_ADDR_R209 |
#defineDS1307_ADDR_W208 |
#defineFORMAT_SHORT1 |
#defineFORMAT_LONG2 |
#defineFORMAT_LITTLEENDIAN1 |
#defineFORMAT_BIGENDIAN2 |
#defineFORMAT_MIDDLEENDIAN3 |
#defineMONDAY1 |
#defineTUESDAY2 |
#defineWEDNESDAY3 |
#defineTHURSDAY4 |
#defineFRIDAY5 |
#defineSATURDAY6 |
#defineSUNDAY7 |
#defineSQW_RATE_10 |
#defineSQW_RATE_4K1 |
#defineSQW_RATE_8K2 |
#defineSQW_RATE_32K3 |
classTime |
{ |
public: |
uint8_t hour; |
uint8_t min; |
uint8_t sec; |
uint8_t date; |
uint8_t mon; |
uint16_t year; |
uint8_t dow; |
Time(); |
}; |
classDS1307_RAM |
{ |
public: |
byte cell[56]; |
DS1307_RAM(); |
}; |
classDS1307 |
{ |
public: |
DS1307(uint8_t data_pin, uint8_t sclk_pin); |
Time getTime(); |
voidsetTime(uint8_t hour, uint8_t min, uint8_t sec); |
voidsetDate(uint8_t date, uint8_t mon, uint16_t year); |
voidsetDOW(uint8_t dow); |
char *getTimeStr(uint8_t format=FORMAT_LONG); |
char *getDateStr(uint8_t slformat=FORMAT_LONG, uint8_t eformat=FORMAT_LITTLEENDIAN, char divider='.'); |
char *getDOWStr(uint8_t format=FORMAT_LONG); |
char *getMonthStr(uint8_t format=FORMAT_LONG); |
voidhalt(bool value); |
voidsetOutput(bool enable); |
voidenableSQW(bool enable); |
voidsetSQWRate(int rate); |
voidwriteBuffer(DS1307_RAM r); |
DS1307_RAM readBuffer(); |
voidpoke(uint8_t addr, uint8_t value); |
uint8_tpeek(uint8_t addr); |
private: |
uint8_t _scl_pin; |
uint8_t _sda_pin; |
uint8_t _burstArray[8]; |
void_sendStart(byte addr); |
void_sendStop(); |
void_sendAck(); |
void_sendNack(); |
void_waitForAck(); |
uint8_t_readByte(); |
void_writeByte(uint8_t value); |
void_burstRead(); |
uint8_t_readRegister(uint8_t reg); |
void_writeRegister(uint8_t reg, uint8_t value); |
uint8_t_decode(uint8_t value); |
uint8_t_decodeH(uint8_t value); |
uint8_t_decodeY(uint8_t value); |
uint8_t_encode(uint8_t vaule); |
}; |
#endif |
Copy lines Copy permalink
Hii.. my name is shankar I buy tiny rtc 1307 module in http://uitechies.co.in/BBBcircuits/product.php?product=rtc-ds1307-24c32-real-time-clock-module-arduino this website establishes a connection for Rtc1307 module and I used arduino UNO board and I connected A5 and A6 data lines it displays date and time only 2 minutes after some error has occurred like (165/165/2165 165:165:85 ) or time starts with 00:00:01 after this error I check the connections also but I don't know whats problem anybody have solution for this problem