connect_to_sensor function