{"id":1929,"date":"2019-08-30T07:43:41","date_gmt":"2019-08-30T14:43:41","guid":{"rendered":"http:\/\/www.donluc.com\/?p=1929"},"modified":"2019-08-30T07:43:41","modified_gmt":"2019-08-30T14:43:41","slug":"project-11-esp32-feather-ds3231-precision-rtc-mk03","status":"publish","type":"post","link":"https:\/\/www.donluc.com\/?p=1929","title":{"rendered":"Project #11: ESP32 Feather &#8211; DS3231 Precision RTC &#8211; Mk03"},"content":{"rendered":"<p><strong>Adafruit HUZZAH32 ESP32 Feather<\/strong><\/p>\n<p>&#8212;&#8212;<\/p>\n<div style=\"width: 720px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-1929-1\" width=\"720\" height=\"406\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2019\/08\/dl1908mk03.mp4?_=1\" \/><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2019\/08\/dl1908mk03.mp4\">https:\/\/www.donluc.com\/wp-content\/uploads\/2019\/08\/dl1908mk03.mp4<\/a><\/video><\/div>\n<p>&#8212;&#8212;<\/p>\n<p><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2019\/08\/DL1908Mk03a.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2019\/08\/DL1908Mk03a.png\" alt=\"ESP32 Feather - DS3231 Precision RTC\" width=\"720\" height=\"652\" class=\"alignnone size-full wp-image-1931\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2019\/08\/DL1908Mk03a.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2019\/08\/DL1908Mk03a-300x272.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\/2019\/08\/DL1908Mk03b.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2019\/08\/DL1908Mk03b.png\" alt=\"ESP32 Feather - DS3231 Precision RTC\" width=\"720\" height=\"480\" class=\"alignnone size-full wp-image-1932\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2019\/08\/DL1908Mk03b.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2019\/08\/DL1908Mk03b-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\/2019\/08\/DL1908Mk03c.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2019\/08\/DL1908Mk03c.png\" alt=\"ESP32 Feather - DS3231 Precision RTC\" width=\"720\" height=\"480\" class=\"alignnone size-full wp-image-1933\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2019\/08\/DL1908Mk03c.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2019\/08\/DL1908Mk03c-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\/2019\/08\/DL1908Mk03d.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2019\/08\/DL1908Mk03d.png\" alt=\"ESP32 Feather - DS3231 Precision RTC\" width=\"720\" height=\"480\" class=\"alignnone size-full wp-image-1934\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2019\/08\/DL1908Mk03d.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2019\/08\/DL1908Mk03d-300x200.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<p>&#8212;&#8212;<\/p>\n<p><strong>Adafruit 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 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.<\/p>\n<p>With a CR1220 12mm lithium battery plugged into the top of the FeatherWing, you can get years of precision timekeeping, even when main power is lost. Great for datalogging and clocks, or anything where you need to really know the time.<\/p>\n<p><strong>DonLuc1908Mk03<\/strong><\/p>\n<p>1 x Adafruit HUZZAH32 ESP32 Feather<br \/>\n1 x Adafruit SHARP Memory Display<br \/>\n1 x Adafruit DS3231 Precision RTC FeatherWing<br \/>\n1 x CR1220 12mm Lithium Battery<br \/>\n1 x LED Green<br \/>\n1 x Push Button<br \/>\n1 x 100 Ohm<br \/>\n1 x 10K Ohm<br \/>\n14 x Jumper Wires 3&#8243; M\/M<br \/>\n2 x Jumper Wires 6&#8243; M\/M<br \/>\n1 x Full-Size Breadboard<br \/>\n1 x SparkFun Cerberus USB Cable<\/p>\n<p><strong>Adafruit HUZZAH32 ESP32 Feather<\/strong><\/p>\n<p>LG1 &#8211; Digital 21<br \/>\nPB1 &#8211; Digital 17<br \/>\nSCK &#8211; Digital 13<br \/>\nMOS &#8211; Digital 12<br \/>\nSSD &#8211; Digital 27<br \/>\nSDA &#8211; Digital 23<br \/>\nSCL &#8211; Digital 22<br \/>\nGND &#8211; GND<br \/>\nVIN &#8211; +3.3V<\/p>\n<p><strong>DL1908Mk03p.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"default\" data-enlighter-title=\"DL1908Mk03p.ino\">\r\n\/\/ ***** Don Luc Electronics *****\r\n\/\/ Software Version Information\r\n\/\/ Project #11: HUZZAH32 ESP32 Feather - DS3231 Precision RTC - Mk03\r\n\/\/ 08-03\r\n\/\/ DonLuc1908Mk03p.ino 08-03\r\n\/\/ Adafruit HUZZAH32 ESP32 Feather Board\r\n\/\/ SHARP Display\r\n\/\/ LED Green\r\n\/\/ Push Button\r\n\/\/ DS3231 Precision RTC \r\n\r\n\/\/ include Library Code\r\n#include &lt;Adafruit_SharpMem.h&gt;\r\n#include &lt;Adafruit_GFX.h&gt;\r\n#include &lt;RTClib.h&gt;\r\n#include &lt;Wire.h&gt;\r\n\r\n\/\/ SHARP Memory Display\r\n\/\/ any pins can be used\r\n#define SHARP_SCK  13\r\n#define SHARP_MOSI 12\r\n#define SHARP_SS   27\r\n\/\/ Set the size of the display here, e.g. 144x168!\r\nAdafruit_SharpMem display(SHARP_SCK, SHARP_MOSI, SHARP_SS, 144, 168);\r\n\/\/ The currently-available SHARP Memory Display (144x168 pixels)\r\n\/\/ requires &gt; 4K of microcontroller RAM; it WILL NOT WORK on Arduino Uno\r\n\/\/ or other &lt;4K &quot;classic&quot; devices!\r\n#define BLACK 0\r\n#define WHITE 1\r\nint minorHalfSize; \/\/ 1\/2 of lesser of display width or height\r\n\r\n\/\/ LED Green\r\nint iLEDGreen =  21;                 \/\/ LED Green\r\nint stateLEDGreen = LOW;             \/\/ stateLEDGreen \r\n\r\n\/\/ Button\r\nint iBut1 = 17;                      \/\/ Button 1\r\nint ButState1;                       \/\/ Variable for reading the button status\r\nint previous = LOW;                  \/\/ previous\r\nlong lTime = 0;                      \/\/ lTime\r\nlong debounce = 500;                 \/\/ debounce\r\n\r\n\/\/ DS3231 Precision RTC \r\nRTC_DS3231 RTC;\r\nString sDate;\r\nString sTime;\r\n\r\nvoid loop() {\r\n  \r\n  \/\/ Read the state of the button value\r\n  ButState1 = digitalRead(iBut1);\r\n  \r\n  \/\/ Check if the button is pressed\r\n  if (ButState1 == HIGH &amp;&amp; previous == LOW &amp;&amp; millis() - lTime &gt; debounce) \r\n  {\r\n\r\n     if(stateLEDGreen == HIGH)\r\n     {\r\n      \r\n        \/\/ stateLEDGreen = LOW\r\n        stateLEDGreen = LOW;\r\n        \/\/ DS3231 Precision RTC \r\n        timeRTC();\r\n        \/\/ SHARP Memory Display Off\r\n        isDisplayOff();\r\n\r\n             \r\n     } else \r\n     {\r\n\r\n        \/\/ stateLEDGreen = HIGH\r\n        stateLEDGreen = HIGH;\r\n        \/\/ DS3231 Precision RTC \r\n        timeRTC(); \r\n        \/\/ SHARP Memory Display On\r\n        isDisplayOn();\r\n            \r\n    }\r\n    lTime = millis();\r\n\r\n  } \r\n\r\n  \/\/ iLEDGreen\r\n  digitalWrite(iLEDGreen, stateLEDGreen);\r\n  previous == ButState1;  \r\n \r\n}\r\n<\/pre>\n<p><strong>getDisplay.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"default\" data-enlighter-title=\"getDisplay.ino\">\r\n\/\/ SHARP Memory Display On\r\nvoid isDisplayOn() {\r\n\r\n    \/\/ Clear Display\r\n    display.clearDisplay();\r\n    \/\/ text display date, time, LED on\r\n    display.setRotation(4);\r\n    display.setTextSize(2);\r\n    display.setTextColor(BLACK);\r\n    display.setCursor(10,10);\r\n    display.println( sDate );\r\n    display.setCursor(10,30);\r\n    display.println( sTime );\r\n    display.setTextSize(3);\r\n    display.setCursor(10,55);\r\n    display.println(&quot;LED On&quot;);\r\n    display.refresh();\r\n\r\n}\r\n\/\/ SHARP Memory Display Off\r\nvoid isDisplayOff() {\r\n\r\n    \/\/ Clear Display\r\n    display.clearDisplay();\r\n    \/\/ text display date, time, LED off\r\n    display.setRotation(4);\r\n    display.setTextSize(2);\r\n    display.setTextColor(BLACK);\r\n    display.setCursor(10,10);\r\n    display.println( sDate );\r\n    display.setCursor(10,30);\r\n    display.println( sTime );\r\n    display.setTextSize(3);    \r\n    display.setCursor(10,55);\r\n    display.println(&quot;LED Off&quot;);\r\n    display.refresh();\r\n\r\n}\r\n<\/pre>\n<p><strong>getRTCDS3231.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"default\" data-enlighter-title=\"getRTCDS3231.ino\">\r\n\/\/ DS3231 Precision 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    \/\/ 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  }\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    \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=\"default\" data-enlighter-title=\"setup.ino\">\r\n\/\/ Setup\r\nvoid setup() {\r\n\r\n  \/\/ SHARP Display start &amp; clear the display\r\n  display.begin();\r\n  display.clearDisplay();\r\n\r\n  \/\/ Button 1\r\n  \/\/ Initialize the button as an input\r\n  pinMode(iBut1, INPUT);\r\n  \r\n  \/\/ Initialize the LED Green\r\n  pinMode(iLEDGreen, OUTPUT);\r\n\r\n  \/\/ DS3231 Precision RTC \r\n  setupRTC();\r\n\r\n  \/\/ stateLEDGreen = LOW\r\n  stateLEDGreen = LOW;\r\n  \/\/ DS3231 Precision RTC \r\n  timeRTC();\r\n  \/\/ SHARP Memory Display Off\r\n  isDisplayOff();  \r\n    \r\n}\r\n<\/pre>\n<p><strong>Follow Us<\/strong><\/p>\n<p><strong>Web:<\/strong> https:\/\/www.donluc.com\/<br \/>\n<strong>Web:<\/strong> http:\/\/neosteamlabs.com\/<br \/>\n<strong>Web:<\/strong> http:\/\/www.jlpconsultants.com\/<br \/>\n<strong>YouTube:<\/strong> https:\/\/www.youtube.com\/channel\/UC5eRjrGn1CqkkGfZy0jxEdA<br \/>\n<strong>Facebook:<\/strong> https:\/\/www.facebook.com\/neosteam.labs.9\/<br \/>\n<strong>Instagram:<\/strong> https:\/\/www.instagram.com\/neosteamlabs\/<br \/>\n<strong>Pinterest:<\/strong> https:\/\/www.pinterest.com\/NeoSteamLabs\/<br \/>\n<strong>Twitter:<\/strong> https:\/\/twitter.com\/labs_steam<br \/>\n<strong>Etsy:<\/strong> https:\/\/www.etsy.com\/shop\/NeoSteamLabs<\/p>\n<p><strong>Don Luc<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Adafruit HUZZAH32 ESP32 Feather &#8212;&#8212; &#8212;&#8212; &#8212;&#8212; &#8212;&#8212; &#8212;&#8212; &#8212;&#8212; Adafruit 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 Crystal Oscillator to any Feather main board. This &#8230; <a title=\"Project #11: ESP32 Feather &#8211; DS3231 Precision RTC &#8211; Mk03\" class=\"read-more\" href=\"https:\/\/www.donluc.com\/?p=1929\" aria-label=\"Read more about Project #11: ESP32 Feather &#8211; DS3231 Precision RTC &#8211; Mk03\">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":[81,47,38,80,5,82,10],"tags":[86,6,87,19,83,85,24,9,84],"class_list":["post-1929","post","type-post","status-publish","format-standard","hentry","category-esp32-project","category-adafruit","category-digitalelectronics","category-esp32","category-microcontrollers","category-program-esp32","category-projects","tag-adafruit","tag-arduino","tag-display","tag-electronics","tag-esp32","tag-fritzing","tag-microcontroller","tag-programming","tag-programming-esp32"],"_links":{"self":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/1929","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=1929"}],"version-history":[{"count":2,"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/1929\/revisions"}],"predecessor-version":[{"id":3026,"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/1929\/revisions\/3026"}],"wp:attachment":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1929"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1929"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1929"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}