In this post I’ll show you how to interface a RTC module DS3231 Real Time Clock with Arduino. This particular module uses I2C protocol to transfer current time to a micro controller. DS3231 library and header files should be installed on your computer and included in the code, otherwise you won’t be able to compile the attached sketch. I’ve added 3 push buttons to individually adjust hours, minutes and seconds variables. No external resistors are needed as Arduino has internal Pull-Ups. Here is the design schematic.
I’ve only tested this project on Arduino mega board but it should work on UNO and other compatible boards. Minor pin assignment may be required in this case. In some instances I’ve noticed that the LCD updates does not clear the previous digit value correctly leaving it visible on the display.
It mainly happens while updating the time. It looks like in update loop time values are skipped sometimes. I’ll try to investigate this behavior and fix it, making the code more stable. For now feel free to download and change the design sketch according to your needs. See this prototype operation in a short video here.