Need Advice on approach for detecting wiring and sensor faults.

Im writing a program to control a boiler, and i know how devastating a loose wire can be on a relay logic system, sometimes causing relays to chatter on and off rapidly, sometimes causing motor starters to do the same.

Right now I'm using a lot of timer on delays and timer off delays in my program to prevent devastating consequences of motors and air valves from fluttering on and off until they blow up. But i have nothing to actually stop them from continuing to turn on and off every 5 seconds, i could increase the timers, but then the burner takes a long time to get going.

I'm curious if theres a library or something of the sort that could easily detect when a sensor flutters on and off rapidly, rather then writing code for every input with timers and counters.

Well, I suppose you could debounce inputs with a button library, but I think any hardware problems should be resolved first. You can detect these problems in software but any actions you take (like time delays) has its own consequences.

It would be good to know what components you have (with links) and schematic. Also your code.

If your input signals are conditioned properly and output circuit is powered separately, isolated and has appropriate flyback, EMI/RFI and spike/arc suppression, then coding becomes simpler and operation would be more reliable and effective.