Sounds like it's time for a little divide and conquer: two tests you could do to try and separate code from temp issues. Does the system as is run ok if you keep it in a cooler environment? What happens if you keep the equipment in place but just run a simpler program that reads the clock and writes it to the SD?