Learn how to create a digital clock with an ST7567 graphical LCD module and a DS3231 RTC module using an Arduino board. Follow the step-by-step guide and write the code to display the time and date readings from the RTC module on the ST7567 display.

Disclaimer:

Advertisements

What is needed to make a clock?

To make a digital clock, you need a RTC for a real-time clock source, a display, and a microcontroller to manage these two basic devices. And some associative components such as buttons, LEDs, alarms, etc. But to know the basics, you need to know about the display and the RTC. Then you can add the other peripherals.

About ST7567 Display:

The ST7567 is a monochrome graphic LCD controller manufactured by Sitronix Technology Corporation. It is commonly used to drive small to medium-sized graphic displays that require high-resolution graphics and low power consumption.

The ST7567 controller supports a variety of display modes, including a static display mode, a scrolling display mode, and a partial display mode. It can handle up to 128×64 or 132×64 dot matrix displays, and it supports a wide range of display types, including STN, FSTN, and FFSTN.

In addition, the ST7567 controller has built-in features that make it easy to implement advanced graphics capabilities, such as multiple grayscale levels, pixel inversion, and an on-chip programmable contrast control circuit. It also has a built-in temperature compensation circuit to ensure stable display performance over a wide range of operating temperatures.

Overall, the ST7567 controller is a popular choice for many embedded systems and consumer electronics applications that require high-quality, low-power graphics displays.

About DS3231:

The DS3231 is a low-cost, extremely accurate, and highly integrated Real Time Clock (RTC) module manufactured by Maxim Integrated Products. It is commonly used to provide timing and date-keeping functionality to a wide variety of electronic devices and systems, including microcontrollers, embedded systems, and consumer electronics.

The DS3231 module features a highly accurate temperature-compensated crystal oscillator (TCXO) that can maintain timekeeping accuracy within ±2ppm over a temperature range of -40°C to +85°C. It also has a built-in battery backup system that can keep the module powered for years in the absence of external power.

One of the notable features of the DS3231 module is its I2C interface, which makes it easy to integrate into a wide range of electronic systems. The module also has several built-in alarms and programmable timekeeping functions, such as 12 or 24-hour formats, and the ability to output signals at precise intervals.

Overall, the DS3231 is a highly reliable and accurate RTC module that is well-suited for a wide range of applications that require precise timekeeping and date-keeping capabilities.

Interfacing DS3231 with Arduino:

To interface DS3231, you need to connect the RTC with Arduino through SCL & SDA pins. If you are using a DS3231 RTC module then no need to use pull-up resistors. But if you the IC directly use pull-up resistors (4K7).

How to make a digital clock with ST7567 & RTC with Arduino

Interfacing ST7567 with Arduino:

I’ve published an article on this already. You can read it from the home page.

The diagram you need to follow:

Making a digital Clock:

After interfacing RTC and display, now you need to code for them. You can follow the following code:

//display configuration
#define LCD_CS 53
#define LCD_DC 9  // RS_any pin
#define LCD_RST 10
#include "ST7567_FB.h"
#include <SPI.h>
ST7567_FB lcd(LCD_DC, LCD_RST, LCD_CS);
#include "fonts_all.h"

//RTC setup
#include <RTClib.h>
#include <Wire.h>
RTC_DS3231 rtc;
char t[32];


int minute1 = 0, hour1 = 0, second1 = 0;
char hour[3], minute[3], second[3], day[3], month[3], year[3];


void setup() {

  lcd.init();
  lcd.setRotation(2);
  lcd.setContrast(10);
  lcd.cls();

  lcd.setFont(c64enh);
  //lcd.printStr(2, 2, "Water ATM v3.1");
  lcd.printStr(15, 10, "Lab Projects BD");
  lcd.display();

  Serial.begin(115200);  //for Serial port to debug
  Wire.begin();
  rtc.begin();
  rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
}

void loop() {


  DateTime now = rtc.now();//read the time and sote in now

  sprintf(hour, "%02d", now.hour());
  sprintf(minute, "%02d", now.minute());
  sprintf(second, "%02d", now.second());
  sprintf(day, "%02d", now.day());
  sprintf(month, "%02d", now.month());
  sprintf(year, "%02d", now.year());


  lcd.cls();
  lcd.setFont(c64enh);
  lcd.printStr(12, 10, "Lab Projects BD");
  lcd.setFont(Term7x14PL);

  lcd.printStr(2, 30, "Time:");
  lcd.printStr(40, 30, hour);
  lcd.printStr(58, 30, ":");
  lcd.printStr(62, 30, minute);
  lcd.printStr(77, 30, ":");
  lcd.printStr(83, 30, second);

  lcd.printStr(2, 50, "Date:");
  lcd.printStr(40, 50, day);
  lcd.printStr(57, 50, "-");
  lcd.printStr(65, 50, month);
  lcd.printStr(75, 50, "-");
  lcd.printStr(85, 50, year);


  lcd.display();
  delay(500);
}

Result:

If your connections are ok, you will find this on the display:

How to make a digital clock with ST7567 & RTC with Arduino

Video:

Conclusion:

I hope this will help you making your own digital clock with Graphics. Happy coding….

Read more on:

For Professional Designs or Help:

Loading

MKDas

Mithun K. Das. B.Sc. in Electrical and Electronic Engineering (EEE) from KUET. Senior Embedded Systems Designer at a leading international company. Welcome to my personal blog! I share articles on various electronics topics, breaking them down into simple and easy-to-understand explanations, especially for beginners. My goal is to make learning electronics accessible and enjoyable for everyone. If you have any questions or need further assistance, feel free to reach out through the Contact Us page. Thank you for visiting, and happy learning!

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *