The Alpha Geek – Geeking Out

Project #19: Time – DS3231 Precision RTC – Mk01

——

#DonLucElectronics #DonLuc #Time #DS3231PrecisionRTC #Arduino #ESP32 #SparkFunThingPlusESP32WROOM #Project #Programming #Electronics #Microcontrollers #Consultant #VideoBlog

——

Time

——

Time

——

Time

——

Time

——

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 (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’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.

SparkFun Micro OLED Breakout (Qwiic)

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.

DL2108Mk01

1 x SparkFun Thing Plus – ESP32 WROOM
1 x SparkFun Micro OLED Breakout (Qwiic)
1 x DS3231 Precision RTC FeatherWing
1 x CR1220 3V Lithium Coin Cell Battery
1 x Terminal Block Breakout FeatherWing
1 x Qwiic Cable – 50mm
1 x Lithium Ion Battery – 850mAh
1 x Half-Size Breadboard
1 x SparkFun Cerberus USB Cable

SparkFun Thing Plus – ESP32 WROOM

DIS – Qwiic
SDA – Digital 23
SDL – Digital 22
VIN – +3.3V
GND – GND

DL2108Mk01p.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #19: Time - DS3231 Precision RTC - Mk01
08-01
DL2108Mk01p.ino
1 x SparkFun Thing Plus - ESP32 WROOM
1 x SparkFun Micro OLED Breakout (Qwiic)
1 x DS3231 Precision RTC FeatherWing
1 x CR1220 3V Lithium Coin Cell Battery
1 x Terminal Block Breakout FeatherWing
1 x Qwiic Cable - 50mm
1 x Lithium Ion Battery - 850mAh
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
#include <Wire.h>
// OLED
#include <SFE_MicroOLED.h>
// Date and time DS3231 RTC
#include <RTClib.h>

// OLED
// DC Jumper
#define DC_JUMPER 1
// Optional - Connect RST on display to pin 9 on Arduino
#define PIN_RESET 9
MicroOLED oled(PIN_RESET, DC_JUMPER);

// Set this to 1000 to get _about_ 1 second timing
const int CLOCK_SPEED = 1000;
// Last Draw
unsigned long lastDraw = 0;

// Date and time functions using a DS3231 RTC
RTC_DS3231 RTC;
String sDate;
String sTime;

// Software Version Information
// Version
String sver = "19-01";

void loop()
{
  // Check if we need to update date, time
  if (lastDraw + CLOCK_SPEED < millis())
  {
    
    // Last Draw
    lastDraw = millis();
    
    // Dates and Time
    timeRTC();

    // is OLED
    isOLED();
    
  }
  
}

getOLED.ino

// OLED
// Setup OLED
void setupOLED(){

  // Initialize the OLED
  oled.begin();
  // Clear the display's internal memory
  oled.clear(PAGE);
  // Clear the library's display buffer
  oled.clear(ALL);
  // Display what's in the buffer
  oled.display();
  
}
// isOLED
void isOLED(){

    // Clear the buffer
    oled.clear(PAGE);
    // Set font to type 0
    oled.setFontType(0);
    
    // Date
    // Set cursor to top-left
    oled.setCursor(0, 18);
    oled.print( sDate );
    
    // Time
    // Set cursor to top-left
    oled.setCursor(0, 32);
    oled.print( sTime );
    
    // Draw the memory buffer
    oled.display();
  
}

getRTCDS3231.ino

// DS3231 Precision RTC
// Setup RTC
void setupRTC() {

  // DS3231 Precision RTC   
  RTC.begin();
  if (! RTC.begin()) {
    while (1);
  }
  
  DateTime now = RTC.now();

  if (RTC.lostPower()) {
    
    // Following line sets the RTC to the date & time this sketch was compiled
    RTC.adjust(DateTime(F(__DATE__), F(__TIME__)));
    // This line sets the RTC with an explicit date & time, for example to set
    // August 2, 2021 at 13:53:0 you would call:
    // RTC.adjust(DateTime(2021, 8, 2, 14, 11, 0));
    
  }
  
}
// timeRTC
void timeRTC() {

    // DS3231 Precision RTC
    sDate = "";
    sTime = "";
    // Date Time
    DateTime now = RTC.now();

    // sData
    sDate += String(now.year(), DEC);
    sDate += "/";
    sDate += String(now.month(), DEC);
    sDate += "/";
    sDate += String(now.day(), DEC);
  
    // sTime
    sTime += String(now.hour(), DEC);
    sTime += ":";
    sTime += String(now.minute(), DEC);
    sTime += ":";
    sTime += String(now.second(), DEC);

}

setup.ino

// Setup
void setup()
{
  
  // Give display time to power on
  delay(100);

  // Set up I2C bus
  Wire.begin();

  // Initialize the OLED
  setupOLED();

  // Setup RTC
  setupRTC();
  
}

——

People can contact us: https://www.donluc.com/?page_id=1927

Technology Experience

  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Robotics
  • Research & Development (R & D)
  • Desktop Applications (Windows, OSX, Linux, Multi-OS, Multi-Tier, etc…)
  • Mobile Applications (Android, iOS, Blackberry, Windows Mobile, Windows CE, etc…)
  • Web Applications (LAMP, Scripting, Java, ASP, ASP.NET, RoR, Wakanda, etc…)
  • Social Media Programming & Integration (Facebook, Twitter, YouTube, Pinterest, etc…)
  • Content Management Systems (WordPress, Drupal, Joomla, Moodle, etc…)
  • Bulletin Boards (phpBB, SMF, Vanilla, jobberBase, etc…)
  • eCommerce (WooCommerce, OSCommerce, ZenCart, PayPal Shopping Cart, etc…)

Instructor

  • PIC Microcontrollers
  • Arduino
  • Raspberry Pi
  • Espressif
  • Robotics
  • DOS, Windows, OSX, Linux, iOS, Android, Multi-OS
  • Linux-Apache-PHP-MySQL

Follow Us

J. Luc Paquin – Curriculum Vitae – 2021 English & Español
https://www.jlpconsultants.com/CV/LucPaquinCVEngMk2021c.pdf
https://www.jlpconsultants.com/CV/LucPaquinCVEspMk2021c.pdf

Web: https://www.donluc.com/
Web: https://www.jlpconsultants.com/
Web: https://www.donluc.com/DLE/
Web: https://www.donluc.com/DLHackster/
Web: https://www.hackster.io/neosteam-labs
Web: https://zoom.us/
Patreon: https://www.patreon.com/DonLucElectronics
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/

Don Luc

Leave a Reply

Your email address will not be published. Required fields are marked *

Categories
Archives