ablab

Hello Readers, welcome to my Blog - A Blog For Bloggers By A Blogger. I'm Arun, an entrepreneur Blogger from India.

DS1307 RTC Interfacing with ATmega32 and LCD Display

16245
11
Mark as Favourite

Real Time Clocks, as the name suggests are clock modules. They are available as integrated circuits (ICs) and manages timing like a clock. Some RTC ICs also manages date like a calendar. The main advantage is that they have a system of battery backup which keeps the clock/ca lender running even in case of power failure. A very small current is required for keeping the RTC alive. This in most case is provided by a miniature 3V lithium coin cell. So even if the embedded system with RTC is powered off the RTC module is up and running by the backup cell. This same technique is used in PC timing also. If you have opened your computer case you will notice a small coin cell in the mother board. The DS1307 Serial Real-Time Clock is a low-power; full binary-coded decimal (BCD) clock/calendar plus 56 bytes of NV SRAM. Address and data are transferred serially via a 2-wire, bi-directional bus(TWI Communication Protocol). The clock/calendar provides seconds, minutes, hours, day, date, month, and year information. The end of the month date is automatically adjusted for months with fewer than 31 days, including corrections for leap year. The clock operates in either the 24-hour or 12-hour format with AM/PM indicator.

In this project, we will learn How to interface a DS1307 Real Time Clock(RTC) with AVR ATmega32 microcontroller and LCD Display. Here, we will read time(Minute and Second) from the DS1307 RTC and we will display the minute and second values in a 16X2 alphanumeric LCD. The data communication between DS1307 RTC and AVR ATmega32 microcontroller takes place using TWI(Two Wire Interface) communication protocol. But before reading the DS1307 RTC, the DS1307 RTC needs to be initialized with second and minute values. The DS1307 RTC is initialized only once. We will initialize both the minute and second values of the DS1307 RTC with 0(Clock will start with 0 minute and 0 second). You can change the initialization values according to your need by changing the initialization values in the DS1307 write section of the code. After initialization of DS1307 RTC, the AVR ATmega32 microcontroller will read the minute and second values from the DS1307 continuously through two wire interface communication and it will display those minute and second values in the 16X2 alphanumeric LCD.

Softwares Required

Hardwares Required

Name Quantity
AVR Trainer Board-100 with ATmega32 1pc
AVR USB Programmer 1pc
12V, 1A DC SMPS Adaptor 1pc
EEPROM & RTC Board with AT24C02 1pc
1 to 1 Connector-Female to Female 3pc
10 to 10 FRC Female to Female Connector 3pc
RG1602A 16X2 Alphanumeric LCD Green 1pc

Circuit Diagram

Video

Connection Guide

