4 ms·
Arduino count to the next Friday
- Crosseye_Jack 10y agoQuick read through at midnight because kitty won't let me sleep. So please forgive anything I've overlooked. Also this isn't criticism just some feed back. The DS1307 is great to start with but I would replace it with something like the ds3231(which is what you will find on eBay, just as a note with the common modules on eBay. You can remove the resistor that's on the simple battery charger and the resistors on the i2c lines if you use plan to use the internal pull-ups on the atmel) or the DS3232/4. The 3231/2/4 come with intergrated crystals and preform temp calibration and are generally much more accurate. The 3232/4 allow you to configure then that temp calibration happens furthering battery life (guess that's what your trying to achieve when you bring up about lowering power usage and making the CPU sleep). The 3234 is the SPI version as your using SPI for the led driver might as well shift the RTC to the SPI bus too and power down the i2c bus completely or shift the led driver over to the i2c bus. Another trick you can do is power the RTC from one of the micro pins, connect the RTC to power the interrupt from the RTC battery. That way you can cut the power to the RTC, wait for the interrupt. Decide if your going to read the time from the RTC, power up the RTC, Read the time. Kill the power to the RTC again. Note: This will reset a few things that will need to reconfigured with the RTC. But it will still tick. Maxim have a very nice sample policy and they have sent me parts to my home address using my personal email (though not a free email provider). They did deny me once but I was being cheeky and asked for a "fancy" one wire ibutton reader. They sent me the cheaper one instead. Can't complain at that. As wel all sample options. Play nice and don't take the piss. Also iirc the falling edge of the RTC SQW at 1hz is half way though the second. Also ready the atmel power guides. Iirc if you set all the I/O your not using as inputs you will lower power usage, also disable all the prefs your not using such as the ADC http://www.nongnu.org/avr-libc/user-manual/group__avr__power.html http://www.nongnu.org/avr-libc/user-manual/group__avr__power... Good luck and enjoy your clock :-) (I have have one of my own but isn't counting to Friday). Also there is a bit in the RTC (forget which bit in which register and don't have the data sheet to hand) that get set if the RTC lost battery power. You can use this and the default time of the RTC to determine if you need to set the RTC time (like your doing using the compile time in setup()) another trick with that. I've found the 2nd compile in a row is normally much faster then (not always the case) so instead of just uploading the code. Verify the code first, then it upload that way your not rebuilding the whole thing and the set time to compile time will be a little more accurate.