[Consolidating an answer from the comments]
A wired connection using Optical isolation (aka Optocouplers) is the recommended way to solve this problem.
There are tutorials available online regarding optical isolation (e.g., https://www.electronics-tutorials.ws/blog/optocoupler.html; https://bestengineeringprojects.com/interfacing-optocoupler-with-arduino/).
One (of many) possible example circuit was noted as:
