Timer for total used time or countdown

Hello there everyone,

I am working on a project right now that can make the user track time for the number of LEDS. As to my knowledge, they have about 10.000 hours of working time. When the 10.000 hours are up, user should be notified when LED's don't work anymore.
There are 2 ways I thought this could work.
One of them is to track the time with a time tracker module but the problem with this is whenever Arduino is shut down the process will reset and the countdown will never end. Is there a solution to this?
The second should be countdown for each time it it used. For example my LED's will work 1 hour each time when it is used, the countdown should be reduced to 9999 more uses. I hope you get the point.
How should I approach this? What extra modules should I buy for this to work?

Hi,
Is there a reason for this application?
What situation would you want to know runtime?
From my experience LED lights usually fail before this due to economical/cheap construction.

Use a stand alone Totaliser Timer.
Lots of machinery have them to check run time and service intervals.
The Totaliser will not forget the time, they are designed for the sort of application you have.

Google totalizer timer

Tom... :slight_smile:

Welp, ı am actually thinking of making a homemade UV-C LED device that would sterilize the masks or daily stuff needed, would be a fun project to work on.
I checked the time totaliser you have mentioned but it seemed expensive for this project. What else can you recommend me on this? Any type of counter should work for this project as well

Maybe a starting point.

// A basic retentive timer.  Runs when enabled.
// Holds value when enable false.  Reset when
// resetPin goes low.  Reset overrides enable

uint32_t accValue;
uint32_t preset = 3000; // 3 seconds
uint32_t previousMillis;
uint32_t currentMillis;

const byte enablePin = 8;
const byte resetPin = 10;
const byte doneLED = 13;

void setup() {
  Serial.begin(115200);
  pinMode(enablePin, INPUT_PULLUP);
  pinMode(resetPin, INPUT_PULLUP);
  pinMode(doneLED, OUTPUT);
}

void loop() {
  currentMillis = millis();
  if (digitalRead(enablePin) == LOW) { // pushbutton pressed, run timer
    accValue = accValue + currentMillis - previousMillis;
  }
  
  if (accValue >= preset) {
    accValue = preset;
    digitalWrite(doneLED, HIGH);
  }
  else digitalWrite(doneLED, LOW);
  previousMillis = currentMillis;
  
  if (digitalRead(resetPin) == LOW) accValue = 0;

  Serial.println(accValue); // if needed
}

With some tinkering, and probably some added hardware, you could save the value to EEPROM for power down times.

I note Aldi selling a device purportedly for sterilising your phone( :astonished: ) but do they actually make UV-C LEDs?

Seriously? :cold_sweat:

EEPROM has limited writes so probably wouldn’t be great for storing timing data for this long unless the arduino didn’t shut down in an uncontrolled fashion and thus had time to write to eeprom only on occasions when necessary rather than regularly just in case of loss of power. Of course it only takes one glitch and your counter is back to 0 in this case

Hi,
What sort of time period do you expect this device to actually exist, not run, but exist?

10,000 hours = 10,000/24 = 417 days, that is over a year continuous operation.

Are you over thinking your project?

A 2 hour a day operation will be 5,000 days or 13.5 years.

You might be better to write the start of operation date on the light.

The other factor is the UV radiation level, it will not be constant up to 10,000 hours operation then cease.

I would be checking the level of radiation at regular times as a calibration measurement to see exactly how your LEDs are working. This will take into account things like power supply performance and enclosure characteristics in one measurement to give an overall performance.
Better than waiting for expiry date.

Tom.... :slight_smile:

Hello there again everyone,
Sorry been busy for a few days. Thank you so much for taking your time.

Paul__B:
I note Aldi selling a device purportedly for sterilising your phone( :astonished: ) but do they actually make UV-C LEDs?

Seriously? :cold_sweat:

Yeah, it seems they make them. (At least I have found one online and never actually got to see it.) I can send in one of the links if you are interested, or maybe you can correct me if I am wrong about all this.

pmagowan:
EEPROM has limited writes so probably wouldn’t be great for storing timing data for this long unless the arduino didn’t shut down in an uncontrolled fashion and thus had time to write to eeprom only on occasions when necessary rather than regularly just in case of loss of power. Of course it only takes one glitch and your counter is back to 0 in this case

I have read about EEPROM and I think you are right. One small glitch would reset my counter or make it useless so I have given up on that part.

TomGeorge:
Hi,
What sort of time period do you expect this device to actually exist, not run, but exist?

10,000 hours = 10,000/24 = 417 days, that is over a year continuous operation.

Are you over thinking your project?

A 2 hour a day operation will be 5,000 days or 13.5 years.

You might be better to write the start of operation date on the light.

The other factor is the UV radiation level, it will not be constant up to 10,000 hours operation then cease.

I would be checking the level of radiation at regular times as a calibration measurement to see exactly how your LEDs are working. This will take into account things like power supply performance and enclosure characteristics in one measurement to give an overall performance.
Better than waiting for expiry date.

Tom.... :slight_smile:

It would take too much time for the LED power to run out as you have mentioned. And from your previous reply I learnt that LEDs will probably start working because of connection issues. Therefore, I gave up on that part. I think trying out the calibration method you have given me is more useful.

Again, thanks to all of you for taking your time.