Тёмный

How to use DS3231 RTC module to build OLED clock 

Подписаться
Просмотров 34 тыс.
% 608

In this video I will show you how to use DS3231 RTC module. It will explain how to connect it to I2C bus.
Also I will show you how to display date and time readings on the OLED display.
Hope that you will find this video useful.
The code and a list of components can be found here:
www.hackster.io/mdraber/tutorial-on-how-to-use-ds3231-rtc-module-e12b38
or here
www.hackster.io/mdraber/tutorial-on-how-to-use-ds3231-rtc-module-e12b38
In the video I use I2C scanner code:
playground.arduino.cc/Main/I2cScanner/
And Library:
github.com/jarzebski/Arduino-DS3231
If you like this content and you want to support me in creating similar videos go to my Patreon webpage
www.patreon.com/MariosIdeas
Or
www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=7PD67JWZ9S3EJ&source=url
Music credits:
------------------------------
Track: Highlander - Scandinavianz [Audio Library Release]
Music provided by Audio Library Plus
Watch: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-NIGxBs8IPHM.html
Free Download / Stream: alplus.io/highlander
------------------------------

Наука

Опубликовано:

 

31 янв 2021

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 88   
@johan78jlg
@johan78jlg Месяц назад
This must be the best video on clock to oled I have seen to date, thanks!!!!
@yogenrai5651
@yogenrai5651 5 месяцев назад
Thank you so much sir for showing little details and explaining because of mentors like you the world is a better place
@geertborloo
@geertborloo 8 месяцев назад
Very clear tutorial, explaining all necessary things to know. Thanks !!
@marios_ideas
@marios_ideas 8 месяцев назад
Glad you liked it
@agaldoo
@agaldoo Год назад
Use the esp32 it has 240 mhz clock and 2MB of storage. The pins are d21(sck) and d22(sda)
@alvin0000
@alvin0000 Год назад
Thank you for share your knowledge. I follow the tutorial and it work as in your video. THANK YOU
@marios_ideas
@marios_ideas Год назад
Glad you like it.
@mywschool8910
@mywschool8910 2 года назад
This tutorial helped me a lot. Many thanks man
@sibaramdatta5625
@sibaramdatta5625 2 года назад
"Ds3231 clock redeclared as different kind of symbol" this type of message shows when tried to upload the sketch. Please help me in this regard. All libraries has been downloaded.
@davidcircuity6473
@davidcircuity6473 Год назад
I get the same error on ESP32, this seems to be an error with a separate clock library. The compilation error "redeclared as different kind of symbol" typically occurs when you have conflicting declarations or naming issues in your code. In this case, it seems that you have a naming conflict with the symbol 'DS3231 clock'. Perhaps this is due to a separate clock library we have loaded. ...but if so which library is causing the problem?
@sapitron
@sapitron 10 месяцев назад
this error happens because there are two different libraries with the same name, "DS3231", one by andrew wickert and the other one by Korneliusz Jarzebski. this last one is used in the present video. uninstall the other one. the author of the video seems to be unaware of this problem.
@am1manTravel
@am1manTravel 23 дня назад
Mario, old friend, I made this about a year ago and just fired it up again the other day. Still keeping good time! So I decided to tweak the sketch so it would show in Fahrenheit. No problem. Then I need to slightly move some of the digits, etc. Thought I'd better update my Libraries too. Did that and then troubles! Getting error msgs when I tried to validate the sketch. Had to change "clock" to "clock1" and then got other errors about RTC, etc. So now the OLED looks ok but every time I plug it in it just goes back to the same time and date every time. Tried many different tweaks in the sketch but no go. I think something happened when I updated my Libraries. Checked the battery in the DS3231 and it is fine. Perhaps , if you would be so kind, you could go back and update it. Would be most appreciated. By the way, I don't remember when I got the "OLED clock using DS3231 RTC module with the memory problem fix" mentioned in an earlier comment a year ago.
@marios_ideas
@marios_ideas 23 дня назад
Paste the setup function from the code you are trying to load
@am1manTravel
@am1manTravel 23 дня назад
@@marios_ideas Is this what you want? Also getting error: 'RTCDateTime' does not name a type; did you mean 'DateTime'? void setup() { Serial.begin(9600); Clock1.begin(); // Set sketch compiling time Clock1.setDateTime(__DATE__, __TIME__); // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64 Serial.println(F("SSD1306 allocation failed")); for (;;); // Don't proceed, loop forever } display.display(); // Display initial Adafruit logo delay(2000); // Clear the buffer display.clearDisplay(); display.display(); }
@marios_ideas
@marios_ideas 23 дня назад
@@am1manTravel You said you loaded the code after you upgraded library and the clock does not work. But now you say you get compile error so you couldn't load the code with error in code. Also the library I was using in this code is an old library which is not further developed so where did you get the update. There are other libraries written by other people with the same name so maybe you installed different library
@am1manTravel
@am1manTravel 22 дня назад
@@marios_ideas Well, I think I fixed the multiple DS3231 libraries and got the one you recommended, the latest version, in there. Still the same problem with the time.
@am1manTravel
@am1manTravel 22 дня назад
Sorry for all the msgs. Think I fixed it with ChatGPT help. Uncomment the clock1.setDateTime(__DATE__, __TIME__); line. Upload the sketch to set the time to the current compilation time. Comment out the clock1.setDateTime(__DATE__, __TIME__); line again. Re-upload the sketch so it doesn't reset the time every time it powers on.
@am1manTravel
@am1manTravel Год назад
Thank you. I used the code "OLED clock using DS3231 RTC module with the memory problem fix" and it worked! Is there a way I can change the temp from C to F? More importantly, it does not keep time when unplugged from power even though I have a fresh battery in the RTC. Any ideas?
@am1manTravel
@am1manTravel Год назад
I fixed the time issue! still looking to change C to F.
@marios_ideas
@marios_ideas Год назад
This should be a simple formula to be applied to a variable storing celcius value . Temperature in degrees Celsius (°C) = (Temperature in degrees Fahrenheit (°F) - 32) * 5/9.
@nigelholland24
@nigelholland24 Год назад
Great video. Thank you.
@marios_ideas
@marios_ideas Год назад
You're welcome:)
@PekaVuite
@PekaVuite 3 года назад
love ur new vid btw can u do a dare for me? dare: can you make an atmega328p handheld console without getting the codes from the internet (if u cant np 😁)
@charandas6162
@charandas6162 2 года назад
What will be the connection and code if we use Arduino maga or esp32
@rafteralimagno5997
@rafteralimagno5997 2 года назад
What part of the code will the address 0x68 (for the DS32321) be used? I understand that Arduino can communicate with I2C devices thru their addresses but I only see the address for the OLED being used. I hope you can respond to this. Thank you!
@marios_ideas
@marios_ideas 2 года назад
Yes you are right. In declaring the RTC you do not quote the address. So It must be done in the library code and that would indicate that DS3231 has fixed address as opposed to OLED displays which I thinkk have 2 or 3 potentialy different addresses.
@rafteralimagno5997
@rafteralimagno5997 2 года назад
@@marios_ideas Alright! I understand your explanation. Btw, I'm doing a project now. But I'm using an LCD instead of ng OLED display. The clock.dateFormat won't work whenever I want to print to the LCD or the serial monitor. I use these for trying to print: LCD: lcd.print(clock.dateFormat("H:i:s", dt)); Serial Monitor: Serial.println(clock.dateFormat("m.d.y|H:i:s", dt)); If you have any ideas about this, it will be very helpful! Thanks a lot!
@marios_ideas
@marios_ideas 2 года назад
Is it possible that it is the same memory problem that I descried for oled displays. So the rtc library plus liquid cristal library together consume too much memory. Try to remove from code lcd part and see if then serial.print works
@jahirulislamshovon9256
@jahirulislamshovon9256 3 года назад
Nice and detailed
@marios_ideas
@marios_ideas 3 года назад
Thanks:)
@mariuspetcu7482
@mariuspetcu7482 7 месяцев назад
Hello mate , I have more than 7 weeks since I am trying to reproduce you clock example but for life of me , I can't get rid of """error: no matching function for call to 'DS3231::DS3231()' DS3231 clock; """ ... Can You guide me or explain in simple words (for newbies like me - LOL) where it came from / why / where should I look ? ... I've being reading / watching tones of explanations but none of them sims to work so PLEASE , do You have a solution for this ? ... Thank You for all you hard work and for sharing with us ... Bless You
@marios_ideas
@marios_ideas 7 месяцев назад
have you intealled the library?
@mariuspetcu7482
@mariuspetcu7482 7 месяцев назад
@@marios_ideas Thank You for the answer ... Yes , the one you provide it , and I put it here : """ C:\Program Files (x86)\Arduino\libraries """ - could be / has to be installed in another place ? ... - it is possible to be in conflict with other libraries that already installed ? ... THANK You
@mariuspetcu7482
@mariuspetcu7482 7 месяцев назад
oled_clock_using_ds3231_rtc_module_:11:8: error: no matching function for call to 'DS3231::DS3231()' DS3231 clock; ^~~~~ In file included from E:\Download_NOU_Mar_2020\New folder\oled_clock_using_ds3231_rtc_module_\oled_clock_using_ds3231_rtc_module_.ino:7:0: C:\Program Files (x86)\Arduino\libraries\DS3231/DS3231.h:80:3: note: candidate: DS3231::DS3231(uint8_t, uint8_t) DS3231(uint8_t data_pin, uint8_t sclk_pin); ^~~~~~ C:\Program Files (x86)\Arduino\libraries\DS3231/DS3231.h:80:3: note: candidate expects 2 arguments, 0 provided C:\Program Files (x86)\Arduino\libraries\DS3231/DS3231.h:77:7: note: candidate: constexpr DS3231::DS3231(const DS3231&) class DS3231 ^~~~~~ C:\Program Files (x86)\Arduino\libraries\DS3231/DS3231.h:77:7: note: candidate expects 1 argument, 0 provided C:\Program Files (x86)\Arduino\libraries\DS3231/DS3231.h:77:7: note: candidate: constexpr DS3231::DS3231(DS3231&&) C:\Program Files (x86)\Arduino\libraries\DS3231/DS3231.h:77:7: note: candidate expects 1 argument, 0 provided oled_clock_using_ds3231_rtc_module_:12:1: error: 'RTCDateTime' does not name a type RTCDateTime dt; ^~~~~~~~~~~ E:\Download_NOU_Mar_2020\New folder\oled_clock_using_ds3231_rtc_module_\oled_clock_using_ds3231_rtc_module_.ino: In function 'void setup()': oled_clock_using_ds3231_rtc_module_:24:11: error: 'class DS3231' has no member named 'setDateTime'; did you mean 'setTime'? clock.setDateTime(__DATE__, __TIME__); ^~~~~~~~~~~ setTime E:\Download_NOU_Mar_2020\New folder\oled_clock_using_ds3231_rtc_module_\oled_clock_using_ds3231_rtc_module_.ino: In function 'void loop()': oled_clock_using_ds3231_rtc_module_:42:3: error: 'dt' was not declared in this scope dt = clock.getDateTime(); ^~ oled_clock_using_ds3231_rtc_module_:42:14: error: 'class DS3231' has no member named 'getDateTime'; did you mean 'getTime'? dt = clock.getDateTime(); ^~~~~~~~~~~ getTime oled_clock_using_ds3231_rtc_module_:51:27: error: 'class DS3231' has no member named 'dateFormat' display.println(clock.dateFormat("l", dt)); ^~~~~~~~~~ oled_clock_using_ds3231_rtc_module_:56:25: error: 'class DS3231' has no member named 'dateFormat' display.println(clock.dateFormat("M jS Y ", dt)); ^~~~~~~~~~ oled_clock_using_ds3231_rtc_module_:61:27: error: 'class DS3231' has no member named 'dateFormat' display.println(clock.dateFormat("H:i", dt)); ^~~~~~~~~~ oled_clock_using_ds3231_rtc_module_:66:25: error: 'class DS3231' has no member named 'dateFormat' display.println(clock.dateFormat("s", dt)); ^~~~~~~~~~ 🤣😭😥😳
@marios_ideas
@marios_ideas 7 месяцев назад
@@mariuspetcu7482Remove the library from that folder and then install the zip file through Arduino IDE. Make sure you use the exact library from the link. There are various libraries with the same name in the net. So remove all libraries reffered to ds3231 and then install the right library again
@mariuspetcu7482
@mariuspetcu7482 7 месяцев назад
@@marios_ideas Thank You for the answer mate ... I will do that and post back the result ...
@watosmate8935
@watosmate8935 4 месяца назад
Use quite a bit of memory to add an alarm and to manually change it wouldn't it?
@marios_ideas
@marios_ideas 4 месяца назад
Well the majority memory is used for OLED display buffer. With very little memory nano has to offer any library consuming slightly more memory can cause the bottleneck
@am1manTravel
@am1manTravel Год назад
Can I find/call this up on WOKWI?
@marios_ideas
@marios_ideas Год назад
WOKWI?
@am1manTravel
@am1manTravel Год назад
@@marios_ideas Oh, I thought that is how you made the diagram around 7:47. WOKWI is an arduino simulator- I'm new to it.
@flameshine2207
@flameshine2207 3 года назад
I want to know how to make a clock by using u8g2 library, how to set address for oled screen?
@marios_ideas
@marios_ideas 3 года назад
I do not know that library but I have some projects in the pipeline that will use OLED displays. If I like this library I may use it and do a small tutorial on it
@billferner6741
@billferner6741 5 месяцев назад
I run into the memory problem as soon as I started. My solution was putting all text messages (e.g. help or failure code) into the eeprom.
@ArkhaanX
@ArkhaanX 3 года назад
Thank you.
@marios_ideas
@marios_ideas 3 года назад
You're welcome:)
@priyaop5040
@priyaop5040 2 года назад
everything works fine, but when I disconnect the arduino from the PC, wait a few minutes, connect it again, Time starts from the moment where I cut off the power. Where is the fault hardware or software?
@marios_ideas
@marios_ideas 2 года назад
no battery or dead battery in the RTC?
@donzhu4996
@donzhu4996 2 года назад
@@marios_ideas Seems like I have the same issue. I checked the battery and it was full.
@marios_ideas
@marios_ideas 2 года назад
@@donzhu4996 I must be the hardware. Software is just reading the time from the RTC. The problem I had once was the time was always reset to the particular time after restart, and the solution was that there was a line in the code that was setting the particular time. But this is not the case you guys have here
@nikodemkarcz310
@nikodemkarcz310 3 года назад
Are the new version now? I did exactly the same code but it doesn’t work
@marios_ideas
@marios_ideas 3 года назад
What exactly does not work
@nikodemkarcz310
@nikodemkarcz310 3 года назад
„RTCDateTime does not name a type
@marios_ideas
@marios_ideas 3 года назад
Nikodem Karcz so do you have an error when compiling? Can you paste the line of code and an error
@marios_ideas
@marios_ideas 3 года назад
Did you install the libraries?
@nikodemkarcz310
@nikodemkarcz310 3 года назад
@@marios_ideas yup
@vijithcv
@vijithcv 2 года назад
while running the library DS3231 SIMPLE code , there is no time displayed in the Serial monitor. The code shows no error but while printing the output in the serial monitor, there is an empty space. hence current date or time is not displayed.
@marios_ideas
@marios_ideas 2 года назад
Having you checked if the device is recognized by i2c bus. Look for the i2c scanner code and run it. It will show you if the module is visible and under which address
@vijithcv
@vijithcv 2 года назад
@@marios_ideas its not the device issue. Seems some issue with the library. I am able to run the DS3231_simple code of that lib under examples and i get the date and time under Serial Monitor. But when running the DS3231_DATEFORMAT code its not giving any output and gives only blank spaces in the Serial Monitor
@vijithcv
@vijithcv 2 года назад
@@marios_ideas it was a bug in the library. In the Github page updated library file is there. After downloading that the issue is resolved
@sapitron
@sapitron 10 месяцев назад
the "redeclared as different kind of symbol" error happens because there are two different libraries with the same name, "DS3231", one by andrew wickert and the other one by Korneliusz Jarzebski. this last one is used in the present video. uninstall the other one (which is much more popular and available at the online repository). the author of the video seems to be unaware of this problem.
@marios_ideas
@marios_ideas 10 месяцев назад
At the time of vide creation I had to install the library. So at this stage I chose which one I want to install. If you installed one before and then decide to use Jarzembski's library it is clear that you have to remove the library that has the same name as both cannot coexist. I have never run into this problem as I have never installed the other library to start with. Later I experimented with both but that was after i created this video
@mominkhadri8062
@mominkhadri8062 3 года назад
you have not shared your second code, i dont have mega, will you plz send your second custon fuction code.
@mominkhadri8062
@mominkhadri8062 3 года назад
first one does not run in nano or arduino
@marios_ideas
@marios_ideas 3 года назад
In create.arduino.cc/projecthub/mdraber/tutorial-on-how-to-use-ds3231-rtc-module-e12b38?ref=user&ref_id=1474727&offset=6 there are both codes provided
@mominkhadri8062
@mominkhadri8062 3 года назад
@@marios_ideas thank you so much i got it !!!, what changes should i make in the 2nd code to show 12 hr format?
@deniker1
@deniker1 3 года назад
@@mominkhadri8062 I want a 12 hr code I've been pulling my hair all day
@mominkhadri8062
@mominkhadri8062 3 года назад
@@deniker1 same here bro
@Dimuuz
@Dimuuz Год назад
I can't find the code. The link doesn't work ⛔
@marios_ideas
@marios_ideas Год назад
I will fix it soon. It is the fault of the website i store the code on. They modernised it and it invalidated some of the links
@BoydGoldie
@BoydGoldie Год назад
Me too, the link to components and code does not work.
@marios_ideas
@marios_ideas Год назад
The site where I was storing the code was uprgading and it invalideated all my links. I have moved to hackster.io. Let me know if this works for you
@MrTutitoto
@MrTutitoto 3 года назад
Nano Every with 6KB of sram or the MKR Zero with 32KB of sram
@marios_ideas
@marios_ideas 3 года назад
Thanks. Is Nano Every recognised by Arduino IDE as Nano, How do I connect the other board to Arduino IDE
@flashcorp76
@flashcorp76 Год назад
Clock time size is (2), seconds text size is (2)…..But they are Not displayed as the same size…where is the catch ?
@marios_ideas
@marios_ideas Год назад
Ups....:) You just spotted the error in my video. I updated the link to the code in the description. There you will find the actual code that was used to achieve the result you see in this video.
@DuduHN2009
@DuduHN2009 2 года назад
SImple! ESP32!!!!! 512Kb of RAM!
@michelforget3638
@michelforget3638 3 года назад
esp32
@marios_ideas
@marios_ideas 3 года назад
Can you elaborate?:)
@driss25
@driss25 2 года назад
Not push button
@marios_ideas
@marios_ideas 2 года назад
Explain?