Tiny RTC DS1307 I2C Module (DS1307) [S029]



https://www.youtube.com/watch?v=Ai9vbMClES8


*GitHubhttps://github.com/rdiot/rdiot-s029.git


* Specs

DS1307 I2C real-time clock chip (RTC)

24C32 32K I2C EEPROM memory

The using LIR2032 rechargeable lithium battery with charging circuit

Solve the problem DS1307 with backup battery can not read and write.

Fully charged, it can provide the DS1307 timing 1.

Compact design, 27mm * 28mm * 8.4mm

Leads to the a DS1307 clock pin, to provide the clock signal for the microcontroller.

Other I2C devices can be cascaded


* Contents

- Library : https://github.com/adafruit/RTClib


- Connect

GND - GND

VCC - 5V

SDA - SDA

SCL - SCL


- Key Code

#include <Wire.h> 

#include <LiquidCrystal_I2C.h>

#include "RTClib.h"

 

LiquidCrystal_I2C lcd(0x27,20,4);  // LCD2004

RTC_Millis rtc;

String dt;

String ut;

 

void setup()

{

  lcd.init();  // initialize the lcd 

  lcd.backlight();

  lcd.print("start LCD2004");

  

  rtc.begin(DateTime(F(__DATE__), F(__TIME__)));

 

  delay(1000);

  lcd.clear();

}

 

void loop()

{

 

  lcd.setCursor(0,0);

  lcd.print("S029:DS1307");

 

  DateTime now = rtc.now();

 

  dt = (String)now.year()+"/";

  dt += (String)now.month()+"/";

  dt += (String)now.day()+" ";

  dt += (String)now.hour()+":";

  dt += (String)now.minute()+":";

  dt += (String)now.second();

 

  lcd.setCursor(0,1);

  lcd.print(dt);

 

  ut = (String)now.unixtime();


  lcd.setCursor(0,2);

  lcd.print("unixtime="+ut);

}



'2) Sensor > RTC' 카테고리의 다른 글

DS3231 AT24C32 IIC Clock Module (DS3231SN) [S174]  (0) 2016.09.11
RTC DS1302 Module (DS1302) [S030]  (0) 2016.09.11
Posted by RDIoT
|