how to make different grounding
Here is one of the simplest opto-couplers that I can think of.

It would be simpler if the flashlight was replaced by the sun.

The receiver indicates the relative brightness of light hitting the sensor.

As light brightness changes, the amount of current flowing in the circuit changes.

Do you see any reason why the two circuits require a common ground to operate correctly?







simulate this circuit &ndash; Schematic created using CircuitLab

Now add some dangerous voltage to the circuit, either by accident or by design.







simulate this circuit

Now add a common ground.







simulate this circuit