Communication between two AVR microcontrollers over SPI with different power supplies
If you have isolated circuits you can always choose 1 reference point on each circuit to connect to the other. Only one. In most case that will be the grounds.

Both 5 V supplies are isolated from each other through transformers, then you can safely connect their grounds together.