• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Short Review: DS3231 RTC Breakout Board

MrAl

Well-Known Member
Most Helpful Member
Hello there,

I was recently testing a real time clock (RTC) breakout board with the DS3231 chip on it, and it also has a 32k bits EEPROM chip.

So far so good, the RTC is doing less than 1 second error in 8 hours, but we'll see how it goes after a longer time period.
My temperature is fairly constant around room temperature, and 2 parts per million translates to about 1 minute per year which is about 5 seconds per month which is about 0.1752 seconds per day, so it's hard to measure over only 8 hours, but i've seen much worse than this is showing already. Because it works pretty well over 8 hours it will be more than good enough for my little dual timer project, which is intended to count days, hours, minutes, seconds over maybe a week at the longest. So the error over a week should not be more than about 1.2 seconds, but again, we'll see how this goes.
The nice thing is, it has a battery backup on board, so turning off the power does not lose time which makes experimentation very easy because the power can be shut down for days at a time, then the time can be checked at the later date and compared to a known good clock. This will make it easy to check after say a week.

I was also surprised that the library downloaded for it WORKED the first time! That's not always the case as many people know. So there was very little rework to do except maybe changing the display format a little and adding a blink LED to indicate activity even when the time is not being displayed.

I have not gotten to try the on board EEPROM though yet, which is a 32k bit unit which translates to 4096 bytes of EEPROM, 8 bits per byte. That provides for a little extra non volatile storage space.

Some good points about this breakout board:
1. 2 parts per million stability translates to about 1 minute per year, about 1.2 seconds per week.
2. Has on board EEPROM, 4096 bytes.
3. Runs on 3.3v or 5v or anything in between.
4. Has on board battery backup, rechargeable Li-ion cell which will keep time for years on a full charge due to the low current requirement during power down.
5. I2c interface which allows other I2C devices to operate off of the same two microcontroller pins, although some might prefer SPI.
6. Fairly small, the whole board is only about 0.75 inches by about 1.5 inches.

Accuracy looks good so far, but i'll post more at a later date once i have more time data.
 

MrAl

Well-Known Member
Most Helpful Member
What processor, what library?.

Incidentally, I've got some more now after the first lot came smashed to little pieces :D
Hi,

Happy to hear you got your new ones in now.

This is using just an Arduino Uno that's all, and the Arduino IDE too.
The library is what they call the "Time" library plus the "DS3231_RTC" library.
I can post if anyone wants to see it actually right here.
There are examples too, one for setting the time and one for reading the time, maybe others also.

If we can upload zip files i can upload the required files in a zip package.

One thing i did not look at yet though was the charging scheme for the Li-ion battery. It looks like it could be a simple hobby level charging circuit which i am not sure is adequate. If the battery overcharges, it gets ruined or worse. The DS1307 breakout board has a schematic that shows this, but the DS3231 board schematic is yet to be found that also shows the charging circuit.
 
Last edited:

MrAl

Well-Known Member
Most Helpful Member
Hi again,

A little more data.

First, after 12 hours i noticed a 1 second difference, running slow compared to real time. But after 21 hours it must have corrected because it's back down to zero again. I'll keep checking over time.

Nigel:
Good excuse to use one of your Nano's now :)
Up and running in about 15 minutes or so using the serial monitor of the IDE.
 

MrAl

Well-Known Member
Most Helpful Member
NEXT DAY:
A little more info...
Using the Arduino IDE, the serial monitor ("tools" menu) once started (clicked) it resets the Arduino Uno board, and with the code set up to put out 5 time samples, it resets and spits out 5 time samples that look like:
" Time = 21:07:15, Date (M/D/Y) = 1/2/2000"

Note i have not set the time and date yet, so it is whatever the chip was set at last before i got it.
I changed the code to only output 5 such lines of data, then stop, then release the serial port with Serial.end();
So shutting down the IDE and serial monitor, then starting back up at a later date and clicking "Serial Monitor" starts the process over again so i see another 5 time samples. This makes it easy to check the clock board and chip because nothing else is needed, not even an LCD display, and it does not matter if the computer/Arduino is shut down with the power off, because once started up again the Serial Monitor will force a reset and show another 5 (new) time samples. The battery backup keeps the time running normally (presumably).

