Saturday, 02 July 2016 15:10

Arduino Based DS1307RTC Large LED Digital Clock

This is an Arduino based digital Clock to display real time on a 32x16 LED matrix panel using a DS1307 RTC module. The date and time can be set via serial interface or push button switches.

 

Features

  1. Shows date and time on serial monitor
  2. Shows date and time on a 32x16 LED matrix panel
  3. 3 display mode (Font_Normal, Font_3x5 & Font_Large)
  4. Very bright LED, suitable for indoor & outdoor
  5. Adjust settings via serial interface or push button switches
  6. 8 steps brightness control
  7. Enable/Disable Alarm
  8. Keeps time running after electricity failure
  9. Using a homemade Arduino which is very simple & low cost

Updated on 20 Aug. 2016

Design a GUI interface using AutoIT scripting language to read settings from and write settings to the LED clock.

GUI

 

 

 

Libraries

You need to download and install the following libraries before you can upload sketch to your Arduino.


RTC.h, DS1307RTC.h, SoftI2C.h
The RTC.h library adds timekeeping functionality to Arduino with or without external timekeeping hardware.
The DS1307RTC.h library allows you to access the DS1307 realtime clock chip via I2C.
The SoftI2C.h library implements the master side of the I2C protocol in software on any arbitrary pair of pins for DATA and CLOCK.

 

DMD2.h
A library for driving the 32x16 dot matrix LED display

 

SystemFont3x5.h
DMD2 does not include the 3x5 fixed width font in their download, you must copy it to your DMD2 fonts folder.

 

 

 

Freetronics DMD (Dot Matrix Display) Library

There are several ways to drive the 32x16 LED Dot Matrix Display from an Arduino, I found that Freetronic DMD and DMD2 are the most easy to use library for display text & simple shape like circles and boxes.

DMD2 added features such as brightness control which allows the Arduino to control the brightness of the display. Only four functions from the library is used in the Arduino sketch.

  • dmd.begin()
  • dmd.clearScreen()
  • dmd.setBrightness(brightness)
  • dmd.selectFont(Font)

 

DMD2 includes several font file types in the library font folder, there are:

  • Arial_Black_16.h
  • Arial14.h
  • Droid_Sans_12.h
  • Droid_Sans_16.h
  • Droid_Sans_24.h
  • SystemFont5x7.h


The 3x5 fixed width font file type is missing from their library. Finally I found a "3x5 Fixed Width Font" from the Freetronics forum which is contributed by Micah.

Note: DMD2 library is not backwards compatible with the original DMD library. It's currently a beta release.

 

 

 

DS1307 RTC

 

DS1307 RTC Module

The DS1307 serial real-time clock (RTC) is a low- power, full binary-coded decimal (BCD) clock/calendar plus 56 bytes of NV SRAM. DS1307 works on I2C protocol which can interfaces to most microcontrollers.

A 3 volt lithium coin cell battery is connected to the DS1307 which keeps time running after electricity failure. The DS1307 has a built-in power-sense circuit that detects power failures and automatically switches to the backup supply.

 

 

 

32x16 LED Dot Matrix Panel

 

32x16 LED Dot Matrix Panel

The LED matrix panel is arranged in 32 rows by 16 columns (512 LEDs total) which can be used to display digits, letters and even graphs. I'm using a P10 (10mm pitch ) LED matrix panel with the size 320mm(W) x 160mm(H) x 30mm(D), it is designed for outdoor (extra bright). 


The LED matrix panel is available from several sellers & design. You can use it on this project as long as the interface (16 pins IDC connector) is complied to Hub12 protocol. Figure below shows the Hub12 pinout.

HUB08 pinout

 

 

 

ATMega328 Arduino

Initially I'm using an Arduino UNO for this project.

DS1307RTC Arduino UNO

It is then using a homemade Arduino after the project has been completed.

ds1307 large led digital clock PCB

 

 

Implementation

The DMD library is conflicted with the analog pin when used with DS1307RTC, please do not interface the DS1307RTC with the hardware I2C since it uses Analog 4 (SDA) & Analog 5 (SCL) as the signal pin. In order to overcome this problem, the software I2C library is used in this project which allows the DS1307RTC connect to any IO pin (D0 to D13) except the analog IO (Analog 0 to Analog 5).

