How to connect and use a DS1307 Real Time Clock with Arduino - Tutorial

Поделиться
HTML-код
  • Опубликовано: 10 июл 2024
  • Let's use a DS1307 RTC with an Arduino, and display the time and date on the OLED display.
    To get the schematic, libraries and the sketch we used please check out our tutorials page at : brainy-bits.com/tutorials/
  • НаукаНаука

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

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

    Thanks to one of our viewers for these tips:
    Thanks for the excellent tutorial, I managed to get my rtc module working using it. A couple of improvement suggestions:
    * On Arduino Micro (and I guess others using the same MCU) the pins are 2 (SDA) and 3 (SCL).
    Again, thanks for the excellent tutorial!
    Cheers, Pertti

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

    I was having trouble setting the time on the DS1307, but was able to update the date. This example program updated the date and time from my computer and worked perfectly. Thanks for the help. I wasted a whole day trying other ways to set the time and date. Subscribed and liked. Thanks for your time to make this video.

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

      That's great to hear that the video helped! Thanks for the Sub and for watching!

  • @DisturbinThaPeece
    @DisturbinThaPeece 9 лет назад +3

    Very good tutorial! I just found a new favorite RUclips-Channel ;-)
    These are some of the (or even the) best Arduino tutorials I've seen… Keep the quality stuff coming! :D

    • @BrainybitsCanada
      @BrainybitsCanada  9 лет назад +1

      DisturbinThaPeece Thanks for your comment! Great to hear that it's helping people learning this stuff.

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

    thanks a lot! I had a lot of problems with my RTC, but this video solved them all!

  • @hostingsrbijacom
    @hostingsrbijacom 9 лет назад

    First tutorial helped me with setting time.
    I tried tons but not sucessed.
    Awesome :)

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

    Again an awesome tutorial. You do the best explaining of the code I have ever seen. Happily subscribed to your channel.
    Merci beaucoup.

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

      +iHayri1 Thanks again for watching and for the Sub! :)

  • @MarcelDiane
    @MarcelDiane 9 лет назад

    Thanks Yvan, it works great!

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

      +Marcel Hebert Thanks for watching Marcel :) glad it helped you!

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

    Thanks a lot for tutorial!! Thanks the others to solve some issues in comments!

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

    Very useful! Thanks a lot for your tutorial! =]

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

    you are the best!

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

      +drago zengen I don't think so, actually far from it, but thank you for watching :)

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

    Removing these circuits R4,R5 R6 and D1 will it dammage or affect performance of the EEPROM that it has integrated?

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

    BIG THANKS

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

      +maverickstar reloaded You're welcome :) thanks for watching!

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

    Great video

  • @akshaykumar-th9ps
    @akshaykumar-th9ps 7 лет назад

    sir can we modify it to simple time base switch without depending on actual time.

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

    Nice job.

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

      +Dan Murphy Thanks for the comment and for watching!

  • @randynunez2666
    @randynunez2666 5 лет назад +1

    What if I'm just watching this and only have an LCD screen, not OLED. What changes would I make to the code?

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

    WITH THE 7 PIN OLED THE 128X64 PINOUT MAY DIFFER FROM ONE COMPANY TO ANOTHER . WITH SOME MINOR RESEARCH I FOUND THE RIGHT CONNECTIONS WORKS LIKE A CHARM

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

    Why there are two sets of pins for I2C communication ?

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

    Hi Brainy-Bits! I just wanna ask is it possible to combine a water sensor and RTC program? Thanks.

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

      +Yixingsmoo Aeri Sir could you let me know how to program this one.
      I want to turn on the device every 7:30 in the morning and it will stay on for 10mins long, after that it will turn off and it will turn on again on 4:00pm and stays on for 10mins also. Could you please let me know how to set this up?
      And we're planning to use this for watering system,but same with the question above, we will use a water sensor. What we're planning to do is to stop the above situation in case that there is water detected. is it possible to run and combine this using one program? Thank you :)

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

    I am haven a problem setting the rtc. i get ser_open(): can't open device:/dev/ttyACMO" i have it wired up to a mega. Do you have any suggestions?

  • @94cobragermany
    @94cobragermany 9 лет назад +1

    Could this RTC take the time from a smartphone as opposed to a computer?

    • @nebe01
      @nebe01 9 лет назад

      You could if you added a Bluetooth or WiFi adapter which can read the date and time from your phone via Bluetooth or directly from the Internet using something like the ESP8266 Serial WIFI module.

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

    hello sir please help me i want to make an automatic egg incubator i did every thing but i have a question can i use arduino to rotate a motor 5 time a day with three hours of delay
    i also connected dht11 sensor to read temperature and humidity but when i gave delay to the relay (which is used for motor rotation) between the delay time the dht11 sensor also on hold and dont show the temperature
    i have tiny rtc i connected to give the hours and times but when the date goes is i need to connect to computer and write another date sorry for my english please help me 😍

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

    Is DS1307 Real Time Clock in this tutorial support with ESP8266?

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

    Thanks for the tutorial, and it worked like charm on the first try itself :),. I just have 2 questions,..
    1. what if i want to display as 12hr format.
    2. At some places resistors are recommended to connect to the SDA and SCL lines,.. but we don't use it here?

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

      +CARTIKN Hi, the library used in this tutorial includes a function to use 12hr format:
      hourFormat12(); // Returns the hour value in 12 hour format
      also to know if it is AM or PM you can use these functions:
      isAM(); // Returns true if time is AM
      isPM(); // Returns true if time is PM
      As for the resistors, it seems that they might be needed if you are using the I2C model of this Oled module, they are not required for the SPI bus models like the one we are using in this tutorial.
      Hope this help and thanks for watching!

  • @mikehagen9060
    @mikehagen9060 7 лет назад +2

    Like some others I could not get your code to complie.
    Error...
    'tmElements_t' was not declared in this scope
    Thanks

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

      like me. you can solve that?

    • @labonczgergo5227
      @labonczgergo5227 6 лет назад +2

      You should try another library: github.com/PaulStoffregen/Time
      and use #include "TimeLib.h" instead of #include "Time.h"

    • @tropcm
      @tropcm 6 лет назад +1

      thx a lot it solved my problem :D

    • @vedantmomaya1533
      @vedantmomaya1533 6 лет назад +1

      thnx very much

    • @atriumdomy4043
      @atriumdomy4043 4 года назад +1

      @@labonczgergo5227 Thanks that helped!!! :)

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

    how to keep rtc running even the arduino off? help me

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

    what changes do i have make bcz im using 12C oled display

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

    Such a code with delay(1000) is not correct. That's because running code itself takes some time. So whole loop cycle takes 1000 + some extra. In the video you can see clearly the problem it causes - you have disappeared seconds at 16:23:15, 16:23:46, 16:24:01, 16:24:15, ... The solution could be not to delay() at all.
    EDIT: after posting this post, times I have written became recognized as video times. But they are meant to be times as seen on OLED display :)

  • @talshavit3
    @talshavit3 9 лет назад

    hi
    i'm trying to use the RTC as a timer using an interrupt but for that i need access to the control register in order to enable the SQW/OUT pin
    do you have an idea how can i do it ?
    thanks

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

      +Tal Shavit Not familiar enough with was you are trying to achieve so afraid I can't help you in this case... Thanks for watching!

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

    My arduino turns off when I connect it's power to the time module and the 7905 fuse starts to heat up, also my RTC came with the CR2023 battery already in it, please someone help me! Could the battery's inability to charge be causing this problem?

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

    i just bought one of these exact modules and it is coming with a cr2032 battery.. the ones youre saying to not use.. so i have to break the charging circuit on a brand new thing because they included a battery i cant use in it??

    • @BrainybitsCanada
      @BrainybitsCanada  4 года назад +1

      Not exactly, you see the battery that is required by default is a LIR2032, which is a rechargeable battery and can be hard to find, also expensive... but the CR2032, not rechargeable, is very common, but it cannot be used directly, since the RTC module will try to charge it, and basically kill it, or worse, cause a fire. So you have to remove the charging component for the RTC module unless you get the LIR2032. Hope that clears things up, thanks for watching! Btw you can check out my website for more info here: www.brainy-bits.com/rtc1307-arduino-library-tutorial/

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

      @@BrainybitsCanada is this something i can remove then replace in the future if/when i find the proper battery? the rtc module was only like 3$ but i still hate to break such a cool and useful feature permanently

  • @JavierRomeroo
    @JavierRomeroo 9 лет назад

    Great tutorial! Thank you very much for sharing Ivan, just ordered my module and batteries. I've already setted up the time code in my proyect, but I have to update the time every time I shut down and back up the arduino. I imagine that there's an easy way to just upload that time that I already configured in the arduino to the DS1307 right? Or either way to obtain the time online from a server with the shield and upload that to the DS1307 RTC I'm I correct?

    • @BrainybitsCanada
      @BrainybitsCanada  9 лет назад

      Javier Romero Hi, thanks for the comment! If you installed a battery in the DS1307 it should keep the time once configured even if you turn off the power. These originally use a LIR2032 rechargeable battery, but if you do the modification you can use a regular CR2032 which is easier to find and cheaper also. You can find the instructions to modify your module on our website here: brainy-bits.com/tutorials/rtc1307-arduino-library-tutorial/
      Of course if you want to get the time from a TServer and then use that info to configure the DS1307 at startup you could. :)
      Ps. Never use a regular CR2032 battery in these unless you do the modifications, since the module will try to charge it, and will damage the battery or worse...

  • @Rui5959
    @Rui5959 9 лет назад

    hello , I have here a code that works and I have to insert a speaker and an LED to an alarm clock, do you think I can you help?

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

      +Rui Duarte Gorgulho Don't have much time with taking care of the store and making videos, but check out our other videos and you might find bits a pieces that you can use for your project! Thanks for watching!

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

    have you done time and date datalogger?

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

      +Sys.stem Not Yet :) but will keep it in mind for a future video. Thanks for watching btw!

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

    I have a problem on the module , if battere CR2032 inserted , reading the serial monitor blank , if battere in detached , normal readings , I use mega2560 , CR2032 I have modified following the tutorial , please help to solve this problem , thank you

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

      +ferry Hendrawan Hard to say, but it sounds like a short when the battery is inserted, check to make sure nothing is shorted on the board when you modified it. Hope this helps and thanks for watching!

  • @raajjeshdatta9248
    @raajjeshdatta9248 9 лет назад

    How to get weekday for the same project ??. Pls advice .

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

      +Raajjesh Datta Haven't done this myself, but there is the 'weekday()' function you can add to your code to extract the day value if you want to display it. Hope this helps and thank you for watching!

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

    HELLO SIR,
    Can u help me inculcate the same code with I2C oled 128*64" module.

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

    I am facing a small problem please help me. When i run example code SetTime from the library it gives an error at (RTC.write(tm) and says
    could not convert 'DS1307RTC::write(((tmElements_t&)(& tm)))' to 'bool'
    Please help me out.
    Shall be grateful

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

    thnx a lot but the link in the description is not quite working with my laptaop but is working with my phone, pls try to fix that .If i use right click and open in new tab then it works

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

    whenever I try to set time it shows @ 'tmElements_t' does not name a type
    I downloaded the three required files !

  • @jimmyrabong342
    @jimmyrabong342 9 лет назад

    if i use nokia 5110 lcd, is the programming code still the same?thanks...

    • @BrainybitsCanada
      @BrainybitsCanada  9 лет назад

      Jimmy Kunjan Sorry for the late reply my friend, our next tutorial coming this week will cover the Nokia 5110, stay tuned! Thanks!

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

    When I try to compile, I get an error dealing with the "tmElements_t tm;" is this a common problem that you know the solution to, or would you need more info? FYI, I'm very new to Arduino, so simple terminology for now, thanks. haha

    • @j.van_heck4394
      @j.van_heck4394 8 лет назад

      My solution for this problem is downloading Arduino IDE version 1.06 on a other location. This works for me ;-)

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

      Thanks for the help getting by the error! However by doing that it fixed the error problem and lets me upload the sketches (seemingly) successfully, but when I open the serial monitor, no date or time shows up in there. Nothing shows up in there. As I'm not planning on using the OLED display, how would I confirm that the RTC is tracking time properly if nothing shows up in the serial monitor window?

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

      same goes...

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

    plz give me this libraries download links !!!!!

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

    HELLO THIS IS NICE VIDEO BUT CAN YOU COMBINE RTC AND TEMPERATURE SENSER AT SAME TIME

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

      +Md Afroz I made a video here: ruclips.net/video/FqJYb7wYAi8/видео.html where I display the temperature on a Nokia LCD, but you could use some of that code to add temperature display to this tutorial if you wanted. Hope this helps and thanks for watching!

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

    there is no display in my lcd.

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

    can u share the code for testing ?

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

      +Snaky .M Hi, you can find the code, schematic and more for all our tutorials on our website here: brainy-bits.com/tutorials
      Thanks for watching!

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

    direct link : www.brainy-bits.com/rtc1307-arduino-library-tutorial/

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

    Is it still working when Power of Arduino OFF?

    • @JoseCosta-qb4ms
      @JoseCosta-qb4ms 5 лет назад

      Yes, that's why it has a battery.
      Time keeps ticking.

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

    Cant get you code and schematic please upload the link direct link here not you website link please sor

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

    plz send me code of this

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

    to*

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

    Liked simply because you aren't Indian