Ios magnetometer wrong values

173 Views Asked by At

I am writing code to detect magnet. I am doing this through this code:

let manager = CMMotionManager()

if manager.isMagnetometerAvailable {
manager.startMagnetometerUpdates(to: OperationQueue.main) { (data, error) in    
        let bField = sqrt((pow(data?.magneticField.x ?? 0, 2) + pow(data?.magneticField.y ?? 0, 2) + pow(data?.magneticField.z ?? 0, 2)))
        print(bField)    
    }
}

problem is that it is printing value above 250 when there is no magnet. This value should be around 50uT if there is no magnet around. Is it raw data? If it is raw data how can I get original data?

0

There are 0 best solutions below