DS323x_Generic Library for DS3231/DS3232 Extremely Accurate I2C RTC
Posted: Fri Oct 30, 2020 12:55 am
DS323x_Generic Library
How To Install Using Arduino Library Manager
Why do we need this DS323x_Generic Library
This is an Arduino library for DS3231/DS3232 Extremely Accurate I2C-Integrated RTC/TCXO/Crystal
The DS323x is a low-cost, extremely accurate I2C real-time clock (RTC) with an integrated temperature-compensated crystal oscillator (TCXO) and crystal. The device incorporates a battery input, and maintains accurate timekeeping when main power to the device is interrupted.
The examples will demonstrate how to get the UTC time from NTP server, then update the RTC to make sure the time is perfectly correct.
This DS323x_Generic Library is based on and modified from Hideaki Tai's DS323x Library to add functions and support to many boards and shields.
Releases v1.0.0
1. Initial porting to many Generic boards using WiFi/Ethernet modules/shields.
2. Add support to ESP8266, ESP32, SAMD21/SAMD51, nRF52, STM32F/L/H/G/WB/MP1 with WiFiNINA, ESP8266/ESP32 WiFi, ESP8266-AT, W5x00, ENC28J60, LAN8742A Ethernet modules/shields.
3. Fix bug. Add functions.
4. Completely new examples.
Currently Supported Boards
- ESP8266.
- ESP32.
- SAM DUE
- AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense, Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B302_ublox, NINA_B112_ublox etc..
- Arduino SAMD21 (ZERO, MKR, NANO_33_IOT, etc.).
- Adafruit SAMD21 (Itsy-Bitsy M0, Metro M0, Feather M0, Gemma M0, etc.).
- Adafruit SAMD51 (Itsy-Bitsy M4, Metro M4, Grand Central M4, Feather M4 Express, etc.).
- Seeeduino SAMD21/SAMD51 boards (SEEED_WIO_TERMINAL, SEEED_FEMTO_M0, SEEED_XIAO_M0, Wio_Lite_MG126, WIO_GPS_BOARD, SEEEDUINO_ZERO, SEEEDUINO_LORAWAN, SEEED_GROVE_UI_WIRELESS, etc.)
- STM32 (Nucleo-144, Nucleo-64, Nucleo-32, Discovery, STM32F1, STM32F3, STM32F4, STM32H7, STM32L0, etc.).
- STM32F/L/H/G/WB/MP1 (Nucleo-64 L053R8,Nucleo-144, Nucleo-64, Nucleo-32, Discovery, STM32Fx, STM32H7, STM32Lx, STM32Gx, STM32WB, STM32MP1, etc.) having 32K+ Flash program memory.
- AVR Mega, UNO, Nano
Currently Supported WiFi Modules/Shields
- ESP8266 built-in WiFi.
- ESP32 built-in WiFi.
- WiFiNINA using WiFiNINA or WiFiNINA_Generic library.
- ESP8266-AT, ESP32-AT WiFi shields using WiFiEspAT or ESP8266_AT_WebServer library. To be done soon.
Currently Supported Ethernet Modules/Shields
- W5x00's using Ethernet, EthernetLarge, Ethernet2 or Ethernet3 Library.
- ENC28J60 using EthernetENC or UIPEthernet library.
- LAN8742A using STM32Ethernet / STM32 LwIP libraries.
Examples
Alarm
1. Alarm_Ethernet
2. Alarm_STM32_Ethernet
3. Alarm_WiFiNINA
Time
4. RTC_Ethernet
5. RTC_STM32_Ethernet
6. RTC_WiFiNINA
Debug Termimal Output Samples
1. The following is debug terminal output when running example Alarm_STM32_Ethernet on STM32F7 Nucleo-144 NUCLEO_F767ZI with LAN8742A using STM32Ethernet Library.
2. The following is debug terminal output when running example RTC_STM32_Ethernet on STM32F7 Nucleo-144 NUCLEO_F767ZI with W5500 using Ethernet2 Library.
How To Install Using Arduino Library Manager
Why do we need this DS323x_Generic Library
This is an Arduino library for DS3231/DS3232 Extremely Accurate I2C-Integrated RTC/TCXO/Crystal
The DS323x is a low-cost, extremely accurate I2C real-time clock (RTC) with an integrated temperature-compensated crystal oscillator (TCXO) and crystal. The device incorporates a battery input, and maintains accurate timekeeping when main power to the device is interrupted.
The examples will demonstrate how to get the UTC time from NTP server, then update the RTC to make sure the time is perfectly correct.
This DS323x_Generic Library is based on and modified from Hideaki Tai's DS323x Library to add functions and support to many boards and shields.
Releases v1.0.0
1. Initial porting to many Generic boards using WiFi/Ethernet modules/shields.
2. Add support to ESP8266, ESP32, SAMD21/SAMD51, nRF52, STM32F/L/H/G/WB/MP1 with WiFiNINA, ESP8266/ESP32 WiFi, ESP8266-AT, W5x00, ENC28J60, LAN8742A Ethernet modules/shields.
3. Fix bug. Add functions.
4. Completely new examples.
Currently Supported Boards
- ESP8266.
- ESP32.
- SAM DUE
- AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense, Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B302_ublox, NINA_B112_ublox etc..
- Arduino SAMD21 (ZERO, MKR, NANO_33_IOT, etc.).
- Adafruit SAMD21 (Itsy-Bitsy M0, Metro M0, Feather M0, Gemma M0, etc.).
- Adafruit SAMD51 (Itsy-Bitsy M4, Metro M4, Grand Central M4, Feather M4 Express, etc.).
- Seeeduino SAMD21/SAMD51 boards (SEEED_WIO_TERMINAL, SEEED_FEMTO_M0, SEEED_XIAO_M0, Wio_Lite_MG126, WIO_GPS_BOARD, SEEEDUINO_ZERO, SEEEDUINO_LORAWAN, SEEED_GROVE_UI_WIRELESS, etc.)
- STM32 (Nucleo-144, Nucleo-64, Nucleo-32, Discovery, STM32F1, STM32F3, STM32F4, STM32H7, STM32L0, etc.).
- STM32F/L/H/G/WB/MP1 (Nucleo-64 L053R8,Nucleo-144, Nucleo-64, Nucleo-32, Discovery, STM32Fx, STM32H7, STM32Lx, STM32Gx, STM32WB, STM32MP1, etc.) having 32K+ Flash program memory.
- AVR Mega, UNO, Nano
Currently Supported WiFi Modules/Shields
- ESP8266 built-in WiFi.
- ESP32 built-in WiFi.
- WiFiNINA using WiFiNINA or WiFiNINA_Generic library.
- ESP8266-AT, ESP32-AT WiFi shields using WiFiEspAT or ESP8266_AT_WebServer library. To be done soon.
Currently Supported Ethernet Modules/Shields
- W5x00's using Ethernet, EthernetLarge, Ethernet2 or Ethernet3 Library.
- ENC28J60 using EthernetENC or UIPEthernet library.
- LAN8742A using STM32Ethernet / STM32 LwIP libraries.
Examples
Alarm
1. Alarm_Ethernet
2. Alarm_STM32_Ethernet
3. Alarm_WiFiNINA
Time
4. RTC_Ethernet
5. RTC_STM32_Ethernet
6. RTC_WiFiNINA
Debug Termimal Output Samples
1. The following is debug terminal output when running example Alarm_STM32_Ethernet on STM32F7 Nucleo-144 NUCLEO_F767ZI with LAN8742A using STM32Ethernet Library.
Code: Select all
Start Alarm_STM32_Ethernet on NUCLEO_F767ZI, using LAN8742A Ethernet & STM32Ethernet Library
[ETHERNET_WEBSERVER] Board : NUCLEO_F767ZI , setCsPin: 10
[ETHERNET_WEBSERVER] Default SPI pinout:
[ETHERNET_WEBSERVER] MOSI: 11
[ETHERNET_WEBSERVER] MISO: 12
[ETHERNET_WEBSERVER] SCK: 13
[ETHERNET_WEBSERVER] SS: 10
[ETHERNET_WEBSERVER] =========================
You're connected to the network, IP = 192.168.2.159
Packet received
Seconds since Jan 1 1900 = 3812072751
Unix time = 1603083951
The UTC time is 5:05:51
Alarm 1 is set to : 05:06:21
Alarm 1 alarm rate : 1
Alarm 2 is set to : 05:06:00
Alarm 2 alarm rate : 2
============================
05:05:52 Mon 19 Oct 2020 UTC
01:05:52 Mon 19 Oct 2020 EDT
============================
05:05:52 Mon 19 Oct 2020 UTC
01:05:52 Mon 19 Oct 2020 EDT
============================
...
============================
05:06:00 Mon 19 Oct 2020 UTC
01:06:00 Mon 19 Oct 2020 EDT
Alarm 2 activated
============================
05:06:01 Mon 19 Oct 2020 UTC
01:06:01 Mon 19 Oct 2020 EDT
============================
...
============================
05:06:20 Mon 19 Oct 2020 UTC
01:06:20 Mon 19 Oct 2020 EDT
============================
05:06:21 Mon 19 Oct 2020 UTC
01:06:21 Mon 19 Oct 2020 EDT
Alarm 1 activated
============================
05:06:22 Mon 19 Oct 2020 UTC
01:06:22 Mon 19 Oct 2020 EDT
============================
Code: Select all
Start RTC_STM32_Ethernet on NUCLEO_F767ZI, using W5x00 & Ethernet2 Library
[ETHERNET_WEBSERVER] Board : NUCLEO_F767ZI , setCsPin: 10
[ETHERNET_WEBSERVER] Default SPI pinout:
[ETHERNET_WEBSERVER] MOSI: 11
[ETHERNET_WEBSERVER] MISO: 12
[ETHERNET_WEBSERVER] SCK: 13
[ETHERNET_WEBSERVER] SS: 10
[ETHERNET_WEBSERVER] =========================
You're connected to the network, IP = 192.168.2.117
Packet received
Seconds since Jan 1 1900 = 3812054437
Unix time = 1603065637
The UTC time is 0:00:37
============================
00:00:37 Mon 19 Oct 2020 UTC
20:00:37 Sun 18 Oct 2020 EDT
============================
00:00:46 Mon 19 Oct 2020 UTC
20:00:46 Sun 18 Oct 2020 EDT