Electronic compass method to eliminate interference