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
  • НаукаНаука

Комментарии • 69

  • @MkmeOrg
    @MkmeOrg 8 лет назад +1

    Well done David. I remember struggling a bit the first times I used RTC modules. Really great tutorial. Cheers. Eric

  • @KenHeinrich
    @KenHeinrich 8 лет назад

    Hi David You lighting is great. Nice job on the demo.

    • @DavidWatts
      @DavidWatts  8 лет назад

      +Ken Heinrich Thanks Ken

    • @KenHeinrich
      @KenHeinrich 8 лет назад

      +David Watts Your are welcome. Again Great Job.

  • @RonanCantwell
    @RonanCantwell 8 лет назад

    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.

  • @BeginnersTech314
    @BeginnersTech314 8 лет назад

    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.

    • @DavidWatts
      @DavidWatts  8 лет назад

      +Beginner's Tech I look forward to seeing what you are working on.

    • @BeginnersTech314
      @BeginnersTech314 8 лет назад

      David Watts im planning on making some videos then but it is going to take awhile.

    • @david_pilling
      @david_pilling 8 лет назад

      +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.

    • @BeginnersTech314
      @BeginnersTech314 8 лет назад

      David Pilling ok thanks for the heads up.

  • @profesorjan7614
    @profesorjan7614 7 лет назад

    Very good video, it was very useful!

  • @LaithKhalil
    @LaithKhalil 8 лет назад

    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).

  • @leorusnac
    @leorusnac 8 лет назад

    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

  • @joem3581
    @joem3581 3 года назад

    Thanks for the video David help me setup my clock , Thanks.

  • @norm1124
    @norm1124 8 лет назад

    Nice Demo, thank you

  • @robbs96
    @robbs96 8 лет назад

    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

  • @IgorFranca01
    @IgorFranca01 7 лет назад

    Thank you so much, this really helped a lot

    • @DavidWatts
      @DavidWatts  7 лет назад

      +Igor Franca you are most welcome.

  • @zserzs
    @zserzs 4 года назад

    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!

  • @taranagnew436
    @taranagnew436 6 лет назад

    could you crate a int with the year,month,day,hour,min and second?

  • @phone6974
    @phone6974 7 лет назад

    Can the time be controlled by using buttons?

  • @geirvalsvik1780
    @geirvalsvik1780 6 лет назад

    Good video David :) Do you have info on how to use the 32k EEPROM memory on this module as well?

    • @DavidWatts
      @DavidWatts  6 лет назад

      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.

  • @BGLENN-dp4tx
    @BGLENN-dp4tx 5 лет назад

    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!

  • @Mehabubbashaofficial
    @Mehabubbashaofficial 6 лет назад

    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

  • @MYNICEEV
    @MYNICEEV 8 лет назад

    Awesome.

  • @emmtzi1
    @emmtzi1 8 лет назад

    Hi David!
    Well done! Maybe the simplest functional in the web (among some very confusing for starters like me!).

  • @alltypeofnepal2964
    @alltypeofnepal2964 5 лет назад

    how we can run the 2 wire system analog clock using of rtc

  • @HuyV
    @HuyV 8 лет назад

    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)

  • @BritishConcept
    @BritishConcept 8 лет назад +2

    A 3D printed clock, perhaps? :D Shame this component doesn't use PWM.

  • @xiaomong8
    @xiaomong8 6 лет назад

    No, the 3.3V VCC works for all DS3231 modules.

  • @DavidWatts
    @DavidWatts  8 лет назад

    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.

  • @TheRAZZITEAK
    @TheRAZZITEAK 8 лет назад

    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.

  • @MsTe-tt2mg
    @MsTe-tt2mg 7 лет назад

    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.

    • @padraig4096
      @padraig4096 7 лет назад

      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.

    • @MsTe-tt2mg
      @MsTe-tt2mg 7 лет назад

      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

  • @arisaris7792
    @arisaris7792 6 лет назад

    can i replace 2432 with 2464???

  • @caspervandermeer5229
    @caspervandermeer5229 8 лет назад

    If you were to unplug the Arduino and then plug it back in, will the time be reset?

    • @DavidWatts
      @DavidWatts  8 лет назад

      No, it will keep the time because of the backup cr2032 battery.

  • @Really2950
    @Really2950 8 лет назад

    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.

    • @DavidWatts
      @DavidWatts  8 лет назад

      Sorry dude, did you have a point?

    • @Really2950
      @Really2950 8 лет назад

      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 :)

    • @DavidWatts
      @DavidWatts  8 лет назад

      Really2950 Fair enough, they probably are worth looking at. I must admit that I usually forget that they are there. Thanks for reminding me.

  • @marioaditya9297
    @marioaditya9297 7 лет назад

    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..

    • @clypeum5063
      @clypeum5063 7 лет назад

      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

  • @ahmatchoeri9796
    @ahmatchoeri9796 7 лет назад

    how to get millisecond use RTC?

  • @donovanpl
    @donovanpl 8 лет назад

    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?

    • @DavidWatts
      @DavidWatts  8 лет назад

      +Donovan Lym They are also SDA and SCL on many Arduino boards but the are also present elsewhere often unmarked.

    • @donovanpl
      @donovanpl 8 лет назад

      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.

    • @DavidWatts
      @DavidWatts  8 лет назад

      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.

    • @donovanpl
      @donovanpl 8 лет назад

      OK, I'm good now. Bugged me for a little while now. Thanks, David.

  • @udith-pz4tv
    @udith-pz4tv 7 лет назад

    I need to get relay out four times per day , how can do it

    • @darktherapy
      @darktherapy 7 лет назад

      Udith Samantha I can help.

  • @shaputer
    @shaputer Год назад

    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.

  • @ShaunDobbie
    @ShaunDobbie 7 лет назад

    I tried this out and the month is appearing as 81 when it should be 01.

    • @nrdesign1991
      @nrdesign1991 7 лет назад

      Did you set the time? Maybe it's still "confused" because it was never set properly.

  • @androidandroid1514
    @androidandroid1514 8 лет назад +1

    first like ^_^

  • @donovanpl
    @donovanpl 8 лет назад

    What does this line do? "uint32_t ts = now.getEpoch();"

    • @DavidWatts
      @DavidWatts  8 лет назад

      +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.

  • @sidneij.becker2098
    @sidneij.becker2098 8 лет назад

    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.

    • @DavidWatts
      @DavidWatts  8 лет назад

      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.

  • @carlosalarconseguel5277
    @carlosalarconseguel5277 8 лет назад

    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);
    }

    • @DavidWatts
      @DavidWatts  8 лет назад

      +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

  • @youpattube1
    @youpattube1 7 лет назад

    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.

    • @DavidWatts
      @DavidWatts  7 лет назад

      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.

    • @youpattube1
      @youpattube1 7 лет назад

      yep. you are right. I missed that.

    • @DavidWatts
      @DavidWatts  7 лет назад

      No problem dude, if you need a hand give me a shout.