I see alot of info about adding RTC to Arduino projects. 1.) They appear to just be one line comments. 2.) I see alot of modules like 1307 and DS3231, but most of these write-ups are almost 10 years old or older.
Can someone point me to the latest and greatest RTC module w/library and where to get it so that I get a good version ?
I buy em 2 at a time from Walmart for $8 per two pack. No battery. They work great. Add battery, connect, up and running on the first try
const int kCePin = 26; // Chip Enable - grn
const int kIoPin = 27; // Input/Output - yel
const int kSclkPin = 28; // Serial Clock - orn
#include <DS1302.h> // RTC library
//
// Create a DS1302 RTC object.
//
DS1302 rtc(kCePin, kIoPin, kSclkPin);
// Somewhere in setup()
//
// Fire up RTC
//
rtc.writeProtect(false); //Gotta unlock before letting it run
rtc.halt(false); //Let clock run
Time t = rtc.time(); // Device data type - read RTC
//
// Somewhere in loop()
//
//
Time t = rtc.time(); // Poll clock
//
// This creates t.hr, t.min, t.sec etc.
//
// In the clockSet() function:
//
//
setRTC(clockYr, clockMon, clockDt, clockHr, clockMin, clockDoW);
//
This is extracted from a running module. The only things you should have to change is the pin assignments.
Sorry. I saw RTC and I've got a bunch working on that device. Never had an issue.
What is the major difference between the two? I mean, it keeps time, what else should it do?
Main difference is the DS3231 has an internal oscillator, and can also compensate for changes in temperature. It is therefore a lot more accurate than the earleirs versions. It also includes 2 built in alarms, as mentioned above.
Old devices have the advantage of a known track record and volume pricing. LOL (speaking as a rather old device myself!)
I like increased accuracy. I phased out DHT-11's for -22's and added BME280s for better accuracy. For an indoor app tho, temp stability is not normally an issue in an environment that only ever changes a degree or two (ain't central air wonderful?) But I like the alarms and better accuracy/stability never hurts in a clock.
Are there multiple versions of the "DS3231" ?
One that has the ability to recharge its battery and one that does not ?
If I purchase a version that does not recharge its battery, what is the life expectancy of the battery ?
We very rarely have power-outage events, does that make a difference on life expectancy ?
Yeah, the battery is probably only intended for use when project looses power, but that's just what the documentation states. I want to know what the project builders are experiencing.
There are multiple board versions that use the same IC. The most common is the one shown in reply #6, the ZS-042. It's designed for a rechargeable lithium battery, but a non-rechargeable one will last over ten years, probably about equal to the shelf life of the rechargeable one. It's not safe to use the board with a non-rechargeable battery, so you need to modify it by removing the resistor adjacent to the cylindrical orange diode on the board, to disable the charging circuit. You can use the board safely with no mods, if you run it on 3.3V instead of 5V. But that is only reasonable when the I2C bus is also using 3.3V.
If you look at the standby current of the IC, and compare with the capacity of a 2032 battery, you will see by simple math that the non-rechargeable battery life is not an issue.
Other boards do exist, that don't have this confusing issue. I have some, they work fine and there is no difference in software, no difference in the I2C connection. They just cost a little bit more.
It would be a very sorry hobby if we had to depend on anecdotal reports to know how the hardware performs. Do you really think that a multinational semiconductor fab would lie to its customers, over such a crucial specification? In what kind of world would the advice of random strangers on an internet forum be considered more reliable?
Would a design engineer sit down and think, "hmmm. I guess it really doesn't matter much if the battery is draining while the device is powered on... ah who will notice anyway!" Come on.