How to use Arduino Real Time Clock module with DS1302 chip

แชร์
ฝัง
  • เผยแพร่เมื่อ 13 พ.ค. 2024
  • In this video, I'm going through the basics of how you can connect and interface a Real-Time Clock (RTC) module based on the DS1302 IC with Arduino.
    A Real-Time Clock, or RTC for short, is an integrated circuit that keeps track of time. It uses a backup battery to maintain time in the event that the main power source is removed.
    Additionally, I go over the principle of operation of this chip and why it is required in certain types of projects where time tracking is vital.
    The code used in this example can be found in the Instructable for the project:
    www.instructables.com/Real-Ti...
    The library used in the example is Rtc By Makuna
    www.arduino.cc/reference/en/l...
    Tools and materials used in this video:
    NodeMCU v3 - s.click.aliexpress.com/e/_9zsjMa
    DS1302 RTC Module - s.click.aliexpress.com/e/_9vbjPg
    Mini Breadboards - s.click.aliexpress.com/e/_9vg9cK
    Jumper Wires - s.click.aliexpress.com/e/_AZwpjC
    CR2032 Battery - s.click.aliexpress.com/e/_9fZL2e
    Alternate links on Banggood:
    NodeMCU v3 - www.banggood.com/custlink/vmm...
    DS1302 RTC Module - www.banggood.com/custlink/KKD...
    Mini Breadboards - www.banggood.com/custlink/mG3...
    Jumper Wires - www.banggood.com/custlink/KG3...
    CR2032 Battery - s.click.aliexpress.com/e/_9fZL2e
    Support my work on Patreon so I can continue producing free content and tutorials!
    / taste_the_code
    My recording gear:
    Samsung A71 - s.click.aliexpress.com/e/_dX2...
    SJ400 Action camera - s.click.aliexpress.com/e/_ssJRaL
    USB Condenser Microphone - s.click.aliexpress.com/e/_sMcKML
    Tripod - s.click.aliexpress.com/e/_stDAGL
    Phone tripod mount - s.click.aliexpress.com/e/_s9WaiJ
    How to use Arduino Real Time Clock module with DS1302 chip
    #arduino #rtc #realTimeClock #electronics #tastethecode
    Main Site and blog: www.tastethecode.com
    Facebook: / tastethecode
    Instagram: / taste_the_code
    Twitter: / taste_the_code
    Get exclusive Taste The Code t-shirts and merch at
    teespring.com/taste-the-code
    Click on the link below to get two months of free premium access to Skillshare and start learning today!
    skl.sh/37LnRua
    Get $50 off your order on hosting for all of your website needs and learning projects on Dreamhost!
    www.dreamhost.com/r.cgi?24057...
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 45

  • @anokhautomation4453
    @anokhautomation4453 2 ปีที่แล้ว +1

    👍nice useful tutorial. Please create more projects with rtc module. 👌

    • @TasteTheCode
      @TasteTheCode  2 ปีที่แล้ว

      Thanks! Will do definitely!

  • @GoodVibesToUsAll
    @GoodVibesToUsAll 3 ปีที่แล้ว

    Great information and nice work. New subscriber

    • @TasteTheCode
      @TasteTheCode  3 ปีที่แล้ว

      Thanks and welcome 👍👍👍

  • @AminahAbdi1
    @AminahAbdi1 ปีที่แล้ว +1

    this one help me creat a real time clock module using RTC thank you

  • @krisr5497
    @krisr5497 3 หลายเดือนก่อน +1

    This is very well explained, thank you. But I am wondering - you said the battery is being (trickle)charged (0:45). The battery you are using is not rechargeable. Could that be a problem?

    • @TasteTheCode
      @TasteTheCode  3 หลายเดือนก่อน +1

      These batteries are all based on lithium so I guess some small current does not harm them. So far I haven't had a problem at all.

  • @Equalizer-ZA
    @Equalizer-ZA 3 ปีที่แล้ว

    Hello Bill .....im from South Africa and my sons do online racing I am interested in developing a gearshift device which they can use as a gear shifter on either side of their steering wheels. They currently use ordinary switches but the more complex wheels use Hall Sensors. How can i get more in touch with you to possibly help me to change the switches out for Hall sensors .......

    • @TasteTheCode
      @TasteTheCode  3 ปีที่แล้ว

      Hey Robert, I don't usually do personal help on projects but my I would suggest that you mount a magnet on the lever of the shifter and then, behind it you can mount the hall effect sensor. You will need one that detects presence of a magnetic field and not the ones that work as on/off switches (detect magnetic polarity). Feel free to contact me through my Facebook page.

  • @akk5830
    @akk5830 2 ปีที่แล้ว +1

    Thanks a lot

  • @m0kcun
    @m0kcun 11 หลายเดือนก่อน

    I hve problem. I first upload the code using cable. Then i unplug it and using battery 9v to it. Btw mine use arduino uno. It doesnt updatind new time. Example i run on 9.00 (10/6/2023) and when i unplug and connect the battery at 10.00 the same day it just show the 9.00am one not the updating

    • @TasteTheCode
      @TasteTheCode  11 หลายเดือนก่อน

      I had that once happening to me as well but with a low-voltage battery on the module. I replaced it with a new battery and it never happened again.

    • @m0kcun
      @m0kcun 11 หลายเดือนก่อน

      @@TasteTheCode okay i wil try use new battery. THANKSSSS

  • @jonathanmitchell2070
    @jonathanmitchell2070 ปีที่แล้ว

    At 10:03, in the serial monitor, a load of junk appears on line 3. What and why is that?

    • @TasteTheCode
      @TasteTheCode  ปีที่แล้ว +1

      It happens when the reset button is pressed on the NodeMCU but I'm not really sure why. You can see it happening at 11:02 I guess it has to do with the processor starting up and maybe using different baud rate at start. I've seen this with many microcontrollers but I've never really paid any attention to it.

    • @jonathanmitchell2070
      @jonathanmitchell2070 ปีที่แล้ว

      @@TasteTheCode Thank you, I am learning, your reply is appreciated.

    • @TasteTheCode
      @TasteTheCode  ปีที่แล้ว

      You are welcome!

  • @Francesco-bu1hh
    @Francesco-bu1hh ปีที่แล้ว

    Hi, is there a way to get the day of the week?

    • @TasteTheCode
      @TasteTheCode  ปีที่แล้ว +1

      There is a function on the library called DayOfWeek() that returns 0-6, where 0 is Sunday, 1 is Monday, etc.

    • @Francesco-bu1hh
      @Francesco-bu1hh ปีที่แล้ว +1

      @@TasteTheCode Thank you. I have been viewing your channel recently. It is very interesting.

    • @TasteTheCode
      @TasteTheCode  ปีที่แล้ว

      Thank you! I'm glad that you like it!

  • @Filo-qn8pj
    @Filo-qn8pj ปีที่แล้ว

    Is there a way to use a battery instead of cable to power source?

    • @TasteTheCode
      @TasteTheCode  ปีที่แล้ว

      Yes you can. You will either need to provide 5V on the Vin pin or 3.3V regulated on any of the 3V3 pins. I have another project where I'm using power bank ICs to make a project power supply for this purpose. You can check it here: th-cam.com/video/Ze9JscCxLx8/w-d-xo.html

    • @Filo-qn8pj
      @Filo-qn8pj ปีที่แล้ว

      @@TasteTheCode Thank you, i'm doing this for a school project and they gave me an arduino board and a 9V Battery Snap DC Cable. However, I found your video and ordered the DS1302 and the NodeMCU and I just wanted to ask, does the 9V battery snap work with the NodeMCU?

    • @TasteTheCode
      @TasteTheCode  ปีที่แล้ว

      Arduinos, work on 5V, and the Uno especially have a mich larger voltage regulator to handle higher voltage range. NodeMCU works on 3.3V, and I think the max you can provide on the Vin pin is 5V. However, if tou have the Arduino, the same code should work on it as it works on the NodeMCU so you can basically just swap them.

    • @Filo-qn8pj
      @Filo-qn8pj ปีที่แล้ว

      @@TasteTheCode Could you please send me a link or the name of a battery and/or battery holder that would work on this. Sorry I am completely new to this and I am struggling.

    • @TasteTheCode
      @TasteTheCode  ปีที่แล้ว

      @@Filo-qn8pj I'm not sure what you need. Arduino Uno will work on a 9V battery and you can still use the RTC module on it in exactly the same way as on the NodeMCU.

  • @dwikiadityairfan6339
    @dwikiadityairfan6339 2 ปีที่แล้ว

    Tambahan program untuk lcdnya bagaimana ya bg?

    • @TasteTheCode
      @TasteTheCode  2 ปีที่แล้ว

      Check my other videos. I already published one for the LCD.

  • @agilalfarizal
    @agilalfarizal ปีที่แล้ว

    Apakah RTC 1302 bisa terhubung dengan esp 32 cam untuk penjadwalan pengambilan photo dan dikirimkan ke telegram jika bisa menggunakan pin yang mana mohon bantuannya

    • @TasteTheCode
      @TasteTheCode  ปีที่แล้ว

      Yes it can but that is not something that is simply executed.

  • @Thebasicmaker
    @Thebasicmaker 2 ปีที่แล้ว

    ci sono siti che danno data ora e minuti

    • @TasteTheCode
      @TasteTheCode  2 ปีที่แล้ว +1

      Yes, but this is handy if the project is not connected on the internet.

    • @Thebasicmaker
      @Thebasicmaker 2 ปีที่แล้ว

      @@TasteTheCode sure but since it has a wi-fi module I thought...

    • @TasteTheCode
      @TasteTheCode  2 ปีที่แล้ว

      I often use NodeMCUs as just demonstration, basically using them instead of an Arduino Nano or Uno.

  • @chrisleon7312
    @chrisleon7312 2 หลายเดือนก่อน

    Complete gibberish!

    • @TasteTheCode
      @TasteTheCode  2 หลายเดือนก่อน

      😱😱😱

  • @Gold007-
    @Gold007- ปีที่แล้ว

    I tried this with my ds 1302. It returns
    19/80/2091 44:127:1 +
    RTC lost confidence in the DateTime!
    data read (20) = "⸮G
    Do you know why this happens?

    • @TasteTheCode
      @TasteTheCode  ปีที่แล้ว

      Did you set the time initially? Check that the battery is OK and that it is making a good connection. I had a bad battery making weird issues once.

    • @Gold007-
      @Gold007- ปีที่แล้ว

      ​@@TasteTheCode The compiled time is set. The battery has 3 Volts and I think it has a good connection. I also tried changing the battery. That didn't work either. Could my ds 1302 be broken?

    • @TasteTheCode
      @TasteTheCode  ปีที่แล้ว

      I've never seen one to fail but it's not impossible. Do you have another one to try?