Counting Random Interval Events

I want to count events into the following buckets.

This is objects falling through a chute.

This input changes as quickly as 500ms but can sometimes never change so there can be significant data to organize or none.

last 60 minutes
last 24 hours
last 48 hours

So, I realize that I may need to timestamp the events, but I want it to be a rolling, real time update.

I'd like to do this without an RTC, so using millis()

Does anyone have experience simplifying what I am trying to do here?

How many events do you expect in a 48 hour window? As you surmise, you will have to timestamp all of them. In the simple case, this means storing an unsigned long for each event at the cost of four bytes apiece.

You could push the data to SD card or do some reprocessing on the timestamps & some other trickery to get to fewer than 4 bytes of RAM per event, but the max number of events you're going to get will guide you towards which Arduino you'll need. Alternatively, you could offload the data storage to a PC and let it tell the arduino what the counts per bucket are.

I was thinking about 48 buckets in an array and cascading the numbers each hour.

int hourlyRead [48]

I could count an hour, shift the numbers, count the hour... and so on. I just have to realize that the 24/48 will be only updated once an hour. That works for me.

that makes this a present hour/first hour issue and a lot less data, but I would like a real time number for the past one hour.

two counts, I guess?

maybe this can be useful - Arduino Playground - Histogram -

BulldogLowell:
I want it to be a rolling, real time update.

What granularity do you want on the rolling update? I mean, do you want the three display values to update every minute, every second, faster than that? To do this perfectly would require keeping a time-ordered list of every single event, but if you don't need every value to be accurate to within fractions of a second then much simpler options are available.

robtillaart:
maybe this can be useful - Arduino Playground - HomePage -

Thanks Rob. I actually underspecified my requirements because I thought that it would be to bothersome to program. I think this library will let me do more.

I'll be back for questions, likely.

cheers.