在我的应用程序中,我想检测周围磁场/电磁场的强度。我想要实现的是测量磁场变化,以了解它是否比控制测量更强或更低。这是我的代码:
- (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;
}
幅度值会对设备周围的磁场产生 react ,问题是您需要真正靠近这种磁场的来源。
那么,问题是:iOS 应用程序是否有可能测量超过 10-20 厘米距离的磁场?如果是,怎么办?
P.S.:我也检查了 Teslameter App由 Apple 开发,它具有几乎相同的代码和完全相同的问题。
最佳答案
当然可以,磁场必须非常强!
您的第一个限制可能是硬件。如 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 .您希望测量的任何场都需要比所需测量距离处的场强得多。您要测量什么,它的强度是否真的足以将罗盘针移动到您想要测量的距离?
关于ios - 使用 iOS 设备作为特斯拉计(磁力计讨论),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36000659/