Arduino DS3231 RTC Clock With LCD

38,902

54

20

Introduction: Arduino DS3231 RTC Clock With LCD

About: I am a college student who loves to make things and share them. Thank-you!

To familiarize myself with a DS3231 RTC (real time clock), I built a simple arduino based 24 hour clock. It has 3 buttons with the following functions: press any button to enter the time setting mode, increase and decrease the time in minutes with two of the buttons, and set the clock with the third button. You can checkout a video of it working at vimeo.com/andrewideas/simplearduinoclock.

Materials Required:

  • An arduino development board (I used an Uno)
  • A standard 16x2 HD44780 based LCD display
  • A DS3231 based RTC (I got mine on Amazon)
  • Three push buttons
  • Three resistors (~10K ohm)
  • A potentiometer (~10K ohm)
  • A breadboard
  • Several jumper wires

Step 1: Wiring

Refer to the drawing for wiring instructions. The buttons are connected to pins A0, A1, and A2. The RTC uses pin A5 for SCL and pin A4 for SDA. The potentiometer varies the contrast on the LCD and the LCD uses digital pins 2 through 7.

Step 2: Programming

Use the arduino IDE to upload my sketch to your arduino.

My code was partly based on the code provided here. And, of course, my code is explained in its comments.

You can download the sketch from this instructable.

Step 3: Continuing on With Your Life

You did it! Unless you didn't- in which case comment below and I'll do my best to help you out. Otherwise, go on ahead and do even greater things!

Thanks!

3 People Made This Project!

Recommendations

  • The 1000th Contest

    The 1000th Contest
  • Battery Powered Contest

    Battery Powered Contest
  • Hand Tools Only Challenge

    Hand Tools Only Challenge

20 Discussions

0
anguyen211
anguyen211

2 years ago

I have all the wiring and coding right, and the LCD lights up and the potentiometer works perfectly. The problem is that the time doesn't show up on the LCD screen, and it only shows a blank screen with squares. Suggestions?

0
Darknessblade.
Darknessblade.

Reply 1 year ago

this is due your display having a different pinout.

i had the same issue with a 10 pin display, the thing you can try is with jumper cables and a breadboard, to find the correct pinout. {and yes this is a hard thing to do}
for my 10pin one it took me over a full day to find the correct one.

use the hello world code for a simplified testing.
you need to reboot the arduino everytime you try a new pinout

0
AndrewIdeas
AndrewIdeas

Reply 2 years ago

If your LiquidCrystal library isn't working, this would explain the LCD not displaying anything, getting the library loaded in your IDE and in your sketch should solve this.

0
ian9au
ian9au

2 years ago on Introduction

a good Indestructable. Keep up the good work.

0
AndrewIdeas
AndrewIdeas

Reply 2 years ago

Thanks for the kind words!

0
anguyen211
anguyen211

2 years ago

Also I can't seem to upload the BasicClock.ino to my library and sketch. It says library not found. Maybe there is an updated version or I can use a different ds3231 library for it?

0
AndrewIdeas
AndrewIdeas

Reply 2 years ago

On my installation of the Arduino IDE the Wire and LiquidCrystal libraries were both included. Check out https://www.arduino.cc/en/Guide/Libraries for help checking if you have these, and if not you should be able to use the library manager to install them. Thanks!

0
MarloG1
MarloG1

3 years ago

good day, can i use this as a stopwatch with lap times?

0
AndrewIdeas
AndrewIdeas

Reply 3 years ago

Hey, this project was designed to be a clock rather than a stopwatch. However, you could use a similar hardware design and make use of the RTC to keep good time and print the output to the LCD.

Thanks!

0
MarloG1
MarloG1

Reply 3 years ago

thank you for your reply,
however i'm new to this and trying to learn arduno, can guide me,
thank you

0
AndrewIdeas
AndrewIdeas

Reply 3 years ago

This doesn't include a rtc, but an rtc is not as important in a stopwatch application anyway.

http://fritzing.org/projects/arduino-lcd-stopwatc...

It is a simple stopwatch, and if you want to incorporate an rtc simply connect it to I2C like I did and use the setRTCTime() and readRTCTime() methods to access the time from the rtc. From there, you should be able to use arithmetic to calculate the passing of time.

Best of luck!

0
MarloG1
MarloG1

Reply 3 years ago

thank you so much for your help

0
MarloG1
MarloG1

Reply 3 years ago

thank you very much for your help

0
bicchef
bicchef

3 years ago

having trouble and not sure how the time should look in the code i just get a back lit screen doesn't respond to the potentiometer anyone that can help me.

thanks

0
AndrewIdeas
AndrewIdeas

Reply 3 years ago

The format for the parameters of setRTCTime() is (sec, min, hr, day of week, day of month, month, year)

For example: setRTCTime(0, 3, 23, 4, 15, 7, 17);

Hope this helps!

0
MahmoudE36
MahmoudE36

4 years ago

your instructable is very awsome

i am a very very new in arduino big world ,,,

and i need help in my second or third arduino project.
...
i need to build a code that repeat it self every 24 hour "every day"
without RTC module

Example like:
at 9 clock "pin 3 High"
at 11 clock "pin 4 High"
at 18 clock "pin 5 High"
at 20 clock "pin 6 High"
at 22 clock "pin 7 High"

and repeat that commands every 24 hour ""every day"
can you help me with that

0
AndrewIdeas
AndrewIdeas

Reply 4 years ago

Thanks for the kind words!

Without an RTC you will run the risk of loosing time accuracy over time, but you can accomplish something what you are asking about by using the delay function. I quickly wrote up a sketch to do what I think you are describing and put it on my site at: http://andrewideas.weebly.com/arduino-delay-pract...

Hopefully you can use this code to work on your project, but bear in mind I have not tested it. None the less, it should be a good starting point for you. Thanks!

0
MahmoudE36
MahmoudE36

Reply 4 years ago

Many many thanks for you AndrewIdeas , and I am very happy for your concern

i will test it and feed you by results