SwitchDoc Labs DS3231 Real Time Clock Module / EEPROM for Arduino and Raspberry Pi
Comments are now closed. Please go to the Product Support Forum at the top of the page.
[include-page id=”buy-include-file”]
What is in this product?
The SwitchDoc Labs DS3231 Real Time Clock Module contains two devices, both
connected to a 3.3V or 5.0V I2C bus. It contains a Maxim DS3231 high accuracy temperature compensated Real Time Clock and an AT24C32 32Kbit EEPROM organized as 4096 8 bit words of non-volatile storage. According to tests done at SwitchDoc Labs (seen below), the DS3231 is the clear winner with a measured accuracy of less than 0.3PPM (Parts Per Million) or in other words, losing or gaining less than 0.026 seconds per day.
The software supports both the DS3231 timekeeping functions, the internal temperature sensor of the DS3231 and the AT24C32 EEPROM device.
I2C address 0x68 is the DS3231 and 0x56 is the AT24C32. Note that on some of the new revision boards the AT24C32 address is 0x57.
The SwitchDoc Labs python based software for the Raspberry Pi product is located here.
The Arduino based software is located here.
You can buy the SwitchDoc Labs DS3231 Module on the SwitchDoc Labs Store.
Benchmark Results
SwitchDoc Labs has run months of performance and validation tests on this DS3231 Module and compared it to other Real Time Clocks. We selected the DS3231 because of it’s superior accuracy. We are measuring the results in PPM (Parts Per Million). For example, losing 1 second per day is a drift of 11.5 PPM while 1 PPM is a drift of 0.0864 seconds per day. The PPM (Parts Per Million) measured error is shown on the graph below:
The DS3231 is the clear winner. The jagged lines are on the graph because we are only able to detect integer second errors because all three real time clocks only show seconds. The Raspberry Pi has better resolution, but we round it off in order to do reasonable comparisons with the RTC data. Here is the summary data in table form:
The table of results is below:
Device | Test Length (Seconds) | Measured PPM | Specification PPM |
DS1307 | 292,869 | 15 PPM | 23 PPM |
DS3231 | 3,432,851 | < 0.3 PPM | 2 PPM |
PCF8563 | 3,432,851 | 24 PPM | 29 PPM |
MCP79400 | 3,432,851 | 4 PPM | Not given directly |
Additional results for other Real Time Clocks are benchmarked here and in the definitive article in Raspberry Pi Geek Magazine Issue 7 and 8.
Raspberry Pi Verification
After you hook up your SwitchDoc Labs DS3231 Module to the Raspberry Pi (3.3V, GND, SCL, SDA), run the following command:
pi@MouseAir2 ~/RTCEval/SDL_DS3231 $ sudo i2cdetect -y 1
The results should be similar to this. 0x68 is the DS3231 and 0x56 is the AT24C32. Note that on some of the new revision boards the AT24C32 address is 0x57.
0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- 56 -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- --
After downloading the drivers from github, run this command:
pi@MouseAir2 ~/RTCEval/SDL_DS3231 $ sudo python testSDL_DS3231.py
pi@MouseAir2 ~/RTCEval/SDL_DS3231 $ sudo python test*.py
Test SDL_DS3231 Version 1.0 - SwitchDoc Labs Program Started at:2014-12-21 02:01:23 ----------------- ----------------- Test the AT24C32 EEPROM ----------------- writing first 10 addresses with random data address = 0 writing value=41 address = 1 writing value=249 address = 2 writing value=198 address = 3 writing value=238 address = 4 writing value=190 address = 5 writing value=101 address = 6 writing value=171 address = 7 writing value=62 address = 8 writing value=255 address = 9 writing value=169 ----------------- reading first 10 addresses address = 0 value = 41 address = 1 value = 249 address = 2 value = 198 address = 3 value = 238 address = 4 value = 190 address = 5 value = 101 address = 6 value = 171 address = 7 value = 62 address = 8 value = 255 address = 9 value = 169 ----------------- ----------------- Raspberry Pi= 2014-12-21 02:01:25 DS3231= 2014-12-21 02:01:25 DS3231 Temp= 21.75 Raspberry Pi= 2014-12-21 02:01:35 DS3231= 2014-12-21 02:01:35 DS3231 Temp= 21.75 Raspberry Pi= 2014-12-21 02:01:45 DS3231= 2014-12-21 02:01:45 DS3231 Temp= 21.75
Why use a Real Time Clock?
A realtime clock is necessary for any project requiring accurate time keeping especially when you don’t always have an Internet connection. The Arduino only has a software based time clock for time keeping. If it powers off, it is gone. A Raspberry Pi being sent up in a balloon or a Pi working in the remote caribbean, like Project Curacao. The Raspberry Pi keeps pretty good time, but only if it is connected to the Internet. The Pi uses an Internet service called NTP to set the clock on power up if the Internet is available. It then calls the NTP servers (some are actually hosted by the National Institute of Standards and Technology (NIST) and linked to their atomic clocks). You aren’t going to get atomic clock accuracy using NTP, but it is pretty good.
It dosen’t work under python3.
Here is an error:
Test SDL_DS3231 Version 1.0 – SwitchDoc Labs
Program Started at:2015-07-15 08:44:07
—————–
—————–
Test the AT24C32 EEPROM
—————–
writing first 10 addresses with random data
address = 0 writing value=61
Traceback (most recent call last):
File “testSDL_DS3231.py”, line 46, in
ds3231.write_AT24C32_byte(x, value)
File “/home/pi/ds3231/ds3231/SDL_DS3231.py”, line 211, in write_AT24C32_byte
self._bus.write_i2c_block_data(self._at24c32_addr,a1,[a0, value])
TypeError: integer argument expected, got float
The software is not Python 3 compliant. If you do a port to Python 3, please let us know and we will post it!
SDL
I took a look at the problem on your page. What version of the Arduino IDE are you using? Is this a problem with the 1.6 version? I’ve seen other issues. We are still using 1.5.
The error looks like a compiler problem and not a board or device problem.
Note that the device should still work with VDD at 3.3V. What are your pull-ups connected to on the I2C bus?