can we use SPI on different ground?

Can we connect the SPI lines (MISO,MOSI,SCK) without the same ground line? for example, we have 2 batteries.

+5V +3V3
| |
[Master] VCC--- ------VCC [Slave]
SCK ------------------------- SCK
MISO-------------------------MISO
MOSI-------------------------MOSI
GND --- ---GND
| |
(GND from 5v) (GND from 3V3)

Waiting for your reply...

No, the grounds must connect. With batteries alone it's not a problem. If the batteries are connected to chargers and your circuit at the same time, then you do have a problem as the chargers may have different ground potentials.

I'm thinking that you also have a problem with different voltages. Can the 3.3v device handle 5v on its inputs? Many cannot and they will be toasted by the 5v. Level converters are available from Adafruit, Sparkfun etc, but they must connect the grounds together.

The solution to both problems is to use optocouplers. Then the grounds can be very different voltages (500v or more.) Getting an optocoupler to work with high-speed SPI does take some real engineering design as the optocoupler is an analog device and needs some biasing to get it to work at high speed.

MorganS:
No, the grounds must connect. With batteries alone it’s not a problem. If the batteries are connected to chargers and your circuit at the same time, then you do have a problem as the chargers may have different ground potentials.

I’m thinking that you also have a problem with different voltages. Can the 3.3v device handle 5v on its inputs? Many cannot and they will be toasted by the 5v. Level converters are available from Adafruit, Sparkfun etc, but they must connect the grounds together.

The solution to both problems is to use optocouplers. Then the grounds can be very different voltages (500v or more.) Getting an optocoupler to work with high-speed SPI does take some real engineering design as the optocoupler is an analog device and needs some biasing to get it to work at high speed.

Thanks a lot for your answer.