top of page
IMG_20170503_173438.jpg

Post

How to make an open source clock with an Arduino board and a RTC


Hi everyone,

Thank you for following this new tutorial.

Today we'll talk about how to make an open source clock with an arduino board and a RTC (Real Time Clock)..

I think everybody here now what an arduino board is. If not, you can have a look on this website and have a better idea.

With the arduino board (Arduino uno, Arduino Mega, Arduino nano, etc), we can make a clock with the following function ''millis(). It allows you to count the time since the arduino board is turned on. But if we turn the power off, the clock stops with it. To counter this problem, there is a electronic module call RTC. A RTC (standing for real time clock) is a device working with an integrated circuit called DS1307. It works with a coin cell battery, what allows it to keep the right time even when the arduino uno is not plugged to any battery.

When it will be reconnected, we will have the right time as we set it up before.

The RTC is connected to the arduino with the I2C procotol which is a serial protocol very common in electronics and make it easier to communicate between the electronics components. It has a coin cell battery to keep the time sharp.

To communicate, the I2C protocol uses 2 pins calls SDA and SCL respectively the data and the clock for the exchange.

Wiring:

To connect the arduino uno and the RTC with the I2C protocol, we'll look for the I2C ports coming from the arduino. These are the pins number on the arduino side:

  • 4: SDA for the data

  • 5: SCL for the clock

  • GND: for the ground

  • +5V: For the power

On the RTC board, they are usually written on the pins. An RTC module can be find easality for less than $15 on internet (Ebay, Sparkfun, Amazon...).

The following shows you how to connect the RTC module with the Arduino uno board. You may need a prototyting breadboard and wires.

Programming:

The program for this project can be download with the following link: Library arduino for RTC module made by sparkfun.

And installed on the Arduino IDE. Here is a link on how to install a library to the arduino IDE ''interface'': How to install a library in to the arduino IDE.

After downloading the library to the arduino IDE, Click on:

  • File -> Examples -> Sparkfun DS1307 - Real Time clock

On the right upper corner of the IDE, click on terminal and you should see appearing a date and a time that are not correct.

Set up the time on the RTC with the Arduino program:

As we said before, you need to use The RTC sparkfun Library in your code by including the header at the beginning of the program.

And ''rtc.begin()'' dans ''void setup'' to initialise the module.

You can set up the time by looking for ''rtc.set time(second, minute, hour, day, date, month, year)'' in the program and type all the informations in it.

Here is an example:

You can also read the time by typping the function behing the object RTC.

  • E.G: rtc.minute(); rtc.hour()..

Here is a example:

With the variables above (s: for seconds, m: for minutes, etc). You can create your own application like a alarm clock with a buzzer to wake you up every morning, a cat or or feeder and even more. The only limit is your imagination.

Don't forget to share your projects with us. ;-)

More details on the project can be find with the following link: Sparkfun RTC

If you like the tutorial and want more, you can subscribe to our newsletter and our social medias to stay upadted to the last tutorials, maker news (Facebook, Twitter, Google+, Instagram and youtube).

See you for another techy tutorial guys. :-)

Categories

Recent Posts

Archive

Search By Tags

Follow Us

Comments

Oszd meg a gondolataidat!Legyél te az első hozzászóló!
bottom of page