{"id":2768,"date":"2021-08-03T12:23:53","date_gmt":"2021-08-03T19:23:53","guid":{"rendered":"https:\/\/www.donluc.com\/?p=2768"},"modified":"2021-08-03T12:23:53","modified_gmt":"2021-08-03T19:23:53","slug":"project-19-time-ds3231-precision-rtc-mk01","status":"publish","type":"post","link":"https:\/\/www.donluc.com\/?p=2768","title":{"rendered":"Project #19: Time &#8211; DS3231 Precision RTC &#8211; Mk01"},"content":{"rendered":"<div style=\"width: 720px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-2768-1\" width=\"720\" height=\"480\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2021\/08\/DL2108Mk01W.mp4?_=1\" \/><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2021\/08\/DL2108Mk01W.mp4\">https:\/\/www.donluc.com\/wp-content\/uploads\/2021\/08\/DL2108Mk01W.mp4<\/a><\/video><\/div>\n<p>&#8212;&#8212;<\/p>\n<p>#DonLucElectronics #DonLuc #Time #DS3231PrecisionRTC #Arduino #ESP32 #SparkFunThingPlusESP32WROOM #Project #Programming #Electronics #Microcontrollers #Consultant #VideoBlog<\/p>\n<p>&#8212;&#8212;<\/p>\n<p><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2021\/08\/DL2108Mk01a.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2021\/08\/DL2108Mk01a.png\" alt=\"Time\" width=\"720\" height=\"534\" class=\"alignnone size-full wp-image-2770\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2021\/08\/DL2108Mk01a.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2021\/08\/DL2108Mk01a-300x223.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<p>&#8212;&#8212;<\/p>\n<p><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2021\/08\/DL2108Mk01b.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2021\/08\/DL2108Mk01b.png\" alt=\"Time\" width=\"720\" height=\"480\" class=\"alignnone size-full wp-image-2771\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2021\/08\/DL2108Mk01b.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2021\/08\/DL2108Mk01b-300x200.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<p>&#8212;&#8212;<\/p>\n<p><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2021\/08\/DL2108Mk01c.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2021\/08\/DL2108Mk01c.png\" alt=\"Time\" width=\"720\" height=\"480\" class=\"alignnone size-full wp-image-2772\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2021\/08\/DL2108Mk01c.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2021\/08\/DL2108Mk01c-300x200.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<p>&#8212;&#8212;<\/p>\n<p><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2021\/08\/DL2108Mk01d.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2021\/08\/DL2108Mk01d.png\" alt=\"Time\" width=\"720\" height=\"480\" class=\"alignnone size-full wp-image-2773\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2021\/08\/DL2108Mk01d.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2021\/08\/DL2108Mk01d-300x200.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<p>&#8212;&#8212;<\/p>\n<p><strong>DS3231 Precision RTC FeatherWing<\/strong><\/p>\n<p>A Feather board without ambition is a Feather board without FeatherWings. This is the DS3231 Precision RTC FeatherWing: it adds an extremely accurate I2C-integrated Real Time Clock (RTC) with a Temperature Compensated Crystal Oscillator (TCXO)  to any Feather main board. This RTC is the most precise you can get in a small, low power package. Most RTCs use an external 32kHz timing crystal that is used to keep time with low current draw. And that&#8217;s all well and good, but those crystals have slight drift, particularly when the temperature changes. This RTC is in a beefy package because the crystal is inside the chip. And right next to the integrated crystal is a temperature sensor. That sensor compensates for the frequency changes by adding or removing clock ticks so that the timekeeping stays on schedule.<\/p>\n<p><strong>SparkFun Micro OLED Breakout (Qwiic)<\/strong><\/p>\n<p>The SparkFun Qwiic Micro OLED Breakout is a Qwiic-enabled version of our popular Micro OLED display. The small monochrome, blue-on-black OLED screen presents incredibly clear images for your viewing pleasure. The OLED display is crisp, and you can fit a deceivingly large amount of graphics on there. This breakout is perfect for adding graphics to your next project and displaying diagnostic information without resorting to a serial output, all with the ease of use of our own Qwiic Connect System.<\/p>\n<p><strong>DL2108Mk01<\/strong><\/p>\n<p>1 x SparkFun Thing Plus &#8211; ESP32 WROOM<br \/>\n1 x SparkFun Micro OLED Breakout (Qwiic)<br \/>\n1 x DS3231 Precision RTC FeatherWing<br \/>\n1 x CR1220 3V Lithium Coin Cell Battery<br \/>\n1 x Terminal Block Breakout FeatherWing<br \/>\n1 x Qwiic Cable &#8211; 50mm<br \/>\n1 x Lithium Ion Battery &#8211; 850mAh<br \/>\n1 x Half-Size Breadboard<br \/>\n1 x SparkFun Cerberus USB Cable<\/p>\n<p><strong>SparkFun Thing Plus &#8211; ESP32 WROOM<\/strong><\/p>\n<p>DIS &#8211; Qwiic<br \/>\nSDA &#8211; Digital 23<br \/>\nSDL &#8211; Digital 22<br \/>\nVIN &#8211; +3.3V<br \/>\nGND &#8211; GND<\/p>\n<p><strong>DL2108Mk01p.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"arduino\" data-enlighter-title=\"\">\r\n\/* ***** Don Luc Electronics \u00a9 *****\r\nSoftware Version Information\r\nProject #19: Time - DS3231 Precision RTC - Mk01\r\n08-01\r\nDL2108Mk01p.ino\r\n1 x SparkFun Thing Plus - ESP32 WROOM\r\n1 x SparkFun Micro OLED Breakout (Qwiic)\r\n1 x DS3231 Precision RTC FeatherWing\r\n1 x CR1220 3V Lithium Coin Cell Battery\r\n1 x Terminal Block Breakout FeatherWing\r\n1 x Qwiic Cable - 50mm\r\n1 x Lithium Ion Battery - 850mAh\r\n1 x SparkFun Cerberus USB Cable\r\n*\/\r\n\r\n\/\/ Include the Library Code\r\n#include &lt;Wire.h&gt;\r\n\/\/ OLED\r\n#include &lt;SFE_MicroOLED.h&gt;\r\n\/\/ Date and time DS3231 RTC\r\n#include &lt;RTClib.h&gt;\r\n\r\n\/\/ OLED\r\n\/\/ DC Jumper\r\n#define DC_JUMPER 1\r\n\/\/ Optional - Connect RST on display to pin 9 on Arduino\r\n#define PIN_RESET 9\r\nMicroOLED oled(PIN_RESET, DC_JUMPER);\r\n\r\n\/\/ Set this to 1000 to get _about_ 1 second timing\r\nconst int CLOCK_SPEED = 1000;\r\n\/\/ Last Draw\r\nunsigned long lastDraw = 0;\r\n\r\n\/\/ Date and time functions using a DS3231 RTC\r\nRTC_DS3231 RTC;\r\nString sDate;\r\nString sTime;\r\n\r\n\/\/ Software Version Information\r\n\/\/ Version\r\nString sver = &quot;19-01&quot;;\r\n\r\nvoid loop()\r\n{\r\n  \/\/ Check if we need to update date, time\r\n  if (lastDraw + CLOCK_SPEED &lt; millis())\r\n  {\r\n    \r\n    \/\/ Last Draw\r\n    lastDraw = millis();\r\n    \r\n    \/\/ Dates and Time\r\n    timeRTC();\r\n\r\n    \/\/ is OLED\r\n    isOLED();\r\n    \r\n  }\r\n  \r\n}\r\n<\/pre>\n<p><strong>getOLED.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"arduino\" data-enlighter-title=\"\">\r\n\/\/ OLED\r\n\/\/ Setup OLED\r\nvoid setupOLED(){\r\n\r\n  \/\/ Initialize the OLED\r\n  oled.begin();\r\n  \/\/ Clear the display&#039;s internal memory\r\n  oled.clear(PAGE);\r\n  \/\/ Clear the library&#039;s display buffer\r\n  oled.clear(ALL);\r\n  \/\/ Display what&#039;s in the buffer\r\n  oled.display();\r\n  \r\n}\r\n\/\/ isOLED\r\nvoid isOLED(){\r\n\r\n    \/\/ Clear the buffer\r\n    oled.clear(PAGE);\r\n    \/\/ Set font to type 0\r\n    oled.setFontType(0);\r\n    \r\n    \/\/ Date\r\n    \/\/ Set cursor to top-left\r\n    oled.setCursor(0, 18);\r\n    oled.print( sDate );\r\n    \r\n    \/\/ Time\r\n    \/\/ Set cursor to top-left\r\n    oled.setCursor(0, 32);\r\n    oled.print( sTime );\r\n    \r\n    \/\/ Draw the memory buffer\r\n    oled.display();\r\n  \r\n}\r\n<\/pre>\n<p><strong>getRTCDS3231.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"arduino\" data-enlighter-title=\"\">\r\n\/\/ DS3231 Precision RTC\r\n\/\/ Setup RTC\r\nvoid setupRTC() {\r\n\r\n  \/\/ DS3231 Precision RTC   \r\n  RTC.begin();\r\n  if (! RTC.begin()) {\r\n    while (1);\r\n  }\r\n  \r\n  DateTime now = RTC.now();\r\n\r\n  if (RTC.lostPower()) {\r\n    \r\n    \/\/ Following line sets the RTC to the date &amp; time this sketch was compiled\r\n    RTC.adjust(DateTime(F(__DATE__), F(__TIME__)));\r\n    \/\/ This line sets the RTC with an explicit date &amp; time, for example to set\r\n    \/\/ August 2, 2021 at 13:53:0 you would call:\r\n    \/\/ RTC.adjust(DateTime(2021, 8, 2, 14, 11, 0));\r\n    \r\n  }\r\n  \r\n}\r\n\/\/ timeRTC\r\nvoid timeRTC() {\r\n\r\n    \/\/ DS3231 Precision RTC\r\n    sDate = &quot;&quot;;\r\n    sTime = &quot;&quot;;\r\n    \/\/ Date Time\r\n    DateTime now = RTC.now();\r\n\r\n    \/\/ sData\r\n    sDate += String(now.year(), DEC);\r\n    sDate += &quot;\/&quot;;\r\n    sDate += String(now.month(), DEC);\r\n    sDate += &quot;\/&quot;;\r\n    sDate += String(now.day(), DEC);\r\n  \r\n    \/\/ sTime\r\n    sTime += String(now.hour(), DEC);\r\n    sTime += &quot;:&quot;;\r\n    sTime += String(now.minute(), DEC);\r\n    sTime += &quot;:&quot;;\r\n    sTime += String(now.second(), DEC);\r\n\r\n}\r\n<\/pre>\n<p><strong>setup.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"arduino\" data-enlighter-title=\"\">\r\n\/\/ Setup\r\nvoid setup()\r\n{\r\n  \r\n  \/\/ Give display time to power on\r\n  delay(100);\r\n\r\n  \/\/ Set up I2C bus\r\n  Wire.begin();\r\n\r\n  \/\/ Initialize the OLED\r\n  setupOLED();\r\n\r\n  \/\/ Setup RTC\r\n  setupRTC();\r\n  \r\n}\r\n<\/pre>\n<p>&#8212;&#8212;<\/p>\n<p><strong>People can contact us:<\/strong> https:\/\/www.donluc.com\/?page_id=1927<\/p>\n<p><strong>Technology Experience<\/strong><\/p>\n<ul>\n<li>Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc&#8230;)<\/li>\n<li>IoT<\/li>\n<li>Robotics<\/li>\n<li>Research &#038; Development (R &#038; D)<\/li>\n<li>Desktop Applications (Windows, OSX, Linux, Multi-OS, Multi-Tier, etc&#8230;)<\/li>\n<li>Mobile Applications (Android, iOS, Blackberry, Windows Mobile, Windows CE, etc&#8230;)<\/li>\n<li>Web Applications (LAMP, Scripting, Java, ASP, ASP.NET, RoR, Wakanda, etc&#8230;)<\/li>\n<li>Social Media Programming &#038; Integration (Facebook, Twitter, YouTube, Pinterest, etc&#8230;)<\/li>\n<li>Content Management Systems (WordPress, Drupal, Joomla, Moodle, etc&#8230;)<\/li>\n<li>Bulletin Boards (phpBB, SMF, Vanilla, jobberBase, etc&#8230;)<\/li>\n<li>eCommerce (WooCommerce, OSCommerce, ZenCart, PayPal Shopping Cart, etc&#8230;)<\/li>\n<\/ul>\n<p><strong>Instructor<\/strong><\/p>\n<ul>\n<li>PIC Microcontrollers<\/li>\n<li>Arduino<\/li>\n<li>Raspberry Pi<\/li>\n<li>Espressif<\/li>\n<li>Robotics<\/li>\n<li>DOS, Windows, OSX, Linux, iOS, Android, Multi-OS<\/li>\n<li>Linux-Apache-PHP-MySQL<\/li>\n<\/ul>\n<p><strong>Follow Us<\/strong><\/p>\n<p><strong>J. Luc Paquin \u2013 Curriculum Vitae &#8211; 2021 English &#038; Espa\u00f1ol<\/strong><br \/>\nhttps:\/\/www.jlpconsultants.com\/CV\/LucPaquinCVEngMk2021c.pdf<br \/>\nhttps:\/\/www.jlpconsultants.com\/CV\/LucPaquinCVEspMk2021c.pdf<\/p>\n<p><strong>Web:<\/strong> https:\/\/www.donluc.com\/<br \/>\n<strong>Web:<\/strong> https:\/\/www.jlpconsultants.com\/<br \/>\n<strong>Web:<\/strong> https:\/\/www.donluc.com\/DLE\/<br \/>\n<strong>Web:<\/strong> https:\/\/www.donluc.com\/DLHackster\/<br \/>\n<strong>Web:<\/strong> https:\/\/www.hackster.io\/neosteam-labs<br \/>\n<strong>Web:<\/strong> https:\/\/zoom.us\/<br \/>\n<strong>Patreon:<\/strong> https:\/\/www.patreon.com\/DonLucElectronics<br \/>\n<strong>Facebook:<\/strong> https:\/\/www.facebook.com\/neosteam.labs.9\/<br \/>\n<strong>YouTube:<\/strong> https:\/\/www.youtube.com\/channel\/UC5eRjrGn1CqkkGfZy0jxEdA<br \/>\n<strong>Twitter:<\/strong> https:\/\/twitter.com\/labs_steam<br \/>\n<strong>Pinterest:<\/strong> https:\/\/www.pinterest.com\/NeoSteamLabs\/<br \/>\n<strong>Instagram:<\/strong> https:\/\/www.instagram.com\/neosteamlabs\/<\/p>\n<p><strong>Don Luc<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8212;&#8212; #DonLucElectronics #DonLuc #Time #DS3231PrecisionRTC #Arduino #ESP32 #SparkFunThingPlusESP32WROOM #Project #Programming #Electronics #Microcontrollers #Consultant #VideoBlog &#8212;&#8212; &#8212;&#8212; &#8212;&#8212; &#8212;&#8212; &#8212;&#8212; DS3231 Precision RTC FeatherWing A Feather board without ambition is a Feather board without FeatherWings. This is the DS3231 Precision RTC FeatherWing: it adds an extremely accurate I2C-integrated Real Time Clock (RTC) with a Temperature Compensated &#8230; <a title=\"Project #19: Time &#8211; DS3231 Precision RTC &#8211; Mk01\" class=\"read-more\" href=\"https:\/\/www.donluc.com\/?p=2768\" aria-label=\"Read more about Project #19: Time &#8211; DS3231 Precision RTC &#8211; Mk01\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[166,47,38,80,59,5,138,82,10,43],"tags":[86,6,102,4,87,19,83,85,24,9,84,27,109,33,167,34],"class_list":["post-2768","post","type-post","status-publish","format-standard","hentry","category-time","category-adafruit","category-digitalelectronics","category-esp32","category-fritzing","category-microcontrollers","category-patreon","category-program-esp32","category-projects","category-sparkfun","tag-adafruit","tag-arduino","tag-components","tag-consultant","tag-display","tag-electronics","tag-esp32","tag-fritzing","tag-microcontroller","tag-programming","tag-programming-esp32","tag-projects-2","tag-sparkfun","tag-technology","tag-time","tag-video-blog"],"_links":{"self":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/2768","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2768"}],"version-history":[{"count":2,"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/2768\/revisions"}],"predecessor-version":[{"id":4420,"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/2768\/revisions\/4420"}],"wp:attachment":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2768"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2768"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2768"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}