Arduino Real Time Clock - Using the Tiny RTC

preview_player
Показать описание
Today we will add a Real-Time Clock to an Arduino. I’ll show you how the Tiny RTC is hooked up and how to use two ways, including with interrupts. We will also construct a temperature and humidity clock.

The Arduino is a very versatile platform with many features, however, one thing it cannot do is tell the time. In order to do that you will need a real-time clock module.

A real-time clock is essentially a digital clock that you can interface with a computer or microcontroller. The module we are going to use is the popular Tiny RTC, which interfaces with the Arduino using the I2C bus.

The Tiny RTC is based upon the DS1307 real-time clock chip. This chip provides readings of the second, minute, hour, day, day of the week, month, and year. It adjusts for leap years and has a battery backup. And its available from several sources and it is very inexpensive.

I’ll show you how to hook up the Tiny RTC and how to set and read the time. We will then look at a more advanced method of using the Tiny RTC, using interrupts.

Here is the Table of Contents for today's video:

00:00 - Introduction
02:19 - Tiny RTC Module
05:15 - Hooking it up
06:03 - Setting the Time
09:43 - Reading the Time
12:30 - Creating Interrupts
19:58 - RTC with Temperature and Humidity

While you are on the website please subscribe to the DroneBot Workshop newsletter. It’s my way of keeping in touch with you to let you know what projects I’m working on.

And please subscribe to the YouTube channel if you haven’t already. That way you won’t miss out on any of the videos.

Thanks and I hope you enjoy the video!
Рекомендации по теме
Комментарии
Автор

Awesome tutorial on Using the Tiny RTC
thanks teacher...
will really appreciate it if you could do a tutorial on how to Setup interrupt from RTC DS3231. In such a way that at a particular time specified. RTC will put my arduino to sleep mode and also at a specified time it will wake it up....USING RTC DS3231 module.
thanks so much Sir, I really appreciate you and celebrate you.
HEZEKIAH 4rm 🇳🇬🇳🇬🇳🇬NIGERIA . 🤗

sportilight
Автор

the DS signal is a 1-wire signal used for the DS18B20 temperatuur sensor that you can add to the board and is not a device select!
and if you use a CR2032 (non rechargeble battery) you need to change some stuff because those boards are designed to use a LIR2032 (rechargeable battery).
to do this remove R5, D1, R4 and R6. then wire a jumper on R6. other wise you try to charge a non chargeabe battery and that is going to kill the battery.

djneon
Автор

I am a fan of this channel.
I have always watched your videos.

Keep up these good works of yours.

I shall be looking forward to the day you will make a video on Arduino/GSM modules.
Thank you now and always.

musaadejoshuaibuopaluwa
Автор

Great video... my only comment is be careful of the difference between "accuracy" and "resolution". The clock may be resolute to a second, but it's accuracy (how much it may drift) may be better or worse after some period of time.

PaulLascari
Автор

Most of these 'micro-puter-ese' videos put me to sleep- but not yours. You have such good structure and flow, it moves me right along. Great job, Bill- as usual. I do not know how you find the time (Pun on purpose!).

acadman
Автор

One small but important point regarding your LED blink on interrupt code. It is not a very good idea to use digitalWrite within an interrupt service routine because it is very slow and, as you rightly pointed out, the routine should execute as quickly as possible. It is much better to use direct port manipulation (in this case PORTB bit 5) to flip the LED state.

SpeccyMan
Автор

your shop is so scarily clean and beautifully arranged.

konturgestalter
Автор

There is also a 16 pin "DS3231SN" RTC. This is the first I have heard of the DS1307 Tiny, but it sounds like they both do the same. Unfortunately I don't have the pinout in front of me or I would share.

Pretty cool little chips.

Inertia
Автор

I completely agree with the other commenters who say to use the DS3231 instead. (Especially the DS3231SN, which is the quartz crystal version, rather than the DS3231M, which uses a less accurate MEMS oscillator.) The DS1307 can be so inaccurate that it's just not worth the effort. I've gotten some clock kits based on the 1307 that were so bad they literally were useless (a clock that loses or gains several minutes per day is simply not usable). The DS3231 is superb.

tookitogo
Автор

I believe this module is suitable for projects that deals with calendar, such as smart irrigation system in agriculture, or deals with time such as smart home 🏠 light

manofmesopotamia
Автор

Very nice! but I think the DS3231 is better and precise than DS1307. what you think

InvertLogic
Автор

You might want to use the qualifier "volatile" for the variable ticks, so the declaration should read "volatile int ticks= 0;". This is a compiler directive which results in code that reads the value of ticks from RAM instead of from a register in order to avoid conflicts when using concurrent processes and/or interrupts with global variables.

MarcRidders
Автор

Another excellent video Bill. Thank you very much for all of your hard work.

jezebabe
Автор

It seems that assigning the square wave to pin 2 or 3 of the Uno comes with the disadvantage that it is an interrupt. The controller stops when the wave is down.

Why not assigning to a non-interrupt digital input pin and then check for change of state (of the square wave)? This would avoid interrupting the controller.

Also, do the statuses of the I/O change to zeros (off) during an interrupt, or are they frozen (maintained) during an interrupt? Thanks

woodensurfer
Автор

Just something I read on google about DS1307. "The main difference between the DS3231 and DS1370 is the accuracy of time-keeping. DS1307 comes with an external 32kHz crystal for time-keeping whose oscillation frequency is easily affected by external temperature. This usually results with the clock being off by around five or so minutes per month." so maybe the DS3231 is better.

s.u.
Автор

For full article there is an error,

This site can’t be reached
Check if there is a typo in dbws.
If spelling is correct, try running Windows Network Diagnostics.
DNS_PROBE_FINISHED_NXDOMAIN

mohammedyasarshaikh
Автор

Module’s Hidden Feature – DS18B20
There’s a provision on our DS1307 RTC module that often goes unnoticed. It allows us to install DS18B20 temperature sensor.

The 3 holes in the top corner right next to the battery holder(labled as U1) is where the DS18B20 is installed.
Once you install the DS18B20, you will be able to get temperature readings from DS pin. These readings can further be used to compensate for temperature based time drift in code.
So there is no need to install a Temp Sensor, since its already at the Tiny RTC / DS1307.

paranormalitcresearch
Автор

1. DS pin is for ds18b20 -- there is a place for it for battery holder side.
2. You ABSOLUTELY MUST modify module for using standard non-rechargable battery. This module will try to re-charge battery and will damage it. Not safe.
Use modules based on DS3231N -- much more stable, not required any modifications, allows to change I2C address, and have additional functionality. A bit more expensive, but much better overall.
You also never mention that module have EEPROM as well.
Please research modules and their issues more carefully, can be lots of traps like that.

tigrafrog
Автор

I really like how you introduced the module and the developed the ideas in this video. It was a good progression from module to project. I'm looking forward to the robot series.

I do like the two camera set up for seeing the projects on the bench or when you showing a module or part. I'm not a fan of the look left look right camera switching for the explanations/narration. It's quite jarring and doesn't feel like it adds to the presentation. I can see what you are going for with respect to keeping interest in the visuals but I think some editing cutting with stills or change of framing would work better than seeing you physically turn to look from one camera to the other with no obvious purpose.

Keep up the great videos!

stompreaper
Автор

Thank you very much for this. It saved me (some time). LOL I did have trouble since I have a DS3231 and not a DS1307. It kept putting the seconds 8 seconds behind. I ended up having to add 8 seconds to the time when it retrieved the time from the PC. Thanks again!

AztecWarrior_