Most smart phones have a Magnetometer sensor built into them. These sensors measure Magnetic Field, or Magnetic Dipole Moment and allows the phone to sense the orientation in space in relation to Magnetic North and Magnetic South, along the X, Y and Z axes. If your phone has a compass app, then the compass app is using the Magnetometer sensor.

The Magnetometer Sensor has an internal chip that contains 3 separate modules used to measure each axis (X, Y and Z) independently by measuring the intensity of the Earths magnetic field, or a local source of magnetism (ie a Bar Magnet or in our cases the EMF radiated from a spirit). Each separate module contains a Hall Sensor which converts the magnetic field into an output voltage, the output voltage is dependant on the magnetic field strength.

As the Earths magnetic field is quite weak in relation to other magnetic sources, these other sources can overpower the Earths magnetic field and change the voltage of the sensors. The magnetic field measurement from these sensors is measured in μT (micro Tesla).

image courtesy of w3.org

For a more detailed explanation on how magnetometer sensors work please visit https://www.w3.org/TR/magnetometer/

So, how do I use the Magnetometer sensor inside my apps?

First of all I need to know the max range of each axis for the Magnetometer chip found inside the phone (each chip has different max ranges), this max range is the same for both positive and negative. So if the positive max range is 4,000 μT for an axis, then the negative max range is -4,000 μT. We will use 4000 μT for this explanation as an example.

So the range for each axis goes from -4000 .. 0 .. 4000 μT.

Hold up, let’s stop for a second and have a look at 1 of my EMF Meter displays.

The above is the EMF Meter from my SGK1 Ghost Hunting Kit.

The EMF Display is divided up into 15 blocks, from green to red. The blocks light up from left to right, where the furthest left green block represents a weak or no magnetic measurement, all the way over to the furthest right red block, representing a strong magnetic measurement. So, the stronger the magnetic measurement, the more blocks (from left to right) light up.

Here a stronger Magnetic measurement is detected so more blocks light up.

Great, but how do I convert the μT measurements from the magnetometer sensor into the coloured blocks in the display?

Thats a good question, because the readings received from the magnetometer sensor are giving me a 3d point in space for the magnetic source creating the magnetic field around the phone. If you looked at the image above showing the X, Y and Z axes of a phone you will see that if the phone is lying flat on a surface and I position a magnet towards the bottom of the phone, I will get a negative Y value. If I put the magnet towards the top of the phone I will get a positive Y value. The same goes for the X and Z axes. So wherever I place the magnet around the phone I will be getting an X, Y and Z value of the 3D point in space around the phone for the position of the magnet, based on the strength of the magnetic field created by the magnet.

So here’s where things start to get complicated. I need to convert those numbers received from the magnetometer sensor (ranging from -4,000 μT to 4,000 μT for each axis) into 1 number from 0 to 14 (the 15 blocks used in the EMF Display). 0 being the weakest strength and 14 being the strongest strength.

So, we know the range of each axis is -4000 μT to 4000 μT. The maximum of the 3 of those axes values added together gives 6928.20323 μT, this is the maximum number all of the sensors can give us for the strongest magnetic measurement received.

But the maximum value of each axis is only 4,000 μT, and the 3 of those added together is only 12,000 μT, so how can the maximum range be 6928.20323 μT?

I need to perform a calculation to retrieve what is known as “the Magnitude” of the Magnetometer X, Y and Z values.

First I need to work out the maximum Magnitude using the following calculation:

Max Magnitude = the square root of (max x value * max x value + max y value * max y value + max z value * max z value)

So,

Max Magnitude = the square root of (4000 x 4000 + 4000 x 4000 + 4000 x 4000)

In this example case, the maximum Magnitude is 6928.20323 μT

So now we have the maximum Magnitude that this particular magnetometer is able to give us and I store it to be used later.

Now I need to get the current Magnitude of the Magnetometer, using the same equation as before but instead of using the maximum value, I use the current values from the axes.

The equation looks like this (where x = x axis value, y = y axis value, z = z axis value and m is the current Magnitude):

m = the square root of (x * x + y * y + z * z)

Now, if any of the X, Y or Z values are negative, they will now be a positive number, and if any of the values are positive, they will still be a positive number, and all 3 added together will be within the range of 0 μT and 6928.20323 μT.

Now what I do is I divide 15 (the amount of blocks in my EMF Meter Display) by 6928.20323 μT and then multiply that decimal value by the value given in the above equation.

The sum looks like this:

15 / 6928.20323 = 0.002165063509547

Then perform

0.002165063509547 * m = the amount of blocks to light up in the EMF Meter Display (after rounding to 0 decimal places).

So how do I work this all this out for the other type of EMF Meter Display that I use?

The above EMF Display works the same as the block display, but instead of having 15 blocks, there are 160 degrees of angle to work with. Half a circle is 180 degrees, but if you look in the image of the display you can see that it is missing roughly 10 degrees on the left and the right, giving 160 degrees to work with.

I just simply change the sum from

15 / 6928.20323 = 0.002165063509547

to

160 / 6928.20323 = 0.023094010768503

Then using trigonometry (sin) I rotate the dial by the value of the sums answer, after rounding the answer to 0 decimal places.

So that is how the EMF Meters work in my apps. They are a very precise tools that use the Magnetometer sensor that is built into your phone / tablet.