Is it possible to count working hours of Arduino UNO (and displaying them on LCD) without reseting that value after power of?
Have in mind that machine using this Arduino would have to work for years and count time very precisely (I'm saying that because I know about EEPROM.write).
Any way to do that without SD card?
I already have MCP79410 RTC but I don't need it to be precise in few seconds; I thought of saving time periodically to EEPROM (every 10-15 minutes) but if machine is turned of before value is stored I would lose that few minutes. That is too much, but few seconds a day is not a problem.
One solution would be to use a large capacitor to keep the Arduino running when the power is removed. By monitoring the power pin, you can tell when power is lost, before the Arduino gives up the ghost. When that happens, store the time in EEPROM.
The Arduino clock is not precise enough to count to second's precision over several years. You will not get away without an RTC. Even a crystal-based RTC is not THAT precise IIRC. Some RTCs have a battery-buffered RAM where you can store you data
Great idea, thank you. I will have to measure time needed to store working hours to EEPROM to see exactly how large capacitor will I need but this seems great.
Thanks once again, UKHeliBob thank you too.
olf2012 Of course over a few years this won't be precise enough to count to second's precision but it doesn't have to, mistake of max.5min a day is ok...
Even the DS1307 RTC has 56 bytes of battery-backed SRAM.
Even if you double-buffered it and stored a 32 bit CRC/checksum for each buffer, you'd have enough storage to store billions of years-worth of on-time. (though I suspect the battery would give out long before that).
Edit: Thinking about it, you could also have a pretty good idea of the total time the device has been switched off.