So i got a bunch of these RTC module for cheap from china. Ive used sparkfun modules before without issue, but ive been having some inconsistencies using these cheap modules.
I could upload a time to the DS1307 and connect via I2C to the module (using RTClib library); however, the module would either not report back a time or it would report back the same time from the last power down. My first though was that the battery was dead, but no its fine. After figuratively banging my head against the wall for a few hours, I realized that the oscillator crystal was loose from its solder pad.
Upon grounding the case of the oscillator with a jumper wire,
time was stored and progressed as would be expected of an RTC. Im no electronics expert, but I thought that grounding the case of an oscillator was not required. I thought it was just a good idea? Why would this cause the RTC to not march forward in time when 5v power is lost?
There are many problems with cheap RTC modules. This one can be added to the list.
Because it is battery operated, the power usage is extremely small. So everything is high impedance. Perhaps that has to do with the grounding of the case of the crystal.
So I soldered down the RTC's crystal thinking that would fix my problem... but no, the problem still persists. Instead of having to ground the case of the crystal to get the RTC to act properly, I now have to tap ground to the positive side of the RTC's watch battery. After this the RTC reports the correct time.
Im guessing this effects some sort of reset allowing the RTC to communicate via I2C? Any thoughts?
-one wont keep time at all when 5v is detached so it seems that crystal may be bad.
-two will keep time but wont transmit it until i do the battery ground thing.
MY SHORTCUT SOLUTION:
So as a quick fix i'm powering the clock off of one of the digital ports and in the setup function i cycle it from ground to power before using the clock. This seems to work with several modules and after over 10 minutes of disconnect time.
#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 RTC;
void setup () {
// Here is where i cycle the clock's power
pinMode(4,OUTPUT);
digitalWrite(4,LOW);
delay(10);
digitalWrite(4,HIGH);
delay(10);
// Everything else is from RTClib example
Serial.begin(57600);
Wire.begin();
RTC.begin();;
//RTC.adjust(DateTime(__DATE__, __TIME__));
if (! RTC.isrunning()) {
Serial.println("RTC is NOT running!");
}
}
void loop () {
DateTime now = RTC.now();
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(' ');
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
delay(1000);
}
Erdin:
Three out of three bad ?
We should never buy those anymore.
Was the Sparkfun RTC also a DS1307 ?
If the battery is good, and the pcb is good (no shortcuts, no bad soldering) it is probably the crystal that causes all the problems.
I wouldn't say they're all "bad", just that something is going on that the existing libraries don't address. I tested five more modules this morning and all but one was fixed by using my ground then power piece of code. Upon further inspection, i had forgotten fix the unsoldered-down the crystal on the fifth one that didn't work after applying my code.
SO IN CONCLUSION:
To make these cheap RTCs work: (1) make sure the case of the crystal is soldered to ground, and (2) momentarily ground the Vcc pin of the RTC before applying 5v. I dont know why these things work, but they do, and both are required in the ones i bought.
jonwwwo, have you made any further progress with these things?
I have exactly the same issue (clock remembers only time at last power down, but increments it correctly from there) and it isn't fixed by either soldering down the xtal case or by your power cycling. The coin cell in the device seems good.
I am on the verge of committing to 100 RTC units of some kind or another, and it would be a big saving if these cheap boards can actually be used. So your latest conclusion would be really helpful!
snusmumriken:
jonwwwo, have you made any further progress with these things?
I have exactly the same issue (clock remembers only time at last power down, but increments it correctly from there) and it isn't fixed by either soldering down the xtal case or by your power cycling. The coin cell in the device seems good.
I am on the verge of committing to 100 RTC units of some kind or another, and it would be a big saving if these cheap boards can actually be used. So your latest conclusion would be really helpful!
Yeah, in the end, my solutions only worked for some of the modules... In my opinion, these modules are crap and not worth your time. If i were to do this project again but still needed to save money id try something like these:
They are simpler, no memory module, and may not have the same issues. But let me reiterate, ive never used these so i dont know if they work any better.
Thanks for that update. I looked at those 1302 modules too, but I am already using serial for a sensor, so I needed an I2C clock - and there's the same anxiety about quality, as you suggest. I reckon I'll have to splash out on the Sparkfun clock.
I've also encountered some problems with the "Tiny RTC I2C modules" from ebay.
In the german forums there is a thread about perhaps the battery type beeing a problem. Does the module you have use a LIR2032 (a rechargable battery unlike CR2032)? Because then it has a charing circuit and the LIR batteries also have a higher voltage. So the DS1307 might think the VCC voltage to be too low and thus doesn't function correctly.
I've never seen a DS1307 design where the crystal case was soldered to ground. I've probably got a dozen of them around, at least three different designs, plus I've breadboarded them with success. I wouldn't think the heat from soldering would do those crystals any good.
Well, Sparkfun seem to think it's a good idea to anchor the xtal case to a solder pad - see attached photo. Their module simply works.
JamesT42:
In the german forums there is a thread about perhaps the battery type beeing a problem. Does the module you have use a LIR2032 (a rechargable battery unlike CR2032)? Because then it has a charing circuit and the LIR batteries also have a higher voltage. So the DS1307 might think the VCC voltage to be too low and thus doesn't function correctly.
Interesting idea, but the measured voltage from the lithium 'Eunicell' CR2032 cell supplied in my Tiny RTC is 3.42V. It increments time nicely provided it is hooked up to VCC - it just doesn't appear to remember the set time while it is running on its own battery. I don't know what the 'BAT' terminal is intended for, so I don't know the significance of this, but the voltage measured there is only 1.8V.
re the crystal.. Soldering them to ground is a common practice for several reasons, one is mechanical .. Vibration can affect the frequency and the second is temperature variations, the third and most important is that soldering fixes the loading capacitors, movement of the crystal can change the operating frequency. I have a handful of devices with 32 KHz crystals.. All soldered..
Seiko had an app note on it from back in the 80's and is still present on some of the early clock chips data sheets... The above materials are all I can remember... It was a long time ago.
[quote author=Jack Christensen link=topic=177297.msg1396731#msg1396731 date=1379534363]
I've never seen a DS1307 design where the crystal case was soldered to ground. I've probably got a dozen of them around, at least three different designs, plus I've breadboarded them with success. I wouldn't think the heat from soldering would do those crystals any good.
Well, Sparkfun seem to think it's a good idea to anchor the xtal case to a solder pad - see attached photo. Their module simply works.
[/quote]
Well that makes one. Here is the datasheet for a crystal that I use, it specifically warns against soldering the case. The part number for Sparkfun's crystal isn't on the schematic, but I suppose it's possible that soldering is OK for a different part.
I have used glue to mitigate movement and vibration.
As a newbie, I'm having to learn all this from a zero knowledge base. I note in various datasheets that they refer to a 'local ground plane' in the vicinity of the xtal. So is the large blob of solder under the xtal acting as that ground plane? In which case, why would anyone solder (rather than glue) the case to it?
I can't help thinking (again from my position of ignorance) that this is a red herring from the OP's problem. If the xtal was faulty or incorrectly located, the clock wouldn't update at all surely? The problem is that once VCC power is lost the clock seems to forget to update until you reconnect (or at least won't report the correct time).
In my point of view there is one design problem in this module !
If you see the DS1307´s data sheet, you can find that battery voltage must be upper than 2.0V .
I dont know why this circuit have a voltage divider by resistors R6 and R4.
I will think about one solution for this problem.
snusmumriken:
I note in various datasheets that they refer to a 'local ground plane' in the vicinity of the xtal. So is the large blob of solder under the xtal acting as that ground plane? In which case, why would anyone solder (rather than glue) the case to it?
I suppose that the solder is part of the ground plane, but more commonly, the ground plane is just the copper on the circuit board. From reading the datasheets, the manufacturers seem to think that is sufficient.
I can't help thinking (again from my position of ignorance) that this is a red herring from the OP's problem. If the xtal was faulty or incorrectly located, the clock wouldn't update at all surely? The problem is that once VCC power is lost the clock seems to forget to update until you reconnect (or at least won't report the correct time).
Could be. I haven't seen this behavior and I don't have a theory. There is a "clock halt" bit in the seconds register (0x00) but I see no reason to think it's being manipulated.
Gustavo_Murta:
I dont know why this circuit have a voltage divider by resistors R6 and R4.