Arduino RTC DS3231 Clock

by 32bitbradley in Circuits > Arduino

4864 Views, 12 Favorites, 0 Comments

Arduino RTC DS3231 Clock

ezgif.com-video-to-gif-1.gif

For one of my first Arduino projects, I wanted to create a DIY real-time clock. This project would allow me to build on my Arduino programming skills, allow me to work on my 3D modelling skills and circuit design/creation. This project has gotten me excited! I’ve wanted to great a digital clock that I can use in the dark for some time, it would make a great addition to my room.

Project Planning

For this project, I’m going to set a small budget of £5, which should be enough for the components as I have most of them already on hands, and the casing can be 3D printed. I don’t have a set deadline for this project so I can take my time to ensure it’s perfect. I will need to program this project, to do this I will sue the Arduino IDE software.

Specification

LCD display with BacklightControllable via buttonsReal-time, driven by RTC module4x AA Battery PoweredLow power option to save battery lifeEasy access to batteriesRounded corners on casingSmall and compact designArduino Nano Driven

Design - Dimensions

1602 I2C LCD Dimensions:

  • LCD = X – 71mm Z – 25MM Y – 4MM
  • Board + LCD= = X – 80MM Z – 35MM Y – 20MM

  • RTC Module = X – 27MM Z – 27MM Y – 10MM

  • Button = X – 6MM Z – 6MM Y – 5mm

  • Button PUSH CIRCLE – 3MM Diameter

Design - Circuit Schematic

New-Schematic-2-768x542.png

I wanted to create an easy to follow circuit schematic for this project. To do this I used the free online EasyEDA circuit designer tool. This tool had a wide library of components that I could use in my schematics and is easy to use.

This diagram will allow me to easily create a prototyping breadboard and transfer my final circuit, once tested, to perf board for the final project.

Design - Programming Arduino

Code can be found here: https://pastebin.com/Xhmki1td

Design - Casing

design-e1480291235219-768x558.jpg

I also needed to create a sketch of how I wanted the casing to look. I drew this basic design during my lunch break, It is simple but will make the block easy to use, small and compact and the LCD will be easy to read. This will make it perfect and it will suit the specification perfectly.

Design - 3D Modeling

Capture-768x394.png

Now that I had a basic design on paper, I used CAD to design a 3D model that I could 3D print. I used TinkerCAD to do this because I’m familiar with the interface and tools available. I created a main housing for the components, with holes for the buttons and LCD screen, I also added a removable screw on back that will be used to change batteries and work on the internal components. I then modelled a little button that will allow the navigations on the from face of the model to be easily pressed. You can see my 3D model below:

As per my specification, I rounded the top corners of the model. I didn’t round the bottom corners because that may have made the model rock from side to side when I forcefully press buttons half asleep during the night, this should ensure that the clock stays still.

Design - 3D Printing

20161202_173041-768x432.jpg

After designing my 3D model, I began to 3D print my casing. This is just the first draft of what the final casing will look like. This print allowed me to better see what needed changing and where I could make improvements.

The Build - Making the Circuit

20170103_102430-768x432.jpg
20170103_102439-768x432.jpg

To connect all the components together, I thought it would be a better idea to make a simple PCB out of perf board and DuPont pins. This is a lot better than my previous ‘bunch of wires’ solution, and it will help keep the components togeather while making it easier to attach inside of the casing. I’ve connected everything underneath with some wiring. I’ve used female pin headers to hold the Arduino nano. This makes it so that I won’t need to destroy the Arduino’s pins, so I can use it again if I need to.

FInished!

20170107_222657-768x432.jpg

Overall, this project was a great success, I learned a lot about Arduino programming from this project and I have made a half decent PCB. To improve the design, I could add an easier to implement, more reliable method for toggling the LCD’s LED light. I could also work on the battery life, the Lipo from Poundland seems to run out after a few hours, I guess that’s Poundland for you…

3D Model Improvements
The clock is coming along well, I have made a revision to the code. I had it previously set up where if the hour was ’00’ then to change the day. But because the clock would stay at ’00’ for a whole hour, the day kept changing every second until 1:00… XD. So, I changed the code to make the day change only when its ’00:00:00′, which works great! To better improve battery life, I have desoldered the Arduino Nano, the I2C LCD module and the charging circuit’s SMD Power LEDs.