Hi,

To get rid of all glitches and spikes ... the use of a radio clock ( here in Europe, it's DCF 77 ) signal could be good. small modules are so cheap nowadays ... say 2$ unit price !!!

And that would correct automatically ... if mains failure !!!

Alain