DS3231 RTC Board Without a Battery

Is it OK to use a DS3231 board without a battery? I am a newbie just starting out with Arduino, and need accurate fairly long term timing for my Nano stepper motor project. I don't need the date or time, just the accurate 32kHz from the DS3231 to generate interrupts.

I have read lots of discussion about disabling the charging circuit if you are using a CR2032, but can't find any reference to eliminating the battery. Reading the DS3231 docs, I see: "If VBAT is not used, connect to ground," but presumably that would not apply here because the board charges the battery.

I presume that I can simply not put a battery in the holder, and still make use of the 32kHz signal to drive an interrupt pin on the Nano. Do you see any issues with this plan?

I believe that the RTC will work just fine without the battery. Off the top of my head, I think you will need to re-enable the RTC oscillator at power on.

That would be taken care if if you keep the time/date init code in setup and simply preset an arbitrary time/date.

Is there a specific need for a 32 kHz interrupt? That would be an interrupt every 31.25uS.

1 Like

Short answer
It is OK.

But do you really need the RTC? As @markd833 already pointed out, if your application needs just an approx 32kHz interrupt (and not 32.768kHz), that could be achieved with an internal timer of the MCU.

Long answer
If you look at schematic of DS3231 module, you'll see that the VBAT pin will be still powered through the series resistor+diode from Vcc, so do not connect it to GND or you will have a constant ~20mA current draw from Vcc (unless you remove the resistor or the diode)

However you should check whether DS3231SN or DS3231M chip is equipped on your module and keep in mind the followings:

DS3231SN:

Although the 32 kHz output will be continuous (i.e., it won’t skip or add extra pulses), the frequency output is only corrected for temperature variations every 64 seconds and so may drift a bit during that time. When the temperature conversion and correction happens, there may be a sharp, distinct change in frequency.

DS3231M:

The 32 kHz output of the DS3231M is not temperature compensated, while the 1 Hz INT#/SQW output is. The 1 Hz signal has a specified stability of 5 ppm, but the 32 kHz signal can vary by up to +/- 2.5%. Yikes.

it is sooo easy and quick to try yourself

1 Like

The stepper drives a "star tracker" for astrophotography, so long term accuracy matters. When I used the Nano's millis() function, the tracking was clearly off -- on long exposures (several minutes with a telephoto lens), stars became streaks.

OMG, am I glad I asked this question! Yes, I can skip the battery, but now I know I can't rely on the 32kHz signal. Since my DS3231's have no markings, I don't know the type, so I will use the 1Hz signal to adjust my millis() readings once per second. As I understand, the 1Hz signal should be correct across types.

Thank you, thank you, thank you!

Why use millis() at all when you have an accurate 1Hz square wave?

But, why?

now I know I can't rely on the 32kHz signal

Not sure why. The 32kHz output is enabled at power up by default on the DS3231. The I2C doesn't even need to be connected.

For that kind of accuracy you don't need any RTC. The reason is probably the inaccuracy of the ceramic resonator that clocks the Uno (what Arduino do you have?). If you use an Arduino that uses a quartz crystal oscillator or crystal instead, you don't need any auxiliary time source, those are accurate to at least 30ppm.

You probably have counterfeits, and may not be able to rely on their accuracy.

Accurate, crystal controlled oscillators with guaranteed performance and an extremely wide range of frequencies can be purchased cheaply from any major electronics parts supplier. They can be purchased in "cans" with pins that fit on a breadboard or can be soldered into a circuit.

Examples: https://www.digikey.com/en/products/filter/oscillators/172

Does your nano use a crystal or a resonator for its main clock source? If I recall correctly, the official Arduino Nano uses a 16MHz crystal. A crystal will generally give you around +/- 10..20 ppm but a resonator is likely to be around +/- 5000 ppm.

EDIT: I was too slow typing and the above has just been covered!

You recall incorrectly.

1 Like

Is the DS3231's output 32kHz or 32.768 kHz?

DS3231 --> 32.768 kHz
DS3231M --> 32.768 kHz +/-2.5%

It should be 32.768kHz on pin 1 - same for both the DS3231M and the DS3231S(N).

The stepper motor runs at a bit over 90 steps per second, so 1Hz isn’t fast enough.

================

Re: No battery -- I only need to know precisely how long the device has been running, don't need date or time. Plus there are potential issues with the charging circuit.

Re: Can't rely on 32kHz -- see @amazed's answer regarding DS3231SN vs DS3231M. The DS3231M's 32kHz is not reliable, and don't know what I have.

================

Ouch -- you may be correct. If so, as long as its timing is consistent I can account for it. Otherwise I need to substitute.

================

Thank you all. This is a great resource for a newbie.

I didn't say anything like the DS3231M 32kHz output is not reliable, I said that it's not that accurate.
Based on the datasheet, it can vary between 31.948 and 33.587 kHz, but it should be precise.
The DS3231S(N) 32kHz should be accurate AND precise.

These photos will be taken in different months of the year, and the temperature can vary during the year, right? (I guess you go outside at night). So you will need some kind of calibration before every photo session.

You could also do some research, how successful "star-trackers" work. I'm sure that there are available examples for such project.

If you are star tracking (or is it star treking - no, that's the song!!) then I assume that you would be outdoors. Have you thought about one of the GPS receiver modules that you can use to get time from?

EDIT: Look for a module with a 1 PPS (pulse per second) output.

My star tracker is a very simple device that just rotates 1 RPSD -- Revolution Per Sidereal Day. It is commonly called a "barn door star tracker." See photo. It is not a computerized "Goto" mount that automatically locates stars and such. That needs a LOT more logic.

It is just 2 pieces of wood connected by a hinge. You point the hinge axis at true north (close to Polaris), and the stepper turns a nut which drives the threaded rod at a very precise (and hopefully accurate!) rate. This keeps the camera pointed at the same location in the sky for very long exposures, accounting for the rotation of the earth. Since all it cares about the stepper turning the nut to move the rod to rotate the camera mount once per day, it does not need to know the current time or date.

Regarding the timing, consistency is critical. Even if it off spec, as long as it is always consistent across temperature changes, I can adjust the stepper speed very precisely; my spreadsheet calcs indicate it should step at 90.27756054 steps/sec, give or take a few ppm :-).

Thanks again!

I'm not convinced that you need anything more elaborate than an MCU with a decent crystal oscillator as a CPU clock source. Those are the norm, the resonator driven boards are not so common. As I said before, crystals are typically within 30ppm. Then it's all software.

If you doubt it, do some calculations.

The 30ppm is mainly a fixed error than can be calibrated in software to produce a much smaller final error.

There is likely much more "play" in your mechanical linkage than that.

That sounds like a task for timer 1 and its compare registers. You can configure the timer to toggle an output pin each time a specific count is reached. That would generate a continuous square wave (i.e. step rate) using the hardware without any further software involvement.

The key to accurate timing is to have a decent clock source as @anon57585045 has pointed out.