MagneticFieldSensor to detect magnet poles

Has anyone used the MagneticFieldSensor to determine if the face of a magnet is a north or south polarisation?

Hi TimN.
The sensor of the smartphones is for REGULAR (geo magnetic field sensor). Not a particular magnetic field of a piece of an object.
Not for analyze the ferromagnetism, diamagnetism or paramagnetism.
Example for that, this sensor ALSO cannot measure paleomagnetism in ferromagnetic materials or in soils.
I hope you are asking this, because i understand that from your question.

The sensor of the smartphone are usable ONLY for regular GEO Magnetism. And doesn't in all cases measure the Magnetic declination (i see some phone do it), but depends of the quality of the sensor.

If you want to measure magnetic currents or fields of an object, you can check this pages.
You must to use an Arduino NANO and then read the data with the phone.

For measuring Hall Effect.
I hope this could be useful for you.

Thanks for the answers. So I’m wondering how this is supposed to work?

Just tested the Magnetic Field Sensor with a magnet. (Companion Google Pixel 4a)

It does change the returned values considerably.

One would need to decipher the readings from the "background" geomagnetism to be able to test poles. Perhaps record a range of readings for the background geomagnetism, then average the values to get a background level. Then identify the same for a magnet.

Here is one designer that seems to have done it to detect North or South. Works better on a modern iPhone than my older HTC One Android.

Could be as simple as this


The documentation in AI2 and on Android Developers is sparse with regards to using local magnetic fields, as the sensor IS intended for geomagnetic sensing.

I do not have a marked magnet/compass to hand, so am guessing with the if condition (it might be round the other way, or you need the Y/Z strength....)

The magnet should be held 1-2 inches away from the top of the device (not the face/screen)

I'll give it a go soonest,

Hello Timai2 , I have entered your program and I find that you have to run very slowly before you see the Z and N, label 1 shows NZ and label 2 shows values but when you spin hard the value is 0.00031 , how come this?

Kind Regards
Wind Magneet Meter

My thoughts are that your magnet needs to be rotating at 90 degrees to its current rotation poistion, so that the N & S poles of the magnet come close to the device, then away from it. This will require a more complicated setup with a right angled gear....