How to connect arduino with sensor using different power source.

If my arduino use power source #1 and I want to read digital input from sensor that use power source #2

Is it ok if I connect sensor output to arduino digital input and connect power source #2 minus(-) pole to arduino gnd?

If the sensor output does not exceed 5v (assuming 5v supply) just connect the Gnd of the sensor to Gnd of the Arduino and sensor output to the input of the Arduino.

Weedpharma