Go Down

Topic: Sleep and Millis() - I need both? (Read 2 times) previous topic - next topic

winner10920

You could perhaps use some logic ics to count while you sleep, not sure how much they would draw tho
you can use a clock signal fed into a ripple counter(or multiple for more precision using a faster clock), then get that parallel output into a piso shifter and when the arduino wakes, clock the data in with spi or bitbang it to recieve how many clock cycles have passed since it was asleep

PeterH

There are power management libraries which can perform the sleep and maintain the 'millis()' value correctly, which simplifies your sketch.

All you really need to send is the count, and the length of time over which that count was collected. I don't see any point sending the previous values since the absolute numbers don't mean anything - it is only the change that is significant.

I suggest that you accumulate the count and duration and only reset when a successful upload has been completed. That way, if there is any difficulty with the upload you will lose granularity in the logged data but the total values will still be correct.
I only provide help via the forum - please do not contact me for private consultancy.

Coding Badly

Why not have the receiver timestamp the data?  Why does the sender have to do it?

I guess this could work but if I lost a packet instead of a gap I would have corrupt data.


A sequence number solves the problem.  Including a few previous values will allow recovery from multiple dropped packets.

iisfaq


There are power management libraries which can perform the sleep and maintain the 'millis()' value correctly, which simplifies your sketch.


I have not seen any - the only mode that maintained the millis function was SLEEP_MODE_IDLE when I did some testing.

But in this mode there is not much power savings since the processor wakes up every millisecond.

All other modes I tried the millis() had stopped.

chris

PeterH


I have not seen any - the only mode that maintained the millis function was SLEEP_MODE_IDLE when I did some testing.


Have you tried searching? There are quite a few power management libraries around.

http://www.engblaze.com/low-power-libraries-for-arduino-control-sleep-with-single-function-calls/
I only provide help via the forum - please do not contact me for private consultancy.

Go Up