Hi hotpointer,
Does the micro reset if you disconnect the solenoid valves and just have the relays switching?
Having the flyback (Back EMF) diodes for the solenoids and relays is good, but their effectiveness is governed by the PCB layout and GND connections. A large current can flow through these diodes during flyback and the PCB tracks going to them can develop a voltage difference along their length. This voltage on the GND connections may be reducing the 5V supply long enough for the brown out detection circuit in the micro to generate a reset.
Can you post a picture of the PCB layout?
HalfSpace