As mentioned before, i think the charging circuit is made of a diode from +5v directly to the Li-ion battery. This is not an acceptable charging method so this will have to be looked into.
With a 4.2v max charge voltage and connected to +5v, if the diode drop is 0.7v then the battery might change to 4.3v or even a little above that, which is not really acceptable.
Unfortunately i cant find a schematic for this board.
This could be why other boards i see like this one do not use a rechargeable battery they use a regular alkaline and do not use the diode.
Also, if run off of a 3.3v supply (which is ok for the chips on board) the battery wont charge at all.

This will definitely have to be looked into more before using long term.

[LATER]
Measured the battery voltage to be 4.29v, while the 5v line going into the board was 4.8v so even with only 4.8v is is already beyond the point (4.2v) that we normally consider max.
Not sure what to do about this yet as the board does not look easy to modify.
One idea: pull off the diode after the battery is charged, keep the battery on board. That way it wont charge, but if it is charged then it should still last a long time if power goes down.
With the diode still connected the battery will be ruined and then when the power goes off it wont last long before it goes out totally and time keeping is lost.
This is the same as with many of the DS1307 boards with the same diode charge circuit.
 
Last edited:

SPDCHK

Member
I am using the DS3231 in my Solar water heater application. I installed my system in August. I synchronized the DS3231 with my Cell phone which in turn is synchronized with http://time.is/.
To date (4 months later) my system has gained 10 seconds
 

MrAl

Well-Known Member
Most Helpful Member
I am using the DS3231 in my Solar water heater application. I installed my system in August. I synchronized the DS3231 with my Cell phone which in turn is synchronized with http://time.is/.
To date (4 months later) my system has gained 10 seconds
Hi,

Thanks for that info. So that boils down to an error of +1 part per million, which is better than the specified 2ppm.

Did you ever check your backup battery voltage? Also, is it a rechargeable Li-ion or primary cell? (check the number on the battery)
Some of them have a primary battery type and no charge circuit diode.
The ones with the diode seem to be overcharging the battery, enough to make this an important issue to consider.

There is also no current limit on the charge current for the battery, meaning if it does drain down the current surge could be quite extensive once the board is powered up again.
 

MrAl

Well-Known Member
Most Helpful Member
Another little update...

I found that on the board itself they show a 200 ohm resistor in series with the diode, which is a *little* better but not quite there yet.

The 200 ohm SMD resistor limits the current to a nominal 10ma during normal charge, and 25ma max with a 5v supply and 0v battery. This at least helps somewhat, but to charge it correctly the voltage also has to be limited to 4.2v as per data sheet and this just isnt going to happen with a full +5v power supply which is very typical. What is more is, at 3.3v (which the chips can run at) there will not be ANY charging gonig on, so the battery never gets fully charged.

At 3.3v we'd have to charge the battery manually by disconnecting the 200 ohm from the board and connecting an external supply that is created to charge regular Li-ion batteries limited to 4.2v and say 10ma. At 5v this would not be a bad idea either so i might do that.
Rather than tap into the 200 ohm resistor by cutting a trace, the simplest method would be to just remove the 200 ohm resistor and connect a thin gauge jumper wire from the positive terminal of the battery (where the diode cathode connects) to the newly created charge circuit board, maybe with a connetor or something. That way the battery can be recharged every 2 years or something.
I also thought about installing a precision shunt regulator across the battery so if the battery voltage got above 4.200 volts it would kick in and limit the voltage to 4.2v as required, but the problem is that any circuit connected permanently like that would have to draw almost zero current when not charging because when the normal power goes down, the drain on the battery has to be extremely little to get the full time on the clcok circuit for years as it is normally. So maybe connect a sense lead to the battery with a high value series resistor, and connect the shunt part ot he other end of the diode, so that the shunt action occurs on the other end of the diode yet we still measure the battery voltage for the set point monitoring.

Of course the other simpler solution is to remove the diode, then install a normal non rechargeable CR2032 battery. That will still keep the time correct for years even after a power down and wont require any extra circuitry. Alternately, just make sure the Li-ion is fully charged, then remove the 200 ohm SMD resistor next to the diode.

I just a little while ago removed the power to the board completely, then measure the battery voltage, and it was up to 4.3 volts which is not good. That could ruin the battery and cause the backup function to fail if the power does go out. So one of the above changes is highly recommended.

Maxim makes one RTC chip that has the ability to charge a battery but i think it is made for NiMH batteries. I already have this board anyway.
 

dr pepper

Well-Known Member
Most Helpful Member
I've used a few of these now, with both drivers written in .asm on a pic, and C for the arduino, I wrote the .asm but just used a library for the 'duino.
I never heard anyone being able to read the temp registers, I just get all 0's or all 1's.
 

MrAl

Well-Known Member
Most Helpful Member
I've used a few of these now, with both drivers written in .asm on a pic, and C for the arduino, I wrote the .asm but just used a library for the 'duino.
I never heard anyone being able to read the temp registers, I just get all 0's or all 1's.
Hi,

Wow that's strange. I think people did do that though. The data sheet says registers 0x11 and 0x12 i think.
I havent tried that yet though because i didnt really need that functionality right now. Maybe in the future some time.
The base accuracy is only 3 degrees C anyway, but you might be able to calibrate that to a better accuracy. Resolution looks ok though, 0.25 degrees C which is roughly 0.5 degrees F.
 

SPDCHK

Member
Q) Did you ever check your backup battery voltage?
A) No. Cannot say that I did. I ordered them (two units in total) from China beginning of the year, and they were still in their packaging when I started with my project. In fact, the spare unit is still sealed.
Q) Also, is it a rechargeable Li-ion or primary cell? (check the number on the battery)
A) The spare unit battery does indicate that it is a "LI-ION RECHARGEABLE BATTERY LIR2030"
 

MrAl

Well-Known Member
Most Helpful Member
Hello again,

Did you check the battery voltage? It may be going too high like mine does.

Another little update:
So far so good. About 3 days now and no error in the seconds. I must have made a mistake when i saw that first error, because the error is always zero now, at least in seconds. More time will tell more.

I also found an interesting way to adjust the time if you would like to try to 'calibrate' a micro controller based time keeping circuit. For my purpose i was use the uC at first, and counting seconds, minutes, hours, and days, up to a max of 48 days. I found some error of course in the millis() function return value relative to real time, so i used a calibration factor in code to get closer to real time. That's not perfect either though, as for one thing it is not temperature compensated, even though close enough for my purpose at the time. But if you'd like to see how close yours is, you can connect one of these RTC boards to your uC chip as a temporary device, then read the RTC and compare with your uC based clock. It makes it easier to compare, and to make it visible you can display both the uC time and the RCT time and you'll see the difference right away, after maybe 12 hours or less. You can even see half second differences because the digits will change at different times if they run out of sync just a little (which they will) and this is similar to comparing the phase of two 1 second clock signals.

I still have a couple more of these RTC's to check but this first one looks pretty good so far. This is the most stable clock i've ever seen even when using the PIC chip and external crystal and calibrating the time carefully. The standard crystals do change a little over temperature and time and it shows up as several seconds sometimes. Good enough for many purposes i guess, but if you want a clock that runs a full year without too much error then you need temperature compensation. Either a RTC or try building your own using a small temperature controlled oven. The inside oven temperature only has to stay above ambient at all times, so maybe 120 degrees F or something like that assuming you are using it indoors. Any calibration should hold better after that, except for the aging, which you'd have to figure out a compensation technique for like some of the RTC's have. I would not mind setting mine once per year though so i probably would not need the aging compensation.
 

Nigel Goodwin

Super Moderator
Most Helpful Member
This is the most stable clock i've ever seen even when using the PIC chip and external crystal and calibrating the time carefully.
It's better if you use a 32KHz crystal on TMR1 if you want a fairly accurate clock, as those crystals are less temperature sensitive - and of course it will run while the PIC is in sleep mode.

Obviously not going to be as good as a real RTC though - but the component count is nice and low :D
 

dr pepper

Well-Known Member
Most Helpful Member
I have a time clock on my desk here made from aircraft instruments, the timekeeper is a pic with a 32kc xtal attached to timer 1, I set it back in June and its only a few seconds out.
Roman black's site shows you how to male a crystal oven for this, then you can make a super accurate clock for a few pence.
 

MrAl

Well-Known Member
Most Helpful Member
Hi again,

Dr Pepper:
Sounds good, i'll take a look.

Nigel:
Also sounds good. Did you try one of your Nano's yet?
 

MrAl

Well-Known Member
Most Helpful Member

dr pepper

Well-Known Member
Most Helpful Member
Yup, of course thats ok as long as you have the overhead.
Piece of cake with a 'duino as there is a pid function available, there might even be an xtal oven library knocking about too.
 

Latest threads

EE World Online Articles

Loading

 
Top