The step-by-step connection guide for DS1307 RTC Interfacing with ATmega32 and LCD Display is as follows

  • Steps - 1 ( 0f 10 )

    Insert the DC Pin of 12V, 1A DC Adapter to the DC Socket of AVR Trainer Board-100.

  • Steps - 2 ( 0f 10 )

    Connect PortB header with LCD data header in AVR Trainer Board-100 with a 10 to 10 FRC Female Connector.

  • Steps - 3 ( 0f 10 )

    Connect RS, RW & EN pins of LCD control header with PD0, PD1 & PD2 pins of PortD header respectively in AVR Trainer Board-100 with 1 to 1 Connectors.

  • Steps - 4 ( 0f 10 )

    Connect the 16X2 Alphanumeric LCD to the LCD header of AVR Trainer Board-100.

  • Steps - 5 ( 0f 10 )

    Connect the EEPROM & RTC header of EEPROM & RTC with PortC header of AVR Trainer Board-100 with a 10 to 10 FRC Female Connector.

  • Steps - 6 ( 0f 10 )

    Connect the ISP header of AVR Trainer Board-100 with AVR USB Programmer header of AVR USB Programmer with a 10 to 10 FRC Female Connector.

  • Steps - 7 ( 0f 10 )

    Switch on the power with the help of Power Switch of AVR Trainer Board-100.

  • Steps - 8 ( 0f 10 )

    Switch on the power with the help of Power Switch of AVR Trainer Board-100.

  • Steps - 9 ( 0f 10 )

    Download DS1307 RTC Interfacing with ATmega32 and LCD Display Hex file to AVR Trainer Board-100 with the help of SinaProg Hex downloader and AVR USB Programmer.

  • Steps - 10 ( 0f 10 )

    Wait for some time(30 seconds) and delete or convert the code between DS1307 write section starts here and DS1307 write section ends here into comments in the C Program of the project and compile the code. After compilation, download the code

  • Insert the DC Pin of 12V, 1A DC Adapter to the DC Socket of AVR Trainer Board-100.

    Steps - 1 ( 0f 10 )

  • Connect PortB header with LCD data header in AVR Trainer Board-100 with a 10 to 10 FRC Female Connector.

    Steps - 2 ( 0f 10 )

  • Connect RS, RW & EN pins of LCD control header with PD0, PD1 & PD2 pins of PortD header respectively in AVR Trainer Board-100 with 1 to 1 Connectors.

    Steps - 3 ( 0f 10 )

  • Connect the 16X2 Alphanumeric LCD to the LCD header of AVR Trainer Board-100.

    Steps - 4 ( 0f 10 )

  • Connect the EEPROM & RTC header of EEPROM & RTC with PortC header of AVR Trainer Board-100 with a 10 to 10 FRC Female Connector.

    Steps - 5 ( 0f 10 )

  • Connect the ISP header of AVR Trainer Board-100 with AVR USB Programmer header of AVR USB Programmer with a 10 to 10 FRC Female Connector.

    Steps - 6 ( 0f 10 )

  • Switch on the power with the help of Power Switch of AVR Trainer Board-100.

    Steps - 7 ( 0f 10 )

  • Switch on the power with the help of Power Switch of AVR Trainer Board-100.

    Steps - 8 ( 0f 10 )

  • Download DS1307 RTC Interfacing with ATmega32 and LCD Display Hex file to AVR Trainer Board-100 with the help of SinaProg Hex downloader and AVR USB Programmer.

    Steps - 9 ( 0f 10 )

  • Wait for some time(30 seconds) and delete or convert the code between DS1307 write section starts here and DS1307 write section ends here into comments in the C Program of the project and compile the code. After compilation, download the code

    Steps - 10 ( 0f 10 )

Post a Comment

    • vitaliy
      Works perfect! Thank you.
      2017-03-09 20:26:39
      Reply
    • ?????????
      where the code
      2017-10-28 23:37:51
      Reply
      • Arun Kumar Garg
        Code will be uploaded very soon.
        2017-10-29 18:23:33
        Reply
        • EminKültürel
          It is now 2018 and no code appears yet!...
          2018-01-16 01:36:26
          Reply
          • ?????????????????
            send an e-mail to this code.
            2018-03-07 18:17:11
            Reply
          • ?????????????????
            send an e-mail to this code.
            2018-03-07 18:17:35
            Reply
            • FestusFashola
              pls help me with the code fashtop3@gmail.com
              2018-07-12 18:55:33
              Reply
              • Arun Kumar Garg

                There was some issue with the downloads. Issue is resolved and now you can  download.

                2018-10-31 20:24:58
                Reply
            • FestusFashola
              pls help me with the code fashtop3@gmail.com
              2018-07-12 18:55:35
              Reply
    • Narendran Venkatramani
      Can you please share the code?
      2017-08-28 12:33:31
      Reply
    • SatyajeetsinhDodiya
      2018-04-11 19:18:09
      Reply
    • SatyajeetsinhDodiya
      i need code for this project dodiyasatyajeet1996@gmail.com
      2018-04-11 19:18:52
      Reply
    • FestusFashola
      pls help me with the code fashtop3@gmail.com
      2018-07-12 19:02:49
      Reply