understanding of UART , if two devices share a common ground. How do they get to the same voltage level for a save data transmission?
Grounds should be established by connecting them together. If they cannot be connected together, galvanic isolation can be employed. The signal levels over cables are typically defined by a standard such as RS-232C (1969). 

Discrete circuits or chips such as the antediluvian MC1488/MC1489 and more modern parts such as MAX3232 can be used to convert between TTL/CMOS levels (as would come out of an MCU directly) and RS-232 levels (they also invert), as you would send over a cable into the outside world.