I recently purchased some I2C RTC modules for an Arduino-based project. The specific model was the XCSOURCE version available on Amazon. These modules are based on the DS1307 8 pin IC and worked fine for the project since they can:
Store the time set by the SetTime example (from this library:
https://github.com/PaulStoffregen/DS1307RTC)
Return the time with the ReadTest example (from the same library as
above).
Provide the real
time clock date and time for my project and retain the time when the
power is lost (running in low power mode from the battery). There is
some drift, the clock may lose or gain a few seconds, but this is
acceptable for my application since I only read the time from the
RTC when the Arduino boots.
If I wanted a more precise timekeeper, I would probably purchase something like the Adafruit DS3231 Precision RTC Breakout board i.e. one which has a temperature sensor to help compensate for frequency changes in the crystal.
There are however some important points to note about these modules:
The supplied battery is NOT rechargeable.
Most cheap lithium coin cells are not specifically rechargeable. The
manufacturer supplied a battery like this:
It says CR2032. A real rechargeable battery in this form factor would be labelled LIR2032
and state 'rechargeable' on the back, as shown below.
A simple voltage divider (R6 and R4) is used to keep the VBAT value below the *maximum required by the DS1307 (3.50V). This is because a rechargeable lithium battery voltage will typically be around 3.70V and may exceed 4.00V (see below). *The DS1307 compares VCC with VBAT and if VBAT is too high, it will think VCC is too low and stay in it's disabled state.
The problem here is that if you read VBAT in your project, you will need to convert the reduced value into the real battery voltage (VBAT will be lower).
Also it is worth noting that
if you try reading VBAT by connecting it to an Arduino input pin
(for example), the battery will be more rapidly discharged,
especially when the power is off.
The charging circuit is very simple / basic via R5 (200 ohms) and D1.
This means that the charging voltage is typically too high for a LIR2032 (assuming VCC is from a 5V USB power supply, for example).
Only 0.09V is dropped across D1, so assuming VCC is 5.00V, the charging voltage would be 4.91V! The data sheet above for the LIR2032 recommends a charging voltage of 4.20V.
There are 2 principal / obvious suggestions to resolve the main battery concerns:
If you are happy to use the supplied NON rechargeable battery and
accept that it will eventually run down and need replacing in
(probably) a few years time you should disable the charging circuit.
The easiest way to do that is to remove (de-solder) D1 (or R5) from
the module's PCB.
The module seem okay "off the shelf", but it is essentially attempting to recharge
non-rechargeable batteries and this may damage the CR2032 and reduce
its lifespan.
If you want to replace the supplied battery and use a rechargeable LIR2032 battery instead, you should reduce the battery charging voltage.
Overcharging a lithium battery can damage it and maybe even cause it to go pop.
There are several ways to reduce
the charging voltage, but I found the simplest / easiest way was to
place one or more diodes between the supply voltage and VCC on the
module:
This is the easiest way I have found because it is
convenient, cheap (using easy to locate components) and does not
require any soldering work etc on the module itself.
The
diodes reduce the voltage before it reaches VCC on the module board.
This in turn means the floating voltage on the battery is reduced to
a more suitable level. It can be fine-tuned by selecting one or more
diodes with different voltage drops.
The power supply I am
using is quite "beefy" and with a low load (a simple
Arduino project) the USB +5V rated supply actually provides 5.22V.
This means I needed to use a silicon diode (IN4007) and germanium
diode in series to reduce VCC to 4.26V, and the charging voltage on
the battery to float at 4.17 (just below the 4.20 recommended
value).
The RTC module seems to be quite happy operating on 4.26V
instead of the quoted 5.00V.
Actual | Theoretical | |
Original VCC | 5.22 | 5.00 |
Drop across silicon diode | 0.65 | 0.65 |
Drop across germanium diode | 0.31 | 0.31 |
New VCC | 4.26 | 4.04 |
Voltage at battery contact | 4.17 | 3.95 |
Diagram showing how the supply voltage is reduced with diodes:
I recommend using a multimeter to fine tune the new VCC. You will need
to select one or more diodes depending on the power supply you are
using etc.
You may find a single silicon diode
is sufficient to bring the new VCC to 4.29V or below (assuming 0.09
is dropped across D1), if your power supply is producing 4.94V or
less.
NOTE: When selecting diodes, you should remove the
battery and connect the positive multimeter probe to the positive
battery contact on the RTC module. Then try different diode
combinations until the voltage falls to 4.20V or below.
Photo
showing the silicon and germanium diode connected in series between
the positive supply voltage and VCC on the RTC module (a rechargeable
LIR2032 battery is fitted):
The new VCC voltage
(with a silicon and germanium diode in series), as shown on a
multimeter.
The voltage supplied to the battery is actually 4.17V in
this example (since a further 0.09V is dropped with D1 on the module):
http://woodsgood.ca/projects/2014/10/21/the-right-rtc-battery/ - thanks to Adrian who suggests the use of a silicon diode to reduce the supply voltage.
https://forum.43oh.com/topic/4131-ds1307-rtc-eeprom-from-ebay-possible-unreliable-operation/ - more details on disabling the charge circuitry etc.
https://batteryuniversity.com/learn/article/charging_lithium_ion_batteries - more on how lithium ion batteries should be charged.