230V AC controll with arduino and relays (now dead arduino)

5 Months later and another arduino gets "crazy" switching on/off my ups grrrrrrrrrr i will have to check what went bad this time....
it seems that was the pin the the controlled the relay...
Im changing the relay with optoisolated with optocoupler 817c ...
what else can i do protect the arduino ?

thanks