Go Down

Topic: store, days passed counter, to eeprom (Read 2307 times) previous topic - next topic


Apr 04, 2011, 02:21 pm Last Edit: Apr 04, 2011, 02:23 pm by dalai Reason: 1
hi from a newbe !
In my project ,micro controller need to change some  values of the program, depending to the days that passed.
For example if we are on day 1 ,the he keep the temperature of the room ,to 23 Celcius . On day 2 the temperature must set to 25 C.
I will use an internal clock to count days.Something like this code http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1227406778/all
The problem is that  if power lost (or reset) , then the arduino will start again fron day one.
I want every 6 hours arduino ,store the days passed  (2 days and 6 hours, or 2 and 1/4 ,or something similar).So  and after every reboot ,arduino, first read those data and continue counting. If I store time every minute ,maybe it will be a problem with eeprom and from the other hand, loosing 6 hours is not a big problem .
If my all idea of solving this problem is wrong, please feel free to guide me. Thank you


For how many days? One byte of EEPROM could store 1/4 days, with a value up to 255, which would be 63.75 days. Every 6 hours, increment the number stored. On reset (intentional or otherwise), read the number stored.

If the length of time that the function is to cover is significantly less than 63 days, you could decrease the interval between saving, with a corresponding change in what the saved value represents (1/4 of a day, 1/6th of a day, 1/8th of a day).
The art of getting good answers lies in asking good questions.


Apr 04, 2011, 02:31 pm Last Edit: Apr 04, 2011, 02:35 pm by dalai Reason: 1
I will count about 50 days.
My best choice would be to backup timer  every 1 hour, but i read that ,internal eeprom will have problem with many read/writes.
If you think that  writing every 1 hour for 1-2 years working period is not so much ,then maybe its for the best to choice more accuracy ,on backup counter.


The EEPROM is good for 100,000 writes so that should be good.

1 hour for 1-2 years

That's still only 17520.

Rob Gray aka the GRAYnomad www.robgray.com


In my project ,micro controller need to change some  values of the program, depending to the days that passed.

Sounds like you need to add a RTC (real Time Clock) check the DS1307 You can just read the day month year hour Minute second ...
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up