4

In my app I want to detect how strong surrounding magnetic/electromagnetic fields are. What I want to achieve is to measure magnetic field change to know if it's stronger than in control measurement or if it's lower. This is my code:

- (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;
}

Magnitude value reacts to the magnetic fields surrounding the device, the problem is that you need to be REALLY close to a source of such a field.

So, the question is: Is there any possibility for an iOS app to measure magnetic fields on distances more than 10-20 centimeters? If so, how?

P.S.: I have also checked the Teslameter App by Apple, it has nearly same code and totally same problems.

Ivan Nesterenko
  • 939
  • 1
  • 12
  • 23

1 Answers1

2

Sure you can, the magnetic field just has to be very strong!

Your first limit might be the hardware. As noted in In iOS, what is the difference between the Magnetic Field values from the Core Location and Core Motion frameworks? the range of those raw values may be limited. At some some hardware and iOS versions restricted them to -128 to +128 microteslas. On an iPhone 6 I can get microtelsa readings well outside that range but that doesn't necessarily help. Apple doesn't seem to provide any reference for the accuracy of magnetometer readings, we can measure values out to nanotesla but the results we get back might be meaningless noise.

Earth's magnetic field at the surface will be 25 to 65 microteslas. Any field you hope to measure is going to need to be measurably stronger than that at the desired measurement distance. What are you trying to measure, and is it really strong enough to move a compass needle at the distance you want to measure it?

Community
  • 1
  • 1
Jonah
  • 17,918
  • 1
  • 43
  • 70
  • The thing is I want to measure delta of the magnetic field's magnitude, just let's say did it become stronger or weaker. – Ivan Nesterenko Mar 15 '16 at 01:34
  • 1
    @IvanNesterenko right so the question becomes; what is the smallest detectable delta in that magnitude the device can measure and how close does that mean you need to be to the source? When I run Apple's example app I see components which vary by at least +/- 1 microtesla. It's going to be very difficult for you to detect a 1 microtesla or less change due to your target field. Given the field's strength how close do you need to get the device to register at least a few microtesla change? – Jonah Mar 15 '16 at 04:52