How to simply use DS1302 RTC with Arduino and LCD screen

  Переглядів 106,697

SurtrTech

SurtrTech

6 років тому

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 років тому
You saved my project too man! Really needed that resistor and I like your library much better.
@Error-wc5fm
@Error-wc5fm 4 роки тому
Thanks for the video. You simplified the task I was facing 😀
@allan1579
@allan1579 6 років тому
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 роки тому
ukposts.info/have/v-deo/gGVpnJV5rXqTxI0.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 Рік тому
Dziękuję, pomogłeś rozwiązać mój problem - sterowanie trackerem w wyznaczonym czasie. Pozdrowienia z Polski.
@jojobonnfadal2124
@jojobonnfadal2124 7 місяців тому
Nice work ( you have an Accent like a moroccan ?!)
@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
@feliperodrigues2487
@feliperodrigues2487 4 роки тому
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.
@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 роки тому
To adjust Output Signal... these cheap modules are not that reliable...
@zahidala
@zahidala 3 роки тому
Very easy to understand. Thank you
@DuyNguyen-ol4jp
@DuyNguyen-ol4jp 8 місяців тому
if i want to show the lunar calendar, what i have to do sirr, can you teach me???
@anupkudale
@anupkudale 4 роки тому
Can you please make a video the shows a ds1302 alarm clock but NO I2C please
@blogstop8442
@blogstop8442 2 роки тому
hello please can you make a video in which a lamp on at 5pm and off at 5am with the ds1302
@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
@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
@First.Last.99
@First.Last.99 2 роки тому
thank you, your new subscriber
@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 років тому
Did it finally, I apologize for the long wait ukposts.info/have/v-deo/bmKlfKiohINmlqs.html
@HasanNaser01
@HasanNaser01 6 років тому
Thank you ..
@spyrostsimpinos2985
@spyrostsimpinos2985 2 роки тому
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
@pawez7517
@pawez7517 3 роки тому
Thank you, very nice video.
@markusosterle3958
@markusosterle3958 3 роки тому
What exactly does the resistor do to fix it?
@DEEPAKPAL01
@DEEPAKPAL01 6 років тому
Please make a video on Automatic Vacuum Cleaner such as Xiaomi does.
@SurtrTech
@SurtrTech 6 років тому
Will try may be lol
@cesarfu7540
@cesarfu7540 10 місяців тому
muchas gracias
@hpenvy1106
@hpenvy1106 4 роки тому
merci mate =)
@shahidmuneer6010
@shahidmuneer6010 3 роки тому
hello friend could you help me, my RTC DS1302 is not storing time when reboot... thank you
@RainbowPlayzo
@RainbowPlayzo 2 роки тому
How to add the AM or PM so we dont get confuse
@miguelangelcorza9144
@miguelangelcorza9144 4 роки тому
muy bueno
@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 роки тому
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!
@javierleal8049
@javierleal8049 5 років тому
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 років тому
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
@jankocurek7744
@jankocurek7744 5 років тому
I love it! Works perfectly!
@manuelantoniogallegos1279
@manuelantoniogallegos1279 4 роки тому
excuse me, how can down the librery for include virtuabotixRTC.h ..? tks..
@TheJuliusCo
@TheJuliusCo 6 років тому
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 роки тому
Maybe a tip to fix this?
@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 !
@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
@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
@nguyenhieuientu838
@nguyenhieuientu838 3 роки тому
'class DS1302' has no member named 'getTimeStr' how to fix it
@SurtrTech
@SurtrTech 6 років тому
How to setup DS1302 RTC module with Keypad? Check the channel.
@user-uv2gu8wm6h
@user-uv2gu8wm6h 4 роки тому
Can I set an alarm?
@SurtrTech
@SurtrTech 4 роки тому
Yes I have an old project for that ukposts.info/have/v-deo/bmKlfKiohINmlqs.html
@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 років тому
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.
@elsazougouri1261
@elsazougouri1261 4 роки тому
Works damn well!! Thank you very much !!
@manuelantoniogallegos1279
@manuelantoniogallegos1279 4 роки тому
excuse me, how can down the librery for include virtuabotixRTC.h ..? tks..
@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
@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
@sansritpaudel8455
@sansritpaudel8455 4 роки тому
Can we get millisecond here ?
@SurtrTech
@SurtrTech 4 роки тому
milliseconds can be measured using millis() function it's within Arduino library
@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
@kuantrung3021
@kuantrung3021 9 місяців тому
10 đ
@sparrowtree5779
@sparrowtree5779 3 роки тому
virtuabotixRTC.h: No such file or directory
@junghonest9018
@junghonest9018 2 роки тому
Metoo
@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.
@flynnrodrigues6771
@flynnrodrigues6771 2 роки тому
I DO NOT HAVE I2C BUS!.........................SHOW OF!..........
@IDNIKII
@IDNIKII Рік тому
3:18
How to setup RTC DS1302 with Keypad + LCD + Arduino
16:41
SurtrTech
Переглядів 27 тис.
Arduino Tutorial 35- Real Time Clock using DS1302 RTC Module
10:07
Enjoy Mechatronics
Переглядів 67 тис.
skibidi toilet 73 (part 2)
04:15
DaFuq!?Boom!
Переглядів 31 млн
顔面水槽がブサイク過ぎるwwwww
00:58
はじめしゃちょー(hajime)
Переглядів 66 млн
⌚️ ЧАСЫ РЕАЛЬНОГО ВРЕМЕНИ (DS1302) и АРДУИНО
6:07
SoftwareProjer - погружение в мир техники и IT
Переглядів 17 тис.
10 заповедей по пайке. Учимся паять
12:05
20 NEW INVENTIONS THAT WILL BLOW YOUR MIND
20:39
Techy Folks
Переглядів 40 тис.
12 Useful & Interesting ESP32 Projects for Beginners!
9:41
ToP Projects Compilation
Переглядів 569 тис.
Bluetooth TRIAC AC power control
10:46
Electronoobs
Переглядів 86 тис.
How to use DS1302 RTC with LCD using Arduino - For Beginners
5:38
KOTOBUKI CHANNEL
Переглядів 17 тис.
Why spend $10.000 on a flashlight when these are $200🗿
0:12
NIGHTOPERATOR
Переглядів 17 млн
Samsung or iPhone
0:19
rishton vines😇
Переглядів 4,2 млн
Клавиатура vs геймпад vs руль
0:47
Balance
Переглядів 962 тис.
ПОЛГОДА строгого режима для Lenovo Legion 5 pro. Чем может обернуться обычный ремонт ноутбука?
31:47
ААНТ КОНТАКТ Сервис по ремонту техники в ЕКБ, СПБ
Переглядів 27 тис.
ПОЛГОДА строгого режима для Lenovo Legion 5 pro. Чем может обернуться обычный ремонт ноутбука?
31:47
ААНТ КОНТАКТ Сервис по ремонту техники в ЕКБ, СПБ
Переглядів 27 тис.
APPLE УБИЛА ЕГО - iMac 27 5K
19:34
ЗЕ МАККЕРС
Переглядів 77 тис.