Page 1 of 2

High Accuracy DS3231 RTC & EEPROM (HCMODU0094)

Posted: Tue Jan 12, 2016 4:40 pm
by admin
Image


Image

The I2C real time clock module (HCMODU0094) is based on the Maxim high accuracy DS3231 real time clock controller. Using an internal temperature compensation crystal oscillator this RTC IC is able to provide extremely high accurate time keeping. The module includes an on-board battery backup and maintains accurate timekeeping when main power to the device is interrupted. The RTC maintains seconds, minutes, hours, day, date, month, and year information. The date at the end of the month is automatically adjusted for months with fewer than 31 days, including corrections for leap year. The clock operates in either the 24-hour or 12-hour format with an AM/PM indicator. Two programmable time-of-day alarms and a programmable square-wave output are provided. Address and data are transferred serially
through an I2C bidirectional bus. A precision temperature-compensated voltage reference and comparator circuit monitors the status of VCC to detect power failures, to provide a reset output, and to automatically switch to the backup supply when necessary.

Included on this module is an Atmel 24C32 32K (4096 x 8) serial I2C EEPROM which allows the module to be used as a simple data logger storing up to 4K of 8 bit data.


If you plan to use this module with a standard Arduino then you can take advantage of our exclusive library (HCRTC) to quickly integrate this module into your own Arduino project. The library also provides the ability to read and write to the included EEPROM.


Features (RTC):

Highly Accurate RTC Completely Manages All Timekeeping Functions
Real-Time Clock Counts Seconds, Minutes, Hours, Date of the Month, Month, Day of the Week, and Year, with Leap-Year Compensation Valid Up to 2100
Accuracy ±2ppm from 0°C to +40°C
Digital Temp Sensor Output: ±3°C Accuracy
Register for Aging Trim
Two Time-of-Day Alarms
Programmable Square-Wave Output Signal
Simple Serial Interface Connects to Most Microcontrollers
Fast (400kHz) I2C Interface
Battery-Backup Input for Continuous Timekeeping
2.3V to 5.5V Operation
Operating Temperature Ranges: 0°C to +70°C


Features (EEPROM):

Low-Voltage and Standard-Voltage Operation 2.7 (VCC = 2.7V to 5.5V)
Internally Organized 8192 x 8
2-Wire Serial Interface
Schmitt Trigger, Filtered Inputs for Noise Suppression
Bidirectional Data Transfer Protocol
100 kHz (1.8V, 2.5V, 2.7V) and 400 kHz (5V) Clock Rate
32-Byte Page Write Mode (Partial Page Writes Allowed)
Self-Timed Write Cycle (10 ms max)
High Reliability Endurance: 1 Million Write Cycles Data Retention: 100 Years



Image



Image

Image


Image


