I try to measure neodymium magnet magnetic field strength, exactly - how it depends on distance to magnet, by using integrated magnetometer sensor in Huawei phone. My setup is like : enter image description here

Then I move neodymium magnet as pictured - horizontally along ruler, and measure dropping magnetic field intensity with app "Magnetic Field Sensor". Because magnetic field has dipole nature - I was expected to get field dropping $\propto r^{-3}$ relationship to distance. But to my surprise, that was not the case. For bigger distances what I've got is relationship $\boxed {\propto r^{-1.5}}$ with a very good fit,- coefficient of determination $R^2 = 0.99$. Results are neither $r^{-2}$ as in monopole fields, nor $r^{-3}$ as in dipole fields. So there must be some error in measuring magnetic field strength. Here comes the question - What possible reasons of this measurement error can be :

  • Problems in Huawei magnetic field sensor. (Was designed to measure Earth magnetic field, so neodymium magnetic field somehow is distorted by Earth magnetic field readings in the sensor ??)
  • Problems in a measuring app "Magnetic Field Sensor" - incorrectly interpolates/extrapolates sensor data, rounding issues, bugs, etc...
  • Both of these two above ?
  • Anything else which I have not thought about.

Any ideas ?


Here is my measurement data requested :

distance (mm) / Field (μT) (A case) / Field (μT) (B case)
0   1025    478
2   918     436
4   734     399
6   539     344
8   403     293
10  308     239
12  242     198
14  209     164
16  170     130
18  141     109
20  122     106
22  103     88
24  90      79
26  79      68
28  70      61
30  63      53

B case was measured field strength by sliding magnet along vertical axis close to phone (perpendicularly to the one shown in picture). Amazingly, sliding magnet vertically, at bigger distances, relationship stays the same $r^{-1.5}$

  • $\begingroup$ Do you think you could include your data if it's not too difficult? Also, I'm guessing you plotted a log-log graph to get the exponent? How many points did you have? $\endgroup$
    – Philip
    Commented Jan 7, 2021 at 20:06
  • $\begingroup$ measurement data included, graph is plotted starting from a distance of 14 mm, because at close distances is total chaos, and exponent is fluctuating about $-1$. No, it's not a logarithmic scale - ordinary ones. Seems like field strength does not want to drop at all. Maybe Huawei phone has integrated magnet inside, which is affecting the readings or something ? $\endgroup$ Commented Jan 7, 2021 at 20:19
  • $\begingroup$ What is your phone model? $\endgroup$
    – Ruslan
    Commented Jan 7, 2021 at 21:46
  • $\begingroup$ Huawei P30 Pro model $\endgroup$ Commented Jan 7, 2021 at 22:15

2 Answers 2


Your data cannot fit your proposd equation. It should become infinite at r=0 and your data dooes not behave like this. Obviously what you call r=0 does not correspeond to a sensor at zero distance from the field source. Whatever that means.

If I try a dependence of (r+18)^x I get x=3 with R2=0.997 where r and 18 are in mm. Other exponents give good fits too, depending on what origin you choose.


It looks like your magnet is cubic. Here is the formula some manufacturer gives for the field of their cubic magnet: https://www.supermagnete.de/eng/faq/How-do-you-calculate-the-magnetic-flux-density#formula-for-block-magnet-flux-density As you can see, it's nothing like the simple dipole formula. And this is only for the field along the z axis. Now I can expect that if you expand the arctangents in series and look at z much larger than the dimensions of the cube you may get some inverse cube dependence (I did not try it).
But if your sensor is off-axis then the dependence becomes more comlicated. Even for simple dipole, the proportionality constant in the B versus 1/$r^3$ formula depends on the angle, so the magnitude of B is not a function of just r. And you still have the problem of determining the origin, how z=0 in the formula relates to your setup.

  • $\begingroup$ Oh interesting, I see, thanks. But then how to know exact offset in mm where sensor in phone is located ? As you have said, one choosing different sensor offset - will get different exponent. How to extract true exponent. Or to find out true location of magnetometer sensor ? I've tried sliding magnet along different phone places, the maximum field peak I've got at a pictured bottom corner. Maybe sensor is deeper inside a phone ? But then I can't move magnet close to it. So how to solve this problem, for not substituting $18 mm$ offset without a real reason ? $\endgroup$ Commented Jan 7, 2021 at 21:03
  • 1
    $\begingroup$ I am not saying that an offset of 18 mm is the right one. I just tried values until I got the exponent if -3 just to show that you can get it. The field may not be a function of just r but may depend on x, y, z component. I don't think it is spherically symmetric, to depend just on r. And the sensor's symmetry matters too. $\endgroup$
    – nasu
    Commented Jan 7, 2021 at 21:26
  • $\begingroup$ And even for ideal dipole, the simple dependence works only for faraway points. Nearby is more complicated. $\endgroup$
    – nasu
    Commented Jan 7, 2021 at 21:28
  • 1
    $\begingroup$ I edited the answer to include some info from a magnet manufacturer for cubic magnets. From the picture looks like you use a cubic magnet, right? $\endgroup$
    – nasu
    Commented Jan 8, 2021 at 0:09
  • 1
    $\begingroup$ Very intresting. I played with the formula too but in a different way. I took the dimeansions of the magnet 5mm (it looks like being around this size in the picture) and plotted the field nummerically. I found that for distances (z) over about 100 mm it fits well with an inverse cubic power. For distances in your measured range the exponent is closer to 1.5 indeed. You can plot a log-log graph and see that it becomes close to a straight line for large z, but not or your range of distances. $\endgroup$
    – nasu
    Commented Jan 9, 2021 at 4:52

The range of the magnetoresistive sensors is typically about 1 milli-tesla. Permanent magnet have much higher fields at close range, so you sensor may have gotten saturated. Then you need to reset it, by moving the phone in a figure-8 pattern.

So it is best to start the measurement at a larger distance.

  • 1
    $\begingroup$ Thanks, you both were right. Magnet shape & saturation was the case. $\endgroup$ Commented Jan 8, 2021 at 17:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.