{"id":117,"date":"2018-12-24T18:42:26","date_gmt":"2018-12-24T18:42:26","guid":{"rendered":"http:\/\/pi.peernix.com\/?p=117"},"modified":"2018-12-24T18:42:26","modified_gmt":"2018-12-24T18:42:26","slug":"real-time-clock-with-a-atmega328-and-a-ds3231","status":"publish","type":"post","link":"http:\/\/peernix.com\/?p=117","title":{"rendered":"Real time Clock with a ATMega328 and a DS3231"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">One of the first\nArduino projects that I started off playing around with was a clock.\nThe project went through various iterations, and served as a learning\nexperience for me.  The first few sets of code I ran did not use a\nRTC (real time clock). At first I didn\u2019t notice, or was not too\nconcerned about the accuracy, but as the project grew more complex,\nand my code, probably not too efficient, I began to notice that the\ntiming was extremely off.  So with the first few instances of the\nproject scrapped, I decided that I need to go the RTC route. \n<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I purchased a few\nRTC modules, and got them working on the breadboard. I had two\nmodules, one based on the DS1308 and the other on the DS3231, using\nthem on the breadboard is identical. I had etched a few circuit\nboards thus far, and I was accustomed to using DIP components. So for\nthis project where I\u2019d etch a board, I decided to use the DS1308,\nas it comes in a DIP-8 package, and I did not want to have to use a\nseparate module in my project. I decided to also go with a DS18b20\none wire temperature sensor and a 16&#215;2 LCD.<\/p>\n\n\n\n<a href=\"https:\/\/imgbb.com\/\"><img decoding=\"async\" src=\"https:\/\/i.ibb.co\/xmFcNmt\/2017-02-24-12-50-54.jpg\" alt=\"2017-02-24-12-50-54\" border=\"0\"><\/a>\n\n\n\n<p class=\"wp-block-paragraph\">I fired up Kicad and\nset about designing a single sided PCB. Without routing any jumpers\nacross the surface of the PCB, and the fair amount of components the\ndesign was not necessarily a breeze, but not extremely complicated\neither.<\/p>\n\n\n\n<a href=\"https:\/\/imgbb.com\/\"><img decoding=\"async\" src=\"https:\/\/i.ibb.co\/vY256MC\/2017-05-14-15-51-11.jpg\" alt=\"2017-05-14-15-51-11\" border=\"0\"><\/a>\n\n\n\n<a href=\"https:\/\/imgbb.com\/\"><img decoding=\"async\" src=\"https:\/\/i.ibb.co\/TL1MHG9\/2017-05-14-15-51-25.jpg\" alt=\"2017-05-14-15-51-25\" border=\"0\"><\/a>\n\n\n\n<p class=\"wp-block-paragraph\">The etching process\nturned out pretty well. At this point I was always etching two\nidentical boards at a time, in case one should not turn out. I don\u2019t\nthink this ever was the case, usually both boards were viable, and it\nleft me with a few unused extras. Previously I had been using USB\ntype B connectors, because they are large, easy to work with, and\nmost importantly though hole female connectors. Because of the\nsuccess with the seven segment display in using a surface mount\nmini-usb connector, I decided to do the same for this project.\n(located on the back side)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The project turned out pretty well, with mainly one exception, the RTC I used (ds1308) did not seem to keep the best time. I attribute this possibly to the 32KHz crystal that I used. I\u2019m not sure how they pair the crystals to the chips, or how the modules based on this chip perform better than what I noticed, but it\u2019d perhaps stray a minute a month, which is pretty considerable, and much more than I was hoping for. But all in all, I was happy to get this project off of the breadboard to free it up for other things.<\/p>\n\n\n\n<a href=\"https:\/\/imgbb.com\/\"><img decoding=\"async\" src=\"https:\/\/i.ibb.co\/cwkSxTG\/2017-05-14-15-48-48.jpg\" alt=\"2017-05-14-15-48-48\" border=\"0\"><\/a>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><a href=\"https:\/\/ibb.co\/YLNVQ8Y\">Schematic<\/a><\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><a href=\"https:\/\/pastebin.com\/wjy8JKXR\">Code<\/a><\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I know the code is in part based on someone else&#8217;s code, however I cannot recall where I found it, so I am unable to give credit.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the first Arduino projects that I started off playing around with was a clock. The project went through various iterations, and served as a learning experience for me. The first few sets of code I ran did not use a RTC (real time clock). At first I didn\u2019t notice, or was not too<\/p>\n<div class=\"more-link\"><a href=\"http:\/\/peernix.com\/?p=117\">Read More<\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[10,12,20,23,57],"class_list":["entry","author-datz","post-117","post","type-post","status-publish","format-standard","category-electronics","tag-arduino","tag-atmega328p","tag-clock","tag-ds1308","tag-rtc"],"_links":{"self":[{"href":"http:\/\/peernix.com\/index.php?rest_route=\/wp\/v2\/posts\/117","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/peernix.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/peernix.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/peernix.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/peernix.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=117"}],"version-history":[{"count":0,"href":"http:\/\/peernix.com\/index.php?rest_route=\/wp\/v2\/posts\/117\/revisions"}],"wp:attachment":[{"href":"http:\/\/peernix.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/peernix.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=117"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/peernix.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}