Image
  1. /* FILE     HCRTC_Example.cpp
  2.    DATE:    23/12/13
  3.    VERSION: 0.2
  4.    AUTHOR:  Andrew Davies
  5.  
  6. This is an example of how to use the Hobby Components RTC library to read and
  7. write to and from the DS3231 real time clock & 24C32 EEPROM (HCMODU0094).
  8.  
  9. You may copy, alter and reuse this code in any way you like, but please leave
  10. reference to HobbyComponents.com in your comments if you redistribute this code.
  11. This software may not be used directly for the purpose of selling products that
  12. directly compete with Hobby Components Ltd's own range of products.
  13.  
  14. THIS SOFTWARE IS PROVIDED "AS IS". HOBBY COMPONENTS MAKES NO WARRANTIES, WHETHER
  15. EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
  16. MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ACCURACY OR LACK OF NEGLIGENCE.
  17. HOBBY COMPONENTS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR ANY DAMAGES,
  18. INCLUDING, BUT NOT LIMITED TO, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY
  19. REASON WHATSOEVER.
  20. */
  21.  
  22.  
  23. /* Include the wire library */
  24. #include "Wire.h"
  25. /* Include the Hobby Components RTC library */
  26. #include <HCRTC.h>
  27.  
  28. /* Define the I2C addresses for the RTC and EEPROM */
  29. #define I2CDS3231Add 0x68
  30. #define I2C24C32Add  0x57
  31.  
  32. /* Example string to write to EEPROM */
  33. char ExampleString[] = "Hobby Components";
  34.  
  35. /* Used in example as an index pointer */
  36. byte index;
  37.  
  38. /* Create an instance of HCRTC library */
  39. HCRTC HCRTC;
  40.  
  41.  
  42. void setup()
  43. {
  44.   Serial.begin(9600);
  45.  
  46.   /* Use the RTCWrite library function to set the time and date.
  47.      Parameters are: I2C address, year, month, date, hour, minute, second,
  48.      day of week */
  49.   HCRTC.RTCWrite(I2CDS3231Add, 13, 4, 24, 14, 21, 0, 3);
  50. }
  51.  
  52. void loop()
  53. {
  54.   /************* Example write to EEPROM ***************/  
  55.  
  56.   /* Initiate a write sequence.
  57.      Parameters are: I2C address, EEPROM start location */
  58.   HCRTC.EEStartWrite(I2C24C32Add, 32000);
  59.  
  60.   for (index = 0; index < sizeof(ExampleString); index++)
  61.   {  
  62.     /* Sequentially write example data to the EEPROM */
  63.     HCRTC.EEWriteByte(ExampleString[index]);
  64.   }
  65.   /* End the write sequence */
  66.   HCRTC.EEEndWrite();
  67.  
  68.   /* Wait for cached data to finish writing */
  69.   delay(10);  
  70.  
  71.  
  72.   /************* Example read from EEPROM ***************/  
  73.  
  74.   /* Initiate read sequence.
  75.      Parameters are: I2C address, EEPROM start location */
  76.   HCRTC.EEStartRead(I2C24C32Add, 32000);
  77.  
  78.  
  79.   for (index = 0; index < sizeof(ExampleString); index++)
  80.   {
  81.     /* Sequentially read data from EEPROM and output it to the UART */
  82.     Serial.write(HCRTC.EEReadByte(I2C24C32Add));
  83.   }    
  84.   Serial.println();
  85.    
  86.  
  87.   /* Continuously read the current time and date from the RTC */
  88.   while(true)
  89.   {
  90.     /* Read the current time from the RTC module */
  91.     HCRTC.RTCRead(I2CDS3231Add);
  92.    
  93.     /* Output the information to the UART */
  94.     Serial.print(HCRTC.GetDay());
  95.     Serial.print("/");
  96.     Serial.print(HCRTC.GetMonth());
  97.     Serial.print("/");
  98.     Serial.print(HCRTC.GetYear());
  99.     Serial.print(" ");
  100.    
  101.     Serial.print(HCRTC.GetHour());
  102.     Serial.print(":");
  103.     Serial.print(HCRTC.GetMinute());
  104.     Serial.print(":");
  105.     Serial.print(HCRTC.GetSecond());
  106.     Serial.print(" DOW:");
  107.     Serial.println(HCRTC.GetWeekday());
  108.    
  109.     /* Now output the same thing but using string functions instead: */
  110.     Serial.print(HCRTC.GetDatestring());
  111.     Serial.print(" ");
  112.     Serial.println(HCRTC.GetTimestring());
  113.    
  114.     /* Wait a second before reading again */
  115.     delay(1000);  
  116.   }
  117. }



Image


Arduino Library:
The HCRTC library can be found within the software section of this forum here


Datasheets:
DS3231.pdf
24C32.pdf

Re: High Accuracy DS3231 RTC & EEPROM (HCMODU0094)

Posted: Fri Jun 17, 2016 4:43 pm
by seamus639
Hi guys,
I'm having trouble with the HCRTC sketch.
I'm getting an error saying that HCRTC.h doesn't exist. Please see screenshot.jpg attached.
Image
Many thanks in advance for any advice you can give

Seamus

Re: High Accuracy DS3231 RTC & EEPROM (HCMODU0094)

