How to simply use DS1302 RTC with Arduino and LCD screen

แชร์
ฝัง
  • เผยแพร่เมื่อ 16 ม.ค. 2018
  • Hello everyone,
    In this tutorial we gonna use DS1302 Real time clock module with Arduino board and also use LCD i2c screen to show date and time on it so you can easily integrate it in your project.
    Hope you like it, and if you have a problem/question/suggestion leave it in a comment or contact me, Thanks.
    Consider a like and subscribe.
    Wiring and codes:
    surtrtech.com/2018/01/27/how-...
    Arduino RTC playlist:
    bit.ly/2I7ZwFC
    How to setup DS1302 RTC with keypad:
    • How to setup RTC DS130...
    How to use LCD i2c screen:
    • Arduino LCD i2C Screen...
    Facebook: / surtrtech
    Twitter: / surtrtech
  • วิทยาศาสตร์และเทคโนโลยี

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

  • @bkmalone864
    @bkmalone864 5 ปีที่แล้ว +8

    You saved my project too man! Really needed that resistor and I like your library much better.

  • @Error-wc5fm
    @Error-wc5fm 4 ปีที่แล้ว +4

    Thanks for the video. You simplified the task I was facing 😀

  • @allan1579
    @allan1579 6 ปีที่แล้ว +10

    Thank you! You saved my RTC. I almost threw it out of the window when it started to display shit numbers, all I needed was the resistor.

    • @abidredlove
      @abidredlove 6 ปีที่แล้ว

      plz tell me where did u put the resistor

    • @allan1579
      @allan1579 6 ปีที่แล้ว

      lotfi DZ in series with the data pin of the rtc to the digital of the arduino

    • @infatum9
      @infatum9 5 ปีที่แล้ว

      Same here. Tried multiple code versions and got 2008 for year.

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

      th-cam.com/video/H58h_BvDbcY/w-d-xo.html
      JUST GO AND WATCH IT GUYS

  • @Scanito
    @Scanito 4 ปีที่แล้ว

    Great video! Quite simple and illustrative. Thank you sir, and thanks for the library link!

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

    Dziękuję, pomogłeś rozwiązać mój problem - sterowanie trackerem w wyznaczonym czasie.
    Pozdrowienia z Polski.

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

    Very easy to understand. Thank you

  • @petittoto7433
    @petittoto7433 4 ปีที่แล้ว

    It works ! on a nano.
    Thank you

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

    thank you so much youre video saved my project, i like it

  • @DuyNguyen-ol4jp
    @DuyNguyen-ol4jp 8 หลายเดือนก่อน

    if i want to show the lunar calendar, what i have to do sirr, can you teach me???

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

    hello friend could you help me, my RTC DS1302 is not storing time when reboot...
    thank you

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

    Can you please make a video the shows a ds1302 alarm clock but NO I2C please

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

    hello please can you make a video in which a lamp on at 5pm and off at 5am with the ds1302

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

    What exactly does the resistor do to fix it?

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

    Thank you, very nice video.

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

    Thanks very much! The circuit and the software worked. I tried to use other libraries but could not get it working. May I ask why the 1K resistor made a difference to the correct timing?

    • @SurtrTech
      @SurtrTech  3 ปีที่แล้ว +2

      To adjust Output Signal... these cheap modules are not that reliable...

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

    Thanks for the video! One question though: what is the resistance value of the resistor you used? Does it have to be a specific value or could it be any resistor?

    • @SurtrTech
      @SurtrTech  4 ปีที่แล้ว

      I used 1k, I think close values should work too, I tried some.

  • @yeahtutoriales1
    @yeahtutoriales1 4 ปีที่แล้ว

    Thanks for support man!

    • @manuelantoniogallegos1279
      @manuelantoniogallegos1279 4 ปีที่แล้ว

      excuse me, how can down the librery for include virtuabotixRTC.h ..? tks..

    • @hpenvy1106
      @hpenvy1106 4 ปีที่แล้ว

      @@manuelantoniogallegos1279 get on Github, then there is a "download" button on the right. Download it and save as a zip. Then open the Arduino IDE and under "Sketch" import the zip file. Probably to late for you

  • @HasanNaser01
    @HasanNaser01 6 ปีที่แล้ว

    Thank you ..

  • @jojobonnfadal2124
    @jojobonnfadal2124 7 หลายเดือนก่อน

    Nice work
    ( you have an Accent like a moroccan ?!)

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

    'class DS1302' has no member named 'getTimeStr'
    how to fix it

  • @First.Last.99
    @First.Last.99 2 ปีที่แล้ว

    thank you, your new subscriber

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

    How to add the AM or PM so we dont get confuse

  • @charaf9099
    @charaf9099 5 ปีที่แล้ว

    i hope u're good first of all ty for that video it really helped me a lot with my project at school but i'm facing some struggels i'd like to have a help from u if that's okay ....i really wonder how we can add the names of days of week to the same program
    and ty

    • @SurtrTech
      @SurtrTech  5 ปีที่แล้ว

      Hi, I think you just sent me a message on FB, I responded there, you can add "myRTC.dayofweek" combined with a switch case

    • @charaf9099
      @charaf9099 5 ปีที่แล้ว

      @@SurtrTech yeah i'd appreciate it if u gave me more detailes because im not very good in arduino language

    • @SurtrTech
      @SurtrTech  5 ปีที่แล้ว

      @@charaf9099 I'll send you an example

    • @BreadIsNow
      @BreadIsNow 5 ปีที่แล้ว

      @@SurtrTech Hey! do you think you could post that example here :)

    • @SurtrTech
      @SurtrTech  5 ปีที่แล้ว

      @@BreadIsNow I told him about the day parameter and if you want to add it there it will be :
      "myRTC.dayofweek" and it goes from 1 to 7
      so you can add a "switch, case" structure to associate every value with a day and for example:
      switch(myRTC.dayofweek)
      case 1:
      Serial.print("Monday");
      break;
      case 2:
      Serial.print("Tuesday");
      break;
      ...That's it you can check the switch case structure on Arduino playground for more details

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

    To all the people who say that it is shows the same time continuously, for some reason i made the crystal vertical and i hit it a little and it works now, maybe it can help

  • @JerryEricsson
    @JerryEricsson 6 ปีที่แล้ว

    Greetings! Working great for me, however I did have to check the address of my display, it came back 0x3F once I changed that address in the code, I have a fine working clock. The only thing missing is an alarm function, it would be great to add that to the mix, since my old night clock was transplanted to our motor home, and I no longer have an alarm clock for those rare days when I need to rise before the damn cat wakes me up at 7:00 AM wanting the damn window open. Oh the joy of old age!

    • @SurtrTech
      @SurtrTech  6 ปีที่แล้ว

      Hello, I already have the code and the wiring for an alarm clock function, the problem is I'm a bit busy these days, I will upload it as soon as possible.

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

      Did it finally, I apologize for the long wait th-cam.com/video/62tHrqMM55w/w-d-xo.html

  • @cesarfu7540
    @cesarfu7540 10 หลายเดือนก่อน

    muchas gracias

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

    Hi, I just did the connections, downloaded the code ant id doesn't work, my ds1302 just heats and shows I'm in the 2000!
    Also why do we need 5v when the battery itself is in the module?

    • @SurtrTech
      @SurtrTech  6 ปีที่แล้ว

      Re check your wiring and watch out the pins used, and download the first code which sets up the module, and use the resistor as recommended.
      The battery cell is just for when you turn off the Arduino it keeps up the time counter

    • @TheJuliusCo
      @TheJuliusCo 6 ปีที่แล้ว

      Oh well I just bought ds3231 that works on I2C, I read it's more reliable than ds1302

    • @SurtrTech
      @SurtrTech  6 ปีที่แล้ว

      Yes it's better, the 1302 has a lot of problems

    • @pablosckX
      @pablosckX 5 ปีที่แล้ว

      @@SurtrTech Have the same problem. It just write repeatedly: Current Date / Time: 0/0/2000 0:0:0

    • @SurtrTech
      @SurtrTech  5 ปีที่แล้ว

      @@pablosckX Did you try to add the resistor? Or it may be a grounding problem

  • @karlmiguelparado3280
    @karlmiguelparado3280 4 ปีที่แล้ว

    Hi there, im quite having a problem with the program because of some errors in the code including the file extension of .h

    • @karlmiguelparado3280
      @karlmiguelparado3280 4 ปีที่แล้ว

      Im quite new with programming

    • @SurtrTech
      @SurtrTech  4 ปีที่แล้ว

      @@karlmiguelparado3280 That's a library problem, check if you installed the libraries correctly, and then check if you don't have two libraries or more of the same name

  • @alqudri9618
    @alqudri9618 5 ปีที่แล้ว

    Hy i have some problem here, my rtc was working correctly just when showing the time, but when i unplugged the vcc or gnd of the module, the time was repeated to setting time.

    • @SurtrTech
      @SurtrTech  5 ปีที่แล้ว

      Hello, upload the code, let the module count for few seconds, then reset the Arduino,
      if you get repeated time, you should first upload the setting time code and then reupload the code without setting
      otherwise it will repeat time everytime you reset the Arduino

  • @javierleal8049
    @javierleal8049 5 ปีที่แล้ว +2

    Hey man, i´m new on arduino, i set the time and date on the rtc with no problem, but in the second code i got this problem:
    " no matching function for call to 'LiquidCrystal_I2C::LiquidCrystal_I2C(int, int, int, int, int, int, int, int)' " . in the line after pin´s are defined
    it´s the same code from your page, can you help me out?
    (also i´m from mexico, so i don't have the greatest english XD )

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

      Did you install the library correctly? Or you're using a different one?
      It's a library issue, you can remove your other library and replace it with the one I used, or try to replace that function with the matching function from the library you're using.

    • @javierleal8049
      @javierleal8049 5 ปีที่แล้ว

      oh, i see the problem, thanks a lot, i solved. You're a hero @@SurtrTech

  • @miguelangelcorza9144
    @miguelangelcorza9144 4 ปีที่แล้ว

    muy bueno

  • @hpenvy1106
    @hpenvy1106 4 ปีที่แล้ว

    merci mate =)

  • @lifeforce3451
    @lifeforce3451 4 ปีที่แล้ว

    it set current time automaticly but from where it get the current time ? from the desktop computer ?

    • @SurtrTech
      @SurtrTech  4 ปีที่แล้ว

      You may find some libraries that detect time automatically, by detecting the sketch compilation date and time.
      But this library you need to set it first using the function "setDS1302Time" in "setup" then reupload the code without it

    • @lifeforce3451
      @lifeforce3451 4 ปีที่แล้ว

      ok thanks@@SurtrTech, but this project is useless if you cannot initiat with the real current time, no need library just write a win32 program windows side take the time from internet using sockets or simply windows date api, then send that data true the serial com wich your arduino is connected ans read it with serial.read() and ... voila !

  • @DEEPAKPAL01
    @DEEPAKPAL01 6 ปีที่แล้ว

    Please make a video on Automatic Vacuum Cleaner such as Xiaomi does.

    • @SurtrTech
      @SurtrTech  6 ปีที่แล้ว

      Will try may be lol

  • @jankocurek7744
    @jankocurek7744 5 ปีที่แล้ว +2

    I love it! Works perfectly!

    • @manuelantoniogallegos1279
      @manuelantoniogallegos1279 4 ปีที่แล้ว

      excuse me, how can down the librery for include virtuabotixRTC.h ..? tks..

  • @GappleXD
    @GappleXD 4 ปีที่แล้ว

    i didnt add 1k resistor but it works! but there is one problem if you reset your arduino the time resets also, can you fix this please?

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

      Hello, yes the resistor is optional, when you reset the Arduino, does the time resets to what you set it before you upload the code or it gives you some default date/time like 1/1/2000 00:00:00 ?
      If it gives you the time you set, you need first to set the correct date and time upload the code... Then comment (put "//" before) the line that contains the function of "myRTC.setDS1302Time" and reupload the code again.

    • @GappleXD
      @GappleXD 4 ปีที่แล้ว

      @@SurtrTech thanks, it now works!

  • @karlmiguelparado3280
    @karlmiguelparado3280 4 ปีที่แล้ว

    Maybe a tip to fix this?

  • @shashankpandey177
    @shashankpandey177 6 ปีที่แล้ว

    Same time is displaying repeatedly which i have set on the code even after commenting out the lines and using 1k resistor. What can be the problem???

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

      Hello, did you first upload the code with the line "myRTC.setDS1302Time..." then you should put a comment on that line and reupload the code.
      If it still doesn't work you could have a problem in the module either the battery is dead or the crystal has a problem
      Contact me on facebook if you want.

    • @shashankpandey177
      @shashankpandey177 6 ปีที่แล้ว

      SurtrTech yes i have done the above steps but still getting prblm

    • @JerryEricsson
      @JerryEricsson 6 ปีที่แล้ว

      Perhaps if you upload the second code that is meant to run the clock and not just sit the device you may have better luck. Of course I am just trying to read your mind over the thousands of miles that separate us from each other, or rather I am just guessing that may be the problem. There are two codes in the pack, if your download came properly.

  • @user-uv2gu8wm6h
    @user-uv2gu8wm6h 4 ปีที่แล้ว

    Can I set an alarm?

    • @SurtrTech
      @SurtrTech  4 ปีที่แล้ว

      Yes I have an old project for that th-cam.com/video/62tHrqMM55w/w-d-xo.html

  • @sansritpaudel8455
    @sansritpaudel8455 4 ปีที่แล้ว

    Can we get millisecond here ?

    • @SurtrTech
      @SurtrTech  4 ปีที่แล้ว

      milliseconds can be measured using millis() function it's within Arduino library

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

    Works damn well!!
    Thank you very much !!

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

      excuse me, how can down the librery for include virtuabotixRTC.h ..? tks..

  • @brianwgDK
    @brianwgDK 5 ปีที่แล้ว

    I get a error when i remove the myRTC.set time line??

    • @SurtrTech
      @SurtrTech  5 ปีที่แล้ว

      Hi, can you please tell me the whole Error?
      I think you probably, deleted the whole line which left some "comments" without their "//".
      You can just add "//" before the "myRTC.setTime" line.

    • @brianwgDK
      @brianwgDK 5 ปีที่แล้ว

      @@SurtrTech Hi thx for fast response :-) i am just adding // to the set line but im getting error
      C:\Users\black\Documents\Arduino\libraries\ArduinoRTClibrary-master\virtuabotixRTC.cpp: In function 'DS1302_write.constprop':
      C:\Users\black\Documents\Arduino\libraries\ArduinoRTClibrary-master\virtuabotixRTC.cpp:479:1: internal compiler error: Segmentation fault
      } //| |
      ^
      Please submit a full bug report,
      with preprocessed source if appropriate.
      See for instructions.
      lto-wrapper.exe: fatal error: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.19.0_x86__mdqgnx93n4wtt\hardware\tools\avr/bin/avr-gcc returned 1 exit status
      compilation terminated.
      c:/program files/windowsapps/arduinollc.arduinoide_1.8.19.0_x86__mdqgnx93n4wtt/hardware/tools/avr/bin/../lib/gcc/avr/5.4.0/../../../../avr/bin/ld.exe: error: lto-wrapper failed
      collect2.exe: error: ld returned 1 exit status
      exit status 1
      Error compiling for board Arduino Nano.

    • @SurtrTech
      @SurtrTech  5 ปีที่แล้ว

      @@brianwgDK Did it work at first then you got an error when you modified it? Or error from the start?

    • @SurtrTech
      @SurtrTech  5 ปีที่แล้ว

      @@brianwgDK It seems like an IDE problem, here I suggest you an issue that you could check (I've never tested it): forum.arduino.cc/index.php?topic=568731.0
      They suggest some solutions:
      "Tools > Board > Boards Manager
      Wait for downloads to finish.
      When you move the mouse pointer over "Arduino AVR Boards", you will see a "Select version" dropdown menu appear. Select "1.6.21".
      Click "Install".
      Wait for installation to finish.
      Click "Close"."
      Or:
      "(In the Arduino IDE) File > Preferences
      In the "Additional Boards Manager URLs" field, enter: downloads.arduino.cc/packages/package_avr_7.3.0_index.json
      If you already have an additional Boards Manager URL in that field, you can separate multiple URLs with commas or click the button on the right side of the field to open a dialog that allows you to add each on its own line.
      Click "OK"
      Tools > Board > Boards Manager
      Wait for the downloads to finish
      Click on "Arduino AVR Boards by Arduino"
      Click the "Update" button.
      Wait for the update to finish.
      Click "Close"."

    • @brianwgDK
      @brianwgDK 5 ปีที่แล้ว

      @@SurtrTech yes works fine, just cant remove set time

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

    Arduino: 1.8.12 (Windows 7), Board: "Arduino Uno"
    sketch_aug21a:19:80: error: no matching function for call to 'LiquidCrystal_I2C::LiquidCrystal_I2C(int, int, int, int, int, int, int, int)'
    LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
    ^
    In file included from C:\Users\Administrator\Documents\Arduino\sketch_aug21a\sketch_aug21a.ino:7:0:
    C:\Users\Administrator\Documents\Arduino\libraries\LiquidCrystal_I2C/LiquidCrystal_I2C.h:57:3: note: candidate: LiquidCrystal_I2C::LiquidCrystal_I2C(uint8_t, uint8_t, uint8_t)
    LiquidCrystal_I2C(uint8_t lcd_Addr,uint8_t lcd_cols,uint8_t lcd_rows);
    ^~~~~~~~~~~~~~~~~
    C:\Users\Administrator\Documents\Arduino\libraries\LiquidCrystal_I2C/LiquidCrystal_I2C.h:57:3: note: candidate expects 3 arguments, 8 provided
    C:\Users\Administrator\Documents\Arduino\libraries\LiquidCrystal_I2C/LiquidCrystal_I2C.h:55:7: note: candidate: constexpr LiquidCrystal_I2C::LiquidCrystal_I2C(const LiquidCrystal_I2C&)
    class LiquidCrystal_I2C : public Print {
    ^~~~~~~~~~~~~~~~~
    C:\Users\Administrator\Documents\Arduino\libraries\LiquidCrystal_I2C/LiquidCrystal_I2C.h:55:7: note: candidate expects 1 argument, 8 provided
    C:\Users\Administrator\Documents\Arduino\libraries\LiquidCrystal_I2C/LiquidCrystal_I2C.h:55:7: note: candidate: constexpr LiquidCrystal_I2C::LiquidCrystal_I2C(LiquidCrystal_I2C&&)
    C:\Users\Administrator\Documents\Arduino\libraries\LiquidCrystal_I2C/LiquidCrystal_I2C.h:55:7: note: candidate expects 1 argument, 8 provided
    C:\Users\Administrator\Documents\Arduino\sketch_aug21a\sketch_aug21a.ino: In function 'void setup()':
    sketch_aug21a:31:6: error: 'class LiquidCrystal_I2C' has no member named 'setBacklightPin'; did you mean 'setBacklight'?
    lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
    ^~~~~~~~~~~~~~~
    setBacklight
    sketch_aug21a:31:36: error: 'POSITIVE' was not declared in this scope
    lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
    ^~~~~~~~
    exit status 1
    no matching function for call to 'LiquidCrystal_I2C::LiquidCrystal_I2C(int, int, int, int, int, int, int, int)'
    This report would have more information with
    "Show verbose output during compilation"
    option enabled in File -> Preferences.
    help me

  • @SurtrTech
    @SurtrTech  6 ปีที่แล้ว

    How to setup DS1302 RTC module with Keypad?
    Check the channel.

  • @ahmedasaleh6547
    @ahmedasaleh6547 5 ปีที่แล้ว

    hello, can you please make a video on how to use the DS1302 Real time clock module with OLED instead of LCD,
    thanks. :-)

    • @SurtrTech
      @SurtrTech  5 ปีที่แล้ว

      Okay will do probably soon,
      If you can't wait you can check my tutorial where I did OLED + DS3231, and replace the functions

  • @danilkovalevsky6981
    @danilkovalevsky6981 4 ปีที่แล้ว

    your code doesnt work by me what i need to do

    • @SurtrTech
      @SurtrTech  4 ปีที่แล้ว

      Did you install the libraries, or for the LCD do you use another library? You can change it or adapt it if you want.

  • @kuantrung3021
    @kuantrung3021 9 หลายเดือนก่อน

    10 đ

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

    virtuabotixRTC.h: No such file or directory

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

    I DO NOT HAVE I2C BUS!.........................SHOW OF!..........

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

    3:18