Motor monitoring + non invasive current sensor

Hello. I want to create a system that measures the ON time of an AC electric motor. I thing to use non-invasive current sensor. I make the hardware, the sensor is working, i receive data. I attach the sketch. The idea is when the current is > 0 to start a timer to detect how long the current is > 0. Аll the times should come together and have an idea of how long the motor has worked in the last 24 hours. I hope you understand my bad English. I need some sample code to help me get started Thank you!

If you post your code according to the forum guidelines in the how to use this forum-please read stickies, more people will see your code.

See the beginner's millis() tutorial for information on timing.

How accurately do you need the times? An Arduino by irself is not very accurate. It could be minutes off after 24 hours. If you need more accurate time keeping a Real Time Clock (RTC) would be required.

use the openenergy site and the entire Arduino code to get readings.

this is not code, but should give you an idea of one way to look at counting the time.

if ( amps are higher than 1
if (running flag == 0
start = millis()
running_flag = 1

if (amps are lower than 1
if running_flag == 1
Run_Time = Run_Time + (millis() - start
Serial.print(total runing time is " )
Serial.println (Run_Time )