Posted: Sat Jun 18, 2016 7:58 am
by andrew
It looks like the library files are in the wrong place. The two files that end in .h and .cpp need to be put in the following location:

My Documents\Arduino\libraries\HCRTC\

If any of these folders don't exist just create them. After you have moved them there you will also need to restart your Arduino IDE.

Alternatively you should be able to install the library by selecting Sketch->Include Library->Add .Zip library in your Arduino IDE. Then just point it to the HCRTC.zip (must be in its zipped form) file. It should then automatically unzip the files and put them in your Library folder.

Re: High Accuracy DS3231 RTC & EEPROM (HCMODU0094)

Posted: Sat Jun 18, 2016 8:14 am
by seamus639
Thanks for that it solved my problem! I'm very new at this and learning fast with help from people like yourself!

Seamus

Re: High Accuracy DS3231 (HCMODU0094) remove red led

Posted: Fri Mar 03, 2017 11:59 am
by mikf650
Hi, the red led is very bright for my project, .
Is there a way to switch it off?

If not, will removing it effect the operation of the RTC??

Thanks
Mik

Re: High Accuracy DS3231 RTC & EEPROM (HCMODU0094)

Posted: Fri Mar 03, 2017 3:36 pm
by andrew
The power LED is connected across the 5V supply so I'm afraid there is no way to turn it off. The only other thing I can suggest to avoid having to desolder it is to use a permanent marker pen or tape to cover it.

If you do want to permanently disable it then you may want to consider removing the black surface mount resistor (marked 102) next to it instead as it is less delicate.

Re: High Accuracy DS3231 RTC & EEPROM (HCMODU0094)

Posted: Sun Aug 27, 2017 6:04 pm
by advocas
Hi

I was looking on Amazon for an RTC for an Arduino project, I noticed that there were a few reviews of this model with warnings about battery charging see below, is this a genuine issue?

Does this come with a CR2032(non-rechargeable battery) or LIR2032(rechargeable battery)?

Is there a charging circuit built in?

Should the charging circuit be disabled as described below?

Thanks in advance

Simon
Fine RTC for Arduino but also a ***WARNING***: The device is specified to operate in range 2.3V to 5.5V but has the design flaw that it FORCE CHARGE the CR2032 battery when in operation! Operation the device at 5v the 3v battery swollen up after a while and there is a high risk for explosion! But no matter what operation voltage a CR2032 battery shall NEVER be attempted charged! A solution is to remove the diode from the circuit or to cut the PCB trace between the diode and resistor 201 on the board. In this circuit a CR2032 battery will last forever anyway, so there is absolute no reason to try to recharge it!

Re: High Accuracy DS3231 RTC & EEPROM (HCMODU0094)

Posted: Tue Aug 29, 2017 9:16 am
by andrew
Thanks for bringing this to our attention. I've had the modules temporally taken off sale whilst we check the stock. We'll put the back on sale as soon as we confirm the correct battery (LIR2032) has been fitted. To answer your questions:
Does this come with a CR2032(non-rechargeable battery) or LIR2032(rechargeable battery)?
The module should be shipped with a rechargeable LIR2032.

Is there a charging circuit built in?
Yes it has a basic charging circuit consisting of a 200R resistor and diode that will charge the battery at about 22mA (~0.5C) when powered via a 5V supply dropping to about 1mA (~0.2C) when fully charged .

Should the charging circuit be disabled as described below?
If you are using it with a CR2032 then charging circuit should be disabled. This can be done by removing the diode or the 200 Ohm resistor. Both are located near the SCL pin.

Re: High Accuracy DS3231 RTC & EEPROM (HCMODU0094)

Posted: Thu Dec 03, 2020 12:03 am
by ILYBTodd
Do you have the mounting hole spacing available to share please?
Would like to design a mount to be 3D printed.
Todd

Re: High Accuracy DS3231 RTC & EEPROM (HCMODU0094)

Posted: Thu Dec 03, 2020 10:07 am
by andrew
Hi Todd, I've now added diagram showing the dimensions to the first post.