Interface RTC With PIC


A Real-Time Clock is like a watch – it runs on a battery and keeps time even when there is a power outage.RTC keeps track of seconds, minutes, hours, date of the month, month, day of month and year with leap year compensation which is valid up to the year 2100.

  • DS1307 is an I2c based serial real-time clock (RTC).
  • The clock can be programmed to operate either in 12-hour or 24-hour format.
  • DS1307 requires very less number of components to operate.
  • RTC DS1307 operates in a frequency of crystal oscillator 32.768kHz.
  • DS1307 uses I2C Protocol.
  • RTC act as a slave device and I2C Master can read/write register of RTC.
  • To communicate with the slave device, the master needs the slave address of the device connected on the bus.
  • DS1307 has fixed slave address.
  • Slave Address
    7-Bit  format: 0b1101000 = 0x68
    Slave address for I2C Write: 0b11010000 = 0xD0
    Slave address for I2C Read: 0b11010001 = 0xD1.


  • Digital Clock.

Hardware Required

  • DS1307.
  • 3.3v Cmos battery.
  • PIC16f877a MicroController.


  • SCL and SDA to port pins.
  • Gnd: Gnd.