Real time clocks

There seem to be a very large number of real time clocks. I have seen SD3031, DS3231, DS1307 etc. I have tried out one which is supposed to be a DS1307 and received from e-bay. It is not marked DS1307. It has RTC v1.1 and has a white label which reads 'open-smart'. It has a 3.3v button cell.
I used the Arduino example' DS1307 RTC set time ' to try to program it. Then I tried to read the time with the Arduino example 'read time from ds1307'. I got the reply unable to sync with rtc. The compile worked ok for the set time part and read time part.
Can anybody tell me on this forum what would be the best RTC to use with Arduino and where would I get it? I may have damaged the one I tried by first using 5v. When I saw that it had a 3.3v button cell I started using that voltage from my nano board.

The DS3231 has a good reputation

2 Likes
  • The DS3231 has proven to be excellent in projects designed here.
    I get them from stores on eBay and AliExpress or from Amazon, should be less than $5.00

  • Have made over 12 LED clocks using the DS3231, almost all are within ± 5 seconds per month.

  • Do not recommend the DS1307 at all.

2 Likes

If you are using the following DS1307 Breakout Board (Fig-1), then it is 5V compatible. The 3.3V Battry Cell is to preserve the data of the time registers of the MCU. (DS3231 is operateable in both 5V and 3.3V options.)
ds1307RTC Module
Figurre-1:

The DS3231 is very much superior to the DS1307. It has an alarm output that can be triggered by either of two alarm settings. The DS1307 has no alarm. I suspect most of the RTCs you get online are counterfeit, but they still seem to work ok for the most part.

The DS3231SN is more accurate than the DS3231M, but both are pretty good. The typical module is the ZS-042 module which comes with an EEPROM chip and a CR2032 coin cell holder. But it requires some modifications before use. The circular-shaped modules have no extras, and may be more likely to have the SN part, but the coin cell holder is for a smaller battery which won't last as long.

I try to get mine from Alice1101983, either on Ebay or Aliexpress, but there may be other good sources.

My latest clock is using an ESP32-C3 SuperMini (the size of a thumb nail).
A few lines of code makes it always accurate within a second or two.
And it has automatic daylight savings.
Leo..

  • Yes, I have mostly converted to ESP around the house, however, adds some complexity when making gifts for others :pleading_face: .

I usually add a WiFi portal to my code (WiFiManager),
so I (or others) can easily change the WiFi credentials or other data.
Leo..

1 Like

On the ESP parts, if you can use the WiFi, you can use the built in NTP code code along with the built in unix time library functions and you don't even need an RTC to have accurate time including local time DST adjustments.

--- bill

Minimal sketch to get time off the net with an ESP32 for a random location (Montreal).
In my clock I have added some extra features, like waiting for a sync before displaying the time, turning WiFi off between updates, reduce them to only twice a day, and solar angle calculation for dimming.
Leo..

#include <WiFi.h> // ESP32
unsigned long prevTime;
time_t now; // epoch
tm tm; // time struct

void setup() {
  Serial.begin(115200);
  WiFi.begin("SSID", "PW");
  configTzTime("EST5EDT,M3.2.0,M11.1.0", "pool.ntp.org"); // https://github.com nayarsystems/posix_tz_db/blob/master/zones.csv
}

void loop() {
  time(&now);
  localtime_r(&now, &tm);
  if (now != prevTime) {
    prevTime = now;
    printf("\n%02u:%02u:%02u", tm.tm_hour, tm.tm_min, tm.tm_sec);
  }
}

Edit: environmental string reduced to a single line

1 Like

Hi Sherman, That may be the problem with the zs-042 module requiring modifications. If I don't know what the modifications are I wont be able to use it. I would prefer something that didn't have to be modified before using it.

The modifications are simple. The module has a "charging" circuit for the battery. But the CR2032 you would be using is a primary cell, and shouldn't be recharged. So to disable the charging circuit, you remove a resistor, or you can just cut one trace.

The second mod is because the module has a power indicator LED which wastes several milliamps for no good reason. So again, you remove a resistor or cut a trace.

If you decide to use this module, I can post pictures of the resistors and traces.

The advantage of the ZS-042, even if you don't need the EEPROM, is its use of the CR2032 holder. That cell has four times the capacity of the smaller CR1220 used in many other modules.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.