Arduino Tiny RTC DS1307 Tutorial

An Easy To Use Real Time Clock for Your Arduino

TinyRTC PicThis battery powered clock allows you to keep reasonably accurate time even when your Arduino is powered off.  Its very useful in data logging and other time sensitive applications.

The device uses I2C to communicate with your Arduino.

The one I have uses an LIR2032 Lithium cell.

There are several internet libraries that can be used to interface with this device.

Where to Buy

These devices extremely affordable are offered on many sites, including those listed below:

eBay     Amazon     Bang Good     AliExpress


Pin Outs

You will only need four connections to make this device work.

TinyRTC Pinouts

Arduino Tiny RTC D1307 Tutorial

Get the RTC Libraries

There are a variety of libraries available for use with this device.   This tutorial will use the Elecrow.   If you are new to using libraries with your Arduino,  I suggest visiting this page.

This light weight library can be used to set the time and read the time.  For many of your applications,  this may be all you want to do.  The Elecrow RTC library can be found HERE.


Connect the Tiny RTC to your Arduino

This set up will work with all the sketches shown below

Arduino TinyRTC Tutorial Connections

Copy Paste and Upload the Sketch Using Elecrow Library

#include <Wire.h>
#include "RTClib.h"


void setup () {
  // Check to see if the RTC is keeping time.  If it is, load the time from your computer.
  if (! RTC.isrunning()) {
    Serial.println("RTC is NOT running!");
    // This will reflect the time that your sketch was compiled
    RTC.adjust(DateTime(__DATE__, __TIME__));
void loop () {
    DateTime now =; 
    Serial.print(now.month(), DEC);
    Serial.print(, DEC);
    Serial.print(now.year(), DEC);
    Serial.print(' ');
    Serial.print(now.hour(), DEC);
    Serial.print(now.minute(), DEC);
    Serial.print(now.second(), DEC);

Verify Your  Tutorial Sketch Output

Open your serial monitor.  Your output should look something like screen capture below:

Arduino TinyRTC Tutorial Output

Other RTC Libraries

This tutorial demonstrated the use of the Tiny RTC using the Elecrow Library.   There are others available.

One such set of libraries is authored by Paul Stoffgren.

There is some functionality included with this library that is not available with the Elecrow version.   To use it though,  you will want to install both the DS1307RTC library and the Time.h library.

The DS1307RTC library can be found here on github.

Time.h and can also be found on github.