Arduino resets when relays deactivate if analog inputs are connected

I'm using an arduino nano with 5 relay outputs and 3 analog inputs. The code is a sequencer that is initiated with a button input. If the analog inputs are disconnected, everything works fine, but if they are connected, then when the relays deactivate, the arduino resets.

I can attach the code or a diagram if needed, but since it works as long as the analog inputs are disconnect, I don't think it is a coding issue.

I'm not an electrical engineer... I'm wondering if there is EMF causing interference? Things too close?

The wires look like a mess... I am planning on zip tying everything so it is neat later.

Relays (and motors and servos) should be powered separately from the Arduino, as they inject electrical spikes into the power supply, resulting in the behavior you discuss (or worse: the spikes can destroy equipment).

I have attempted this with several different power supplies. I also tested powering be Arduino with the USB and having it isolated from the relay boards. I wasn't sure if there should be a common ground between the relay boards and the Arduino. I'm not getting a response without a common ground.

There must be a common ground for signals between the Arduino and the relay board.

Please post a link to the relay board(s), and a scan or photo of a hand drawn (not Fritzing) wiring diagram showing all the connections, especially power and ground.

Here is an attached wiring diagram.

Completely useless wiring diagram. The connections aren't sensibly labeled, and the board photos add next to nothing, so it is nearly impossible to interpret.

Good luck with your project.

I highly recommend using relay modules as opposed to relays. You must still power the magnet from separate source with the modules, however. They include the requisite diode and transistor.

I have attached another wire diagram with added labels. I also moved a few things around to hopefully make it easier to follow.

Here are the components:
4 Channel Relay Board

2 Channel Relay Board

Current Sensor