Power reading on the display

I have an ArduinoUNO with a sketch applied to my needs emonTX. How to change the EmonTX sketch so that when the pulses run out and the power drops, the display also shows zero and does not show the reading of the previous measurement, waiting for the next pulse that does not come until after several hours.

Welcome back, Kauko.

Is this the sketch you are using? Addition to emonTx

If it is, then inside loop( ), you need to get the time using micros( ) and calculate when the last pulse was. You know that from lastTime, but the difficulty you have is those timers overflow after approximately 70 minutes. Therefore, you must say that no pulse after (say) 60 minutes (60,000,000 µs) equals no power (but you can say a shorter time if you wish). You then set emontx.power = 0;.

You must do the maths on the times correctly so that the overflow - when the number reaches the maximum for an unsigned long integer and starts again at zero - is handled correctly:

if ((micros( ) - lastTime) > 60000000)
   emontx.power = 0;

You cannot do this inside onPulse( ) because that part of the code is only executed when a pulse comes in.

I have not tested this, but I think it will work.

Thanks Robert for the quick reply.
The draft is exactly the same one for which I asked for advice in the past which works as it was an idea, thanks for that.
For the problem now, the purpose is just to see on the screen the time of the power drop approximately.
The idea is, for example, 30 seconds without a pulse, in which case you know that the power is switched off.
I try the program line you entered and see if the program works as desired.
Regards Kauko

Good morning Robert.
I made the addition you made to the sketch and put a delay of 30sec which seems to be a suitable time for my purpose. In the future I will think of some changes when … the continuous power of the device is 1750W which is cut off by the thermostat and when the process is complete there will be an after-cooling phase run by a 100W fan that cools the device to 100C, after which the power is 0W.
In other words, that power should also be recorded.
But it is only an idea of the future but not a necessity.
Regards Kauko