使用 iOS 设备作为特斯拉计(磁力计讨论)

Using iOS device as teslameter (magnetometer discussion)

在我的应用程序中,我想检测周围 magnetic/electromagnetic 场的强度。我想要实现的是测量磁场变化,以了解它是否比控制测量更强或更低。这是我的代码:

- (void)setupLocationManager {
    self.locationManager = [[CLLocationManager alloc] init];
    if ([CLLocationManager headingAvailable] == NO) {
        self.locationManager = nil;
    } else {
        self.locationManager.headingFilter = kCLHeadingFilterNone;
        self.locationManager.delegate = self;
        [self.locationManager startUpdatingHeading];
    }
}

// CLLocationManagerDelegate
- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)heading {
    CGFloat magnitude = sqrt(heading.x * heading.x + heading.y * heading.y + heading.z * heading.z);
    if (self.defaultMagnitudeValue == 0.f) {
        self.defaultMagnitudeValue = magnitude;
    }
    self.curentMagnitudeValue = magnitude;
}

幅度值对设备周围的磁场作出反应,问题是您需要真正靠近磁场源这样的领域。

所以,问题是:iOS 应用程序是否有可能测量超过 10-20 厘米距离的磁场?如果是,怎么做?

P.S.: 我也检查了 Apple 的 Teslameter App,它有几乎相同的代码和完全相同的问题。

当然可以,只是磁场要很强!

您的第一个限制可能是硬件。如 In iOS, what is the difference between the Magnetic Field values from the Core Location and Core Motion frameworks? 中所述,这些原始值的范围可能有限。在某些硬件和 iOS 版本中,它们被限制在 -128 到 +128 微特斯拉。在 iPhone 6 上,我可以获得远超出该范围的 microtelsa 读数,但这不一定有帮助。 Apple 似乎没有提供任何关于磁力计读数准确性的参考,我们可以测量到纳特斯拉的值,但我们得到的结果可能是无意义的噪音。

地球表面的磁场将为 25 to 65 microteslas。您希望测量的任何场都需要比所需测量距离处的场强得多。你想测量什么,它真的足够强大,可以将罗盘针移动到你想要测量的距离吗?