How to simply use DS3231 RTC module with Arduino + OLED display
Hello and welcome to this tutorial about DS3231 Real time clock module, and we gonna interface it with Arduino board, I’m using Arduino UNO as usual but today instead of the over-used (in this website/channel) LCD screen, I’m using 128*32 OLED display which is small and classy for little projects.
Before continuing, you can check my previous tutorials and projects about another RTC module which is the DS1302 :
- How to simply use DS1302 RTC module with Arduino board and LCD screen
- How to setup DS1302 RTC module with Keypad + Arduino + LCD
- Simple Arduino based Alarm Clock with DS1302 RTC
Or if you’re not familiar with the OLED display: Use OLED display + Arduino with examples
If you checked my previous DS1302 tutorials or tested it, you gonna notice that it isn’t very reliable as a module and has few problems, like if you’re using it for a long time you will notice that the time is late by few minutes which is a big problem if you need precision in your projects, but don’t forget that it’s very cheap.
But for the one I’m using today, it’s also a low cost module but it’s claimed to be “extremely accurate i²c module”, and thanks to it’s oscillator which is “Temperature compensated crystal oscillator (TCXO) and crystal”, also a good monitoring of the main power, when it goes off the battery automatically start to keep the time, and by my little experience with this module it’s very accurate a nice to use also don’t forget that it has a built in temperature sensor that can inform you of the ambient temperature which can come very handy in projects.
Wiring:
Both modules use i²c bus so the SDA and SCL for both are on A4 and A5 pins on the Arduino Uno board, those pins have double terminals as you can see, then for power the RTC uses the 5V while the OLED uses the 3.3V.
Libraries:
- DS3231 RTC library: Download from Github, A massive thanks to the creator who made it very simple and easy to use.
If you have a later version of Arduino IDE than 1.8.5 you may need to check this library
Download here, thanks to Russell Gililland for mentionning the issue.
- OLED libraries: –Donwload Adafruit SSD1306 library
–Download Adafruit GFX library
Codes:
The codes I’ve used are from the library examples : “Simple”, “Dateformat” and “Temperature”.
The other ones that I’ve used for the OLED display: Download here (Don’t forget these codes don’t setup the date and time, so it’s better to run the “Simple” example first).
Hope you like it and if you have any problem contact me, and consider a subscribe to the channel 😉
Categories
Yassine View All
Automation and Electrical Engineer, Electronics amateur trying to share my little projects.
hi how can i added 2 key for edit hour and minutes to this project??
You need a lot of modifications, better learn how to use an RTC first then use the 2 keys you want until you get that then merge it with this project.