Hello,
I have a project in which i have a speed sensor monitoring wheel speed continuously, now i want to store the latest data into EEPROM before the arduino shuts down and retrieve back the data once the arduino is powered again.
To read the data is something was easy but to write the data only when the arduino is shut down is something i am struggling in.
gauravbothra:
Hello,
I have a project in which i have a speed sensor monitoring wheel speed continuously, now i want to store the latest data into EEPROM before the arduino shuts down and retrieve back the data once the arduino is powered again.
To read the data is something was easy but to write the data only when the arduino is shut down is something i am struggling in.
Need help to solve this issue
Thank you in advance.
Regards,
Gaurav
My approach would be the have the arduino itself control when it would shutdown,
for example, if a relay is powering the arduino and and a switch controls said relay,
then I would wire 2 digital pins to the switch input (and some diodes); one to read the switch status and the other to 'drive' the relay.
when the switch is turned OFF, the arduino then HOLDS the relay ON long enough store your value before releasing the relay thereby going into complete shutdown.
one approach is to always save changed speed values. however, EEPROM has some limited # of writes
a more tricky approach is to recognize the onset of the loss of power with an interrupt which has a short bit of time to do something before power is completely lost