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/ Наука
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
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.
That's great to hear that the video helped! Thanks for the Sub and for watching!
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
DisturbinThaPeece Thanks for your comment! Great to hear that it's helping people learning this stuff.
thanks a lot! I had a lot of problems with my RTC, but this video solved them all!
First tutorial helped me with setting time.
I tried tons but not sucessed.
Awesome :)
Again an awesome tutorial. You do the best explaining of the code I have ever seen. Happily subscribed to your channel.
Merci beaucoup.
+iHayri1 Thanks again for watching and for the Sub! :)
Thanks Yvan, it works great!
+Marcel Hebert Thanks for watching Marcel :) glad it helped you!
Thanks a lot for tutorial!! Thanks the others to solve some issues in comments!
Very useful! Thanks a lot for your tutorial! =]
Thanks for watching :)
you are the best!
+drago zengen I don't think so, actually far from it, but thank you for watching :)
Removing these circuits R4,R5 R6 and D1 will it dammage or affect performance of the EEPROM that it has integrated?
BIG THANKS
+maverickstar reloaded You're welcome :) thanks for watching!
Great video
sir can we modify it to simple time base switch without depending on actual time.
Nice job.
+Dan Murphy Thanks for the comment and for watching!
What if I'm just watching this and only have an LCD screen, not OLED. What changes would I make to the code?
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
Why there are two sets of pins for I2C communication ?
Hi Brainy-Bits! I just wanna ask is it possible to combine a water sensor and RTC program? Thanks.
+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 :)
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?
Could this RTC take the time from a smartphone as opposed to a computer?
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.
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 😍
Is DS1307 Real Time Clock in this tutorial support with ESP8266?
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?
+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!
Like some others I could not get your code to complie.
Error...
'tmElements_t' was not declared in this scope
Thanks
like me. you can solve that?
You should try another library: github.com/PaulStoffregen/Time
and use #include "TimeLib.h" instead of #include "Time.h"
thx a lot it solved my problem :D
thnx very much
@@labonczgergo5227 Thanks that helped!!! :)
how to keep rtc running even the arduino off? help me
what changes do i have make bcz im using 12C oled display
github.com/PaulStoffregen/DS1307RTC
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 :)
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
+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!
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?
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??
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/
@@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
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?
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...
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?
+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!
have you done time and date datalogger?
+Sys.stem Not Yet :) but will keep it in mind for a future video. Thanks for watching btw!
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
+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!
How to get weekday for the same project ??. Pls advice .
+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!
HELLO SIR,
Can u help me inculcate the same code with I2C oled 128*64" module.
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
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
whenever I try to set time it shows @ 'tmElements_t' does not name a type
I downloaded the three required files !
use #include , its wont show error in tmElements
if i use nokia 5110 lcd, is the programming code still the same?thanks...
Jimmy Kunjan Sorry for the late reply my friend, our next tutorial coming this week will cover the Nokia 5110, stay tuned! Thanks!
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
My solution for this problem is downloading Arduino IDE version 1.06 on a other location. This works for me ;-)
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?
same goes...
plz give me this libraries download links !!!!!
HELLO THIS IS NICE VIDEO BUT CAN YOU COMBINE RTC AND TEMPERATURE SENSER AT SAME TIME
+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!
there is no display in my lcd.
can u share the code for testing ?
+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!
direct link : www.brainy-bits.com/rtc1307-arduino-library-tutorial/
Is it still working when Power of Arduino OFF?
Yes, that's why it has a battery.
Time keeps ticking.
Cant get you code and schematic please upload the link direct link here not you website link please sor
plz send me code of this
to*
Liked simply because you aren't Indian