Since most of the IO pin is occupied by Serial (D0, D1) and DMD (D6, D7, D8, D9, D11, D13), the available pin would be D2, D3, D4, D5,  D10 & D12, therefore I use D2 & D3 as the software I2C pin for the DS1307RTC, D4 & D5 for alarm1 and alarm2 respectively.

Note: Do not use Analog pin for Alarm output, the analog pin will change to high and then goes low automatically.

The three push button is control by an anlalog pin (A0) which used to adust the clock settings. I'm using the following sketch to test the buttons in order to know the exact input value for each buttons. 

 

 

 

Source Code

The source code and the libraries is packed in a single file which is available in GitHub, alternately you can download from my website.

 

 

 

 

 

Adjust Settings via Serial

Connect a USB-Serial adapter to the LED clock, you can adjust the clock settings via the serial interface from your computer.

usb serial connecting to LED clock

  • Open serial console from Arduino IDE, make sure selected the correct serial port.
  • Set baud-rate to 9600.
  • Select Both NL & CR next to baud-rate as shown in figure below.
  • Send a valid command to the serial port, you should able to adjust the clock settings.

serial console

 

 

 

Command List

 

Command Format Remarks
Set Mode Mx Where x is ranged from 0 to 2. Eg. M0 will set to Normal font
Set Brightness Bx Where x is ranged from 0 to 7. E.g. B1 will set brightness to 1
Set Date Dyymmdd E.g. D160123 will set date to 23rd Jan 2016
Set Time Thhmmss T012345 will set system time to 01:23:45
Set Alarm Ahhmmssx Where x is the alarm ID. E.g. A0123450 will set the first alarm time to 01:23:45
Enable Alarm Esx Where x is the alarm ID, s is the status either 0 (ON) or 1 (OFF). E.g. E10 will enable first alarm, E00 will disable first alarm.

 

 

 

Adjust Settings via Push Buttons

The LED clock built with three push buttons (SET, UP, DOWN) used to change the clock settings.

  1. Press SET button to bring up the menu.
  2. Press UP or DOWN button to scroll the menu items (1=Display Mode, 2=Set Brightness, 3=Set Date, 4=Set System Time, 5=Set Alarm Time, 6=Enable/Disable Alarm)
  3. Press SET button to select the desired item.
  4. Press UP or DOWN button to change the settings.
  5. Press SET button to save and activate the settings or idle 10 seconds will return to main screen without any changes.

 

Read 8533 times Last modified on Saturday, 24 September 2016 16:37
More in this category: « Arduino based LCD Digital Clock

8 comments

  • Comment Link admin Wednesday, 23 August 2017 12:39 posted by admin

    I think it should work similarly with DS1307. However, you must replace the DS1307RTC library with the DS3231RTC library.

    Open the DS1307_Large_LED_Digital_Clock.ino file and move the cursor to line 15, replace DS1307RTC.h with DS3231RTC.h
    The connection between DS3231 and Arduino is exactly same as DS1307 since both RTC using I2C protocol.

  • Comment Link Andrei Wednesday, 23 August 2017 03:38 posted by Andrei

    done with ds3231 but on the led panel i have to connect all grounds to grounds or only one of them?

  • Comment Link Andrei Wednesday, 23 August 2017 01:52 posted by Andrei

    please help for ajusting sc1307 to ds3231

  • Comment Link admin Saturday, 01 April 2017 21:43 posted by admin

    Hi, Wiliam
    There were some errors on my website, comments after 22 Feb 2017 has been losing. Your question is unabled to compile the sketch, can you provide me your compile errors messages.

  • Comment Link admin Monday, 17 October 2016 19:53 posted by admin

    Yes and no.
    The time is loaded from DS1307 when power on. After that the time is running from Arduino itself.

  • Comment Link Hendra Bahtiar Friday, 14 October 2016 18:34 posted by Hendra Bahtiar

    i think this skect not using DS1307, because if i disconnect RTC module, clock still counting. whnever i disconnect the power, the cloct always show 09:00 , not the latest DS1307 time.

  • Comment Link admin Saturday, 24 September 2016 16:46 posted by admin

    Yes, the sketch must upload to the Arduino. Download link is available in this article.

  • Comment Link rokhmad Friday, 23 September 2016 14:33 posted by rokhmad

    This project do need the sketch ??

Leave a comment

Back to Top