Help to design a running hour counter for two electrical motors.

Dear All,
Good Day.

I would like to design a project to count the running hours for two electrical motors once any one of them started.
for example :
A- electrical motor No.1 and 2 in STOP mode ----> running hour for both of them are 0.0 Hour.
B- electrical motor No.1 OR 2 Started, I need a separate running hour to be started and print the running hour value and keep saving the value after stop.

Dear All, I am new arduino uno user, so it will be a nice of you, if the code is simple and understandable, regarding wiring installation i can do it easily .

Your Kind Cooperation is highly appreciated.

Kind Regards.

You haven't said whether you know how to detect if a motor is running.
It is also important to know what voltage the motors use in case there are safety issues.

As far as the Arduino is concerned it needs an input (for each motor) that reads 4v to 5v (5v is the absolute max) when the motor is running and 0v when it is stopped. In case you are using an AC motor, be aware that the Arduino cannot accept negative voltages.


I would suggest copying the hours log values in EEPROM at regular intervals
(but not too rapidly or you risk wearing out the EEPROM), and read this in at
start up, and write it out also when the system is to be shutdown (or whenever
both motors become idle?).

EEPROM is persistent till you deliberately overwrite it and isn’t normally
altered during programming.

Dear Friends,
Good Day.

Many Thanks for your kind cooperation, my proposal design is to make one digital input for each electric motor ( for this i can do it ) , but i tried to write a code to do timer for each electric motor once start unfortunately i failed many times.

your kind cooperation is highly appreciated.

I suggest you use the millis() function to create a value that increments at the level at which you wish to record time. For example my boat engine records the run time in 10 minute intervals.

So I would have a counter that updates every 10 minutes. I would then record the count (of ten minute periods) in an unsigned long variable. That will hold 2^32 x 10 minute counts or a total period of 800,000 years (if my maths is correct).

You just need to arrange that the value is only incremented while the input pin is HIGH.

As @MarkT says, you should save the value to EEPROM memory at suitable intervals. If you write every 10 minute value to the EEPROM and if the EEPROM can survive 100,000 writes that will represent about 19 years (E&OE).


800,000 years

You know you just might have something here.