#5 Arduino compatible Real Time Clock modules (RTC) - DS1307 & DS3231

preview_player
Показать описание
Adding a Real Time Clock to your Arduino project is EASY and I'll show you how.

RTC modules cost very little and can be added to your project to add data-logging or anything where you need the date and time.

Just four wires and you can connect an RTC to your Arduino or other microcontroller that uses the I2C bus. Easy.

Sketch can be found here:

And my channel is here:
How can I remember this? Memory tip: "See" Ralph Bacon, geddit?
Рекомендации по теме
Комментарии
Автор

Hello Ralph, I want to build a rain sensor so that we do not have to keep checking when the washing is out. I got the idea from my grandson, who watches videos about model RC cars, to search YouTube. Luckily I found you. I watched your rain sensor video and realised that I need to learn about Arduino. So at the age of 71 I'm going back to school watching your basic videos. Hopefully I will learn enough before I expire. Thanks for the videos and slow clear explanations John

CRETEJOE
Автор

Very good. How about a time and temperature sketch since the ds3231 has that ability?

donaldnorris
Автор


I'll soon also add a (very) short video explaining what the BCD (Binary Coded Decimal) is all about - it's much simpler than you might think.

RalphBacon
Автор

First of all thank you for the great video!
I was getting frustrated with the DS3231 because there are so many poorly documented libraries and nothing was working, so I decided to configure it only with the datasheet and the Wire library like you did.
I used part of your code from github for setting the time and added some functions to use the alarm 1 of the DS3231 which I need for a project and it is working great now!

However, I was wondering as to why you were using pointers in the readDS3231time() function. Is it just to make the code work without any global variables?
Is it that you could not pass the seconds, minutes, hours ... variables directly to the function because they are only declared in the displayTime() function and for the readDS3231time() function they are undeclared? So instead you reference them using pointers to be able to change their values even though the variable itself is undeclared in the readDS3231time() function?
Sorry if the question might be dumb, I am not that comfortable using pointers yet, hence the confusion. I would be happy if you could help me out with my question!

Jonas-qzgb
Автор

Hi Ralph, I used the code from video #5 and it works great. I am trying to insert a conditional statement into the code so that if hour = a value (e.g. 12) and minute = 00 and second = 00 {turns a pin high with digital write}. I have used parts of the blink sketch for this. However, I can't get it to work. I have also downloaded various ds3231 libraries and examples to no avail. I'm a total newbie at this (age 64) but don't want to go back to a hardware solution. Can you point me in the right direction? Many thanks, Mike - long time subscriber and avid viewer.

mikebarton
Автор

Thank you very much, great explanation. I’ve realised that after a day my seconds starts to be leading by 6 seconds from the real time how can I fix that.

Thank you.

luthodyiki
Автор

This is good Ralph, can you help if I want to display hours, minutes, second on a separate line rather than displaying everything in one line

tlotlisangnkhase
Автор

In the setTime, how can we adjust the RTC automatically from computer time? Not using the hard coding setDS1302Time(18, 10, 10, 7, 18, 9, 2020);
Thanks a lot

malekiiaetius
Автор

Hello Mr. Bacon, Can you help me send commands to the RTC module. I have spent hours trying without success. One of them I would like to change it to 12 hour mode. I have tried to modify some of your code but ran into a brick wall. Please help.

davewreski
Автор

Thanks, Ralph very helpful and easy to follow and understand your a star thanks Bob

MrBobWareham
Автор

Verry good, will change my thermostat tft project
The to many rtc.libs .h files people can choose to include make arduino dificult

LuberthDijkman
Автор

sir how to replace ds1302 rtc with ds3231
what changes we have to do in program

anukeshambatkar
Автор

At the end of the video #5 RTC you say you have a video on how to set the times.Can you please tell me what number this video is.
Great tutorials you provide love watching them.
Thanks very much.
Fleck

fleckditchburn
Автор

2165/165/165 (Monday) 165:165:85
since midnight 1/1/1970 = 1563147985s = 18091d
now + 7d + 30s: 2019/7/22 12:16:31
how to fix this

ambidaearllawrencep.
Автор

Hey there Ralph, great informational video! You mention that the DS3231 is much better than the DS1307, any reasoning for this?

Thanks!

zakdunn
Автор

Thanks, I got a DS3231 through the post today, watched your video and now it's telling me the time via the serial port on the Arduino.

SusanAmberBruce
Автор

Hi Raplh,
Thanks for this code. I have been strugeling with this for months. Finnaly a code that works.
I just have one problem and was hoping you good help me. I am not new with programming, but I am new with arduino
I want to save the time to a SD card.


I am using this code, where i save the distance. That works fine

// if the file opened okay, write to it:
if (myFile) {
//Serial.print(distance);
myFile.print("Koe aanwezig: ");
myFile.println(distance);
myFile.close();
}

But I get an error if i want to place the time in there. something like this:

myFile.print(displayTime();)

Is there a simple way to at the time in my file on the same line.?
Thnaks for your help

whoopyd
Автор

Hi, I've Been playing around with this script learning about writing the on-board chip directly instead of using a library (Like You say saving memory but not relevant yet), But the Question is How Do you set say bit 7 high without changing any other bits (possible unknown value) do i have to read the whole byte then write back the value + 128 or is there an easier way? (Sorry for the dumb newbee Question but i've not done any coding since BASIC on a C64 back in 1985-8)

garymetheringham
Автор

Is there a better way to set the time instead of hardcoding it one time in the setup loop? I would like to accommodate for 1-second RTC drift by synchronizing the arduino with the local time of my computer upon uploading the sketch.

Thanks for the video!

porlando
Автор

You said that the 1307 is not temp compensated as the 3231, but I assume that this would only be a problem in a widely varying temp environment. Also you had a physical II2C address of 68, but I did not see the address links connected when you showed the board. How does that work?

raymondheath