any ideas on how to program this?
There are a few examples available on the Internet that show how to put the processor to sleep. Here are the two I started with...
The processor can be wakened by an interrupt. If the accelerometer has some way of generating an interrupt (a serial recieve may do it), then what you want to do may work.
log the time its moved at
Save yourself a great headache. Plan to include a real-time clock.
the thing that concerns me is if the accelerometer need a constant 5 volts for it to be able to send the code to wake the arduino up, therefor defeting the perpose of putting it to sleep in the first place
If the goal is to run from batteries then every little bit helps.
A few caveats...
- The deeper sleep modes turn off the processor's clock (which may disable the serial port and definately stops the millis counter)
- It can take serveral clock cycles for the processor to wake. The processor may not wake fast enough to catch the first bit of data from the accelerometer.
- The watchdog oscillator is not a reliable source of time. Temperature and load affect it dramatically. And even when those are stable it still has jitter and drift.