Arduino: DS3231 Real time Clock RTC Module
HTML-код
- Опубликовано: 10 июл 2024
- I am planning to knock up my own real time clock board with a display built-in. I am not sure what it will look like yet though.
I don't think I said anything too stupid in this video but feel free to point it out :-)
The Sodaq library is available in the library manager or via github.com/SodaqMoja/Sodaq_DS...
It turns out that 'Likes' and 'Shares' actually help the channel so, if you want to, please click the thumbs up or share the video.
If you want to get in contact Twitter is probably the best way @mrdavidjwatts
www.davidjwatts.com Наука
Well done David. I remember struggling a bit the first times I used RTC modules. Really great tutorial. Cheers. Eric
Hi David You lighting is great. Nice job on the demo.
+Ken Heinrich Thanks Ken
+David Watts Your are welcome. Again Great Job.
I ordered a bucket load of 1307's a couple of years ago before I heard about these.... Not quite sure why. I mean there's only so much timekeeping to be done in the average house. These are way better.
If I remember correctly, there was a page on the manufacturer's website where you could see a clock powered by one of the 3231's. It was built with a test/development device and left running to see what the long term accuracy was like.
thanks i just ordered 2 of these on eBay so i could learn how to use them. now i have a good understanding as to how to get started thanks to your video.
+Beginner's Tech I look forward to seeing what you are working on.
David Watts im planning on making some videos then but it is going to take awhile.
+Beginner's Tech beware of the ebay DS3231 modules that have a charging circuit for their battery but are supplied with a non-rechargeable cell.
David Pilling ok thanks for the heads up.
Very good video, it was very useful!
A great feature that this has vs the 1307 is the alarm feature. You can put a microcontroller into deep sleep power saving and wake it up with the RTC at a precise time of day (or depending on the chip on a certain date or multiple alarms).
Good tip, thanks.
Nice, now I'm interested how would you show the time :D if on the oled or some led's like you mentioned in the video :) looking forward for the final thing, nice work
Thanks for the video David help me setup my clock , Thanks.
Nice Demo, thank you
is there a warning indication when battery is going out? or could I add one? I am building a device that I need an rtc on. but if battery goes and time changes it could be a VERY BAD thing
Thank you so much, this really helped a lot
+Igor Franca you are most welcome.
Hi! Thanx for the vid! How did you manage to get the values or data not to blink? I am trying to assign it to a retro display to display a 4 digit clock out of this but every time it refreshes ( every second ) the data goes away so does my display blinks.. best regards! please help! thax!
could you crate a int with the year,month,day,hour,min and second?
Can the time be controlled by using buttons?
Good video David :) Do you have info on how to use the 32k EEPROM memory on this module as well?
Here you go - www.hobbytronics.co.uk/arduino-external-eeprom This is about the 24LC256 rather than the 24LC32 but you should be fine with their instructions.
Sure would like to hear about using the INT out to control Arduino or other uP power/sleep mode. There's lots on RUclips about the subject but nothing that's really instructive. Be the first!
sir i just want to control ac appliences based on real time clock and i suppose to use 4 relays to control (AC1 AC2 AC3 AC4) based on respective time these appliences should turned on and off
Awesome.
Hi David!
Well done! Maybe the simplest functional in the web (among some very confusing for starters like me!).
+emmtzi1 Thanks mate.
how we can run the 2 wire system analog clock using of rtc
What happens when you set an invalid date? For example 30th of February. The datasheet states it has an internal calendar with leap year correction, so I guess if it's on 28th of February it will know when to jump to 1st of March or 29th of Feb. But is there a way to use that internal calendar when setting the date instead of having to basically somehow have my own calendar in the arduino in order to prevent the user from setting invalid dates?
I'm trying to make a nixie clock right now. I only have 2 buttons and 6 digits to display. So the user has only a increment button and decrement button to change the settings. When the user is setting the date and increments from 30th of April. My code would do a rtc.setDateTime(rtc.now().year, rtc.now().month, ++rtc.now().date., rtc.now().hour, rtc.now().minute, rtc.now().second)
A 3D printed clock, perhaps? :D Shame this component doesn't use PWM.
No, the 3.3V VCC works for all DS3231 modules.
Sorry Robby, I cannot reply to you directly. There isn't unfortunately a low battery warning but you could solder a wire from the positive terminal cell holder and feed it into your micro-controller analog pin to monitor the voltage.
I've found that there are a lot of fake rtc's from china, especially of the "tiny rtc" kind(ds1307) these fake chips should have a really good accuracy of a couple of seconds per year, but the fakes differ a couple of seconds per day! So the 1307 is a quite descent rtc, I prefer it since there are a lot of libraries for it, and it is available in an 8 pin dip /soic, but on the other hand it needs a crystal.
Hi Mr David. I am new to Arduino. i got 2 questions. First, where to get the first coding (RTC coding)? i have downloaded the zip file and i got the 'adjust' coding but still couldnt get the first coding u showed. Second, i dont get how u print out the date and time? U said u already set the date and time so u dont need to do that, but in the coding it is still in 2011 and yet the time print out is 2016? i dont get it.
I think that the first code is what he wrote himself, so you can just copy it - you can't quite see all of it, I think that there is a closing curly brace } at the bottom.
For the 'adjust' example, I think you just alter the parameters in DateTime dt to what they are now and run it. I assume he used adjust to set up the RTC but didn't save his changes.
padraig4096 Hello :D thanks for helping me to solve my question! I have found another coding which is easier to understand and it works! Anyway, thanks mate! :D
can i replace 2432 with 2464???
If you were to unplug the Arduino and then plug it back in, will the time be reset?
No, it will keep the time because of the backup cr2032 battery.
No mention of the little EPROM chip next to the time chip? Both time modules have this little extra chip. Also, there is 56 bytes in the DS1307 for storing data of any kind. So. Not just time from these 2 modules, also other functionality.
Sorry dude, did you have a point?
Hi. No much of a point, lol. I really enjoy your videos and have watched them all, so, nothing meant in a bad way. Sorry about that.
I was just trying to draw attention to the little AT24C32 chips that are on those modules. Everyone seems to look over them. So, just my 2 pence worth :)
Really2950 Fair enough, they probably are worth looking at. I must admit that I usually forget that they are there. Thanks for reminding me.
Hi David,
Please explain me the part of code that keep saving time every i lost the input power of arduino? I tried and it work as long as arduino has the 5v. But it always restart from begin if my arduino lost the power and when i reconnect again, the time RTC is restated..
I need a solution, please help me David..
mario aditya you need to make sure that the battery in the back is working. the battery provides the power when you disconecct your main power
how to get millisecond use RTC?
This question isn't directly related to the RTC project demo'ed here, but rather the I2C serial clock and data connections. I've been trying for some time now to understand why A4 and A5, when they are analog input pins. Why not on digital pins?
+Donovan Lym They are also SDA and SCL on many Arduino boards but the are also present elsewhere often unmarked.
I still don't understand. The RTC expects clocking (output) from the Arduino. However, the analog pin is an input pin on the Arduino. I must be missing something here.
Donovan Lym They are on the same pins, you cannot use analog input on A4 or A5 when you tell the MC to use I2C. Have a look at page 11 of the datasheet - www.atmel.com/Images/Atmel-42397-8-bit-AVR-Microcontroller-ATmega328PB_Summary.pdf - Just how they choose to make multiple uses of the 328 pins. analog pins can be inputs and outputs.
OK, I'm good now. Bugged me for a little while now. Thanks, David.
I need to get relay out four times per day , how can do it
Udith Samantha I can help.
I use one of these, but I would like to know why it is speeding up ? As of the time of this posting it's 2 minutes fast. Not sure if I could keep it more consistently accurate with coding perhaps ?🤔 It has a BRAND NEW battery.
I tried this out and the month is appearing as 81 when it should be 01.
Did you set the time? Maybe it's still "confused" because it was never set properly.
first like ^_^
What does this line do? "uint32_t ts = now.getEpoch();"
+Donovan Lym It returns a 32 bit representation of the seconds since 1 January 1970 www.epochconverter.com like using millis for a timer but with an absolute reference.
hello, I set up the project tested for several days, and found that it starts to slow after a few hours of use, at the end of three days he was 10 seconds behind in relation to my watch. already changed the RTC module, already changed some things in the code but does not. this is normal in the RTC that are already accuracy.
You are better off comparing it to an internet based clock source but assuming your watch is correct then you should not see a 10 second difference in time. The clock time is set at upload so it will likely be behind the real-time due to the time it takes to upload to the board. From the data sheet you might expect to see around +/-15 seconds per year. Temperature can be a factor in the timing of the crystal but otherwise I don't know any other reason you would get that.
i'm using de same circuit and the same code and the hour and date than i get is wrong 2016-11-10 15:34 . I'm using the ping 20 and 21 of arduino mega 2560. Any tip?
code
// Date and time functions using a RX8025 RTC connected via I2C and Wire lib
#include
#include "Sodaq_DS3231.h"
DateTime now;
void setup ()
{
Serial.begin(9600);
Wire.begin();
rtc.begin();
}
uint32_t old_timeStamp;
void loop ()
{
now = rtc.now(); //get the current date-time
uint32_t ts = now.getEpoch();
if (old_timeStamp==0 || old_timeStamp != ts){
old_timeStamp=ts;
int Nowyear= now.year();
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.date(), DEC);
Serial.print(' ');
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
Serial.println();
}
delay(200);
}
+Carlos Alarcon Just looks like you need to adjust the time. Open up the 'adjust' example from the soda library and give it a go
This wasn't helpful to me. I don't intend to try and copy the code line by line from your video into the sketch, and I don't see where you make it available. And saying that you are not going to show how to set up the date and time because you've already done it, well, not very instructive.
I believe I said that I was using the 'examples' from the library... You get the code in the library. While I appreciate you are looking for a tutorial, please just make the effort to get the library and try it for yourself.
yep. you are right. I missed that.
No problem dude, if you need a hand give me a shout.