SSD1306 OLED Display and DS1307 Interfacing With PIC16F877A | Real Time Clock

Опубликовано: 23 Февраль 2025
на канале: Electronics Developer
497
like

-------------------------
📌Introduction
-------------------------
This post shows how to build a real time clock using PIC16F877A microcontroller and DS1307 RTC chip where time and date are displayed on an OLED display with SSD1306 controller (128×64 Pixel). With the help of a 3V coin cell battery the DS1307 keeps the time running even if the main power source is cut.

The SSD1306 OLED used in this project is configured to work in I2C mode, some SSD1306 OLED boards may require a small hardware modifications (to select between SPI mode or I2C mode) such as soldering, placing jumpers …

To simplify project circuit, the SSD1306 display and the DS1307 RTC chip share the same I2C bus, always the PIC16F877A microcontroller talks with one device only because their I2C slave addresses are different.

-------------------------
📌Circuit Design
-------------------------
The two push buttons B1 and B2 are for setting time and date. Button B1 is connected to pin RB0 (#33) and B2 is connected to pin RB1 (#34). Internal pull-ups for PORTB pins are enabled in the code.In this project the PIC16F877A microcontroller runs with crystal oscillator of 8MHz.

-------------------------
📌 Tags
-------------------------
#PIC16F877A #RTC #ssd1306

-------------------------
📌 The Code
-------------------------
The C code below is for CCS C compiler, it was tested with version 5.051.To be able to compile the C code below with no error, a driver for the SSD1306 OLED display is required, it’s name is SSD1306.C. after the download, add the driver file to the project folder or CCS C compiler drivers folder.

The DS1307 RTC and the SSD1306 OLED display share the same I2C bus, DS1307 I2C address is 0xD0 and SSD1306 display I2C address is 0x7A. Source Code give in comment section.

📌 Tune With us so you never miss any update
-----------------------------------------------------------------------------------------------------------------------------------------------------------
🏷️Telegram : https://t.me/electronicsdeveloper
🏷️Facebook :   / electronicsdeveloper  
🏷️Instagram :   / electronics_developer  
🏷️Tweeter : https://twitter.com/Electronics_Dev?s=09
🏷️LinkedIn :   / electronics-with-shreyash  
🏷️Pinterest :   / electronics_developer  

Copyright Disclaimer under Section 107 of the copyright act 1976
------------------------------------------------------------------------------------------------------------------------------------------------------------
Copyright Disclaimer under Section 107 of the copyright act 1976, allowance is made for fair use for purposes such as criticism, comment, news reporting, scholarship, and research. Fair use is a use permitted by copyright statute that might otherwise be infringing. Non-profit, educational or personal use tips the balance in favour of fair use.

-------------------------------------------------------------------------------------------------------------------------------------------------------------
About Electronics Developer : YouTube certified creative essentials and asset monetization
-------------------------------------------------------------------------------------------------------------------------------------------------------------