top of page

Why is a smartphone compass not affected by magnets?


You have probably already tried to disturb a compass by bringing a magnet close to it, but have you ever tried the same experiment with your smartphone's electronic compass? In the video below, we conducted the experiment, and the result is surprising: the smartphone's compass appears to be unaffected by the presence of a magnet.



Why such behavior? As a scientist, can we trust the magnetometer data? And what are the implications for measuring magnetic fields with a smartphone? This is what we will explore in this article.



  1. Why a magnetometers in a smartphone?


If the accelerometer has been an integral part of smartphones since the earliest generations—originally designed to determine the device's horizontal or vertical orientation—magnetic sensors (or magnetometers) were added much later. The HTC Dream, launched in October 2008, is often considered the first Android smartphone to officially include a magnetic sensor. On Apple's side, the iPhone 3GS, released in June 2009, was the first iPhone to feature a magnetometer.


Why such a delay? At the time, the primary function of magnetometers in smartphones was the digital compass. This feature was useful for navigation, whether for hiking or driving, but it alone was not enough to justify the additional cost and effort required to integrate the sensor. Moreover, the magnetometer is highly sensitive to external elements, making it not always reliable.


However, as smartphones became more powerful, new applications emerged, such as motion-based games, virtual reality, and augmented reality. These applications required a new capability: the ability to precisely track the smartphone's position in space. For example, by moving their smartphone, users could steer a car or a spaceship or explore different angles of a virtual object. These applications drove manufacturers to integrate new sensors into smartphones—particularly the magnetometer—to the delight of gamers… and scientists.



  1. Navigating in space at the best cost



To determine the position of an object at a given moment, two approaches are possible:

  • Using a fixed reference frame: This method involves having a stationary reference frame and an instrument capable of measuring orientation relative to it.

  • Calculating incremental variations: Starting from a known position, successive changes are measured through acceleration and rotation data to deduce the new position.


Submarines use this second method. Thanks to extremely precise gyroscopes and accelerometers, they can navigate without external reference points for several days. However, the accumulation of errors (drift) can result in deviations of several kilometers from their actual position.


For smartphones, which experience much more limited movements, the magnetometer is a highly advantageous alternative, as the Earth's magnetic field provides an excellent local reference. It offers several key benefits:

  • Simplicity of calculations: Measurements are directly linked to the Earth's magnetic field.

  • No drift: Unlike gyroscopes and accelerometers, there is no accumulation of errors.

  • Low power consumption: A magnetometer consumes between 10 µA and 500 µA, whereas an accelerometer consumes about 10 times more, and a gyroscope up to 100 times more.


Given the limited capacity of smartphone batteries, this low power consumption is a major advantage, as it helps preserve battery life while ensuring reliable and cost-effective measurements.



  1. The difficult measurement of the magnetic field


While the magnetometer may seem like the ideal instrument for determining a smartphone's position in space, one major obstacle complicates its use: the low intensity of the Earth's magnetic field.


The Earth's magnetic field has an intensity of about 50 microteslas, divided between a horizontal component (useful for determining north) and a vertical component (indicating magnetic latitude). For comparison, a simple natural magnet, such as magnetite, can generate a field reaching 0.05 tesla—one thousand times stronger. This means that even the slightest stray magnetic field near the sensor can completely distort measurements. For instance, a video demonstrates that a smartphone's magnetometer can detect the field generated by a simple rotating compass, even from a distance of twenty centimeters.


Sensibilité du magnétomètre à la rotation d'une boussole

Magnets aren't the only culprits when it comes to errors—various materials can also disrupt measurements by altering or distorting the magnetic field.

  • Ferromagnetic materials (iron, nickel, cobalt, steel): These become permanently magnetized and interact strongly with the magnetic field.

  • Paramagnetic materials (aluminum, platinum, magnesium): Weakly attracted to the field, as their unpaired electrons temporarily align with it.

  • Diamagnetic materials (copper, gold, graphite, water): Slightly repelled by the field, as their paired electrons create an opposing field.


Additionally, the smartphone’s internal circuits generate their own disturbances. The electrical currents flowing through its components produce magnetic fields proportional to the current intensity and the circuit layout. These fields fluctuate depending on the smartphone’s activity, such as processor operations or network communications. As a result, these stray fields interfere directly with the magnetometer’s measurements, making the data unreliable if calibration is not carefully performed.


For accurate measurements, the magnetometer must be calibrated to compensate for both external material influences and stray fields generated by the smartphone itself.



  1. Static calibration


To correct the various effects that disrupt the ambient magnetic field and prevent the magnetometer from accurately detecting the direction and intensity of the Earth's magnetic field, engineers have developed a calibration mechanism.


Two major categories of disturbances are addressed: the hard iron effect, caused by permanently magnetized elements (such as a screw or a speaker magnet), and the soft iron effect, which results from non-magnetized materials locally distorting the magnetic field lines.


To compensate for these disturbances, the smartphone is moved through a wide range of motions (such as the well-known figure-eight movement). This movement exposes the magnetometer to all orientations, allowing it to correct bias and scale errors while compensating for local disturbances.

By applying these corrections, the system provides a much more reliable measurement of the magnetic field, essential for accurately indicating the Earth's magnetic field direction and the smartphone's positioning in space.



  1. Dynamic calibration


Static calibration helps determine the necessary adjustments to isolate the Earth's magnetic field from internal disturbances within the smartphone. But what happens when a magnet is brought close to the phone or when it's placed inside a car? The measurements will be disrupted, making the magnetometer ineffective. How can these interferences be compensated for?


Early smartphones required users to recalibrate the device whenever the environment changed by performing the well-known figure-eight movement.


Over time, developers introduced more advanced algorithms capable of automatically detecting and compensating for abnormal variations in the magnetic field. These algorithms continuously measure the detected field and compare it to its expected value, using data from the accelerometer and gyroscope.


For example, if the phone is resting on a table and a magnet is brought nearby, the software detects the additional field, measures variations along the three axes, and adjusts the calibration to align the values with the initial magnetic field. But what happens if, at the same time, the phone is rotated? The gyroscope and accelerometer are then used to calculate the phone’s rotation, estimate the theoretical magnetic field without the magnet, and adapt the correction accordingly.



  1. The challenge with sensor fusion


Today, in a smartphone, it is difficult to separate the three positioning sensors: the magnetometer, gyroscope, and accelerometer. These sensors work together to provide precise positioning information while minimizing energy consumption.


This integration of sensors, combined with others like GPS, is known as sensor fusion. The smartphone’s operating system continuously analyzes data from these sensors and makes adjustments based on the specific function being used. For example, to save energy, the system may prioritize the magnetometer or accelerometer in certain situations, only activating the GPS when necessary.


While this fusion benefits users and specialized applications, it presents challenges for scientists and educators. Raw sensor data is harder to access, and open-access data is often altered by the system’s constant adjustments, such as automatic calibration. These modifications make it more difficult to interpret data for experiments or precise analyses.


This is especially true for the magnetometer. Nearly all applications that measure the magnetic field use compensated data that does not fully reflect reality, making reliable measurements more challenging.



  1. Measure the real magnetic field


To measure the real magnetic field, it is necessary to both access the raw data from the magnetometer and account for the smartphone’s internal components (hard iron and soft iron effects). This is exactly what FizziQ provides with the "Raw Magnetic Field" function.


This feature is part of a set of measurements developed in FizziQ, allowing direct access to the raw values of the accelerometers. This gives teachers a variety of tools to conduct classroom experiments on magnetism using nothing but a smartphone:


a. Automatic Magnetic Field

This is the calibrated value provided by the smartphone, suitable for compass-type use.


b. Raw Magnetic Field

This is the direct reading from the magnetometer, without adjustments.

It can be aligned with the theoretical value by pressing "Calibration," which calculates static corrections (hard iron and soft iron) without continuously updating them. This ensures the measurement remains consistent for analyzing the real magnetic field.


c. Y Field & Magnetic North Deviation

FizziQ calculates the actual magnetic field along the Y-axis, as well as the angle between the measured field and magnetic North.

It clearly shows how a magnet influences both the magnetic field and the direction of the compass.



  1. Classroom experiments on the magnetic field


When used correctly, the magnetometer in smartphones is a highly useful tool for teachers, allowing them to illustrate various concepts related to the Earth's magnetic field, Biot-Savart's law, and the properties of magnetic dipoles:


a. Earth's Magnetic Field

By observing the Y-component of the magnetic field, students can determine its horizontal component (corresponding to the North direction for a compass) and measure the inclination angle in the vertical plane.This helps them understand how this angle depends on latitude and verify the relationship between the Earth's magnetic field and geography.


b. Oersted's Effect

By placing a smartphone inside a coil carrying current, students can experimentally verify Biot-Savart's law and Ampère's law.This allows them to better understand how a magnetic field is created and distributed around a wound conductor.


c. Magnetic Dipole

With the magnetometer, students can map the magnetic field produced by a bar magnet (dipole) at different points in space.This helps confirm the Coulomb-like law for magnetism, which predicts that the field intensity decreases as 1/d³ with distance.


d. Magnetic Properties of Materials

Using the magnetometer, students can observe how different metals (ferromagnetic, paramagnetic, or diamagnetic) interact with a magnetic field.The results can illustrate real-world applications, such as detecting buried metallic objects in sand or identifying sunken ships.



  1. Conclusion


The magnetometer is a key component in smartphones, essential for navigation (by identifying the direction of the Earth's magnetic field) and for providing a reliable measurement of the phone's orientation in space with minimal power consumption. This precision is particularly useful for interactive games and virtual or augmented reality applications.


However, using this sensor in the classroom requires a deep understanding of how it works, particularly the data acquisition mechanisms and the biases introduced by the smartphone's automatic calibration processes, which can affect measurements.


With this in mind, we have developed a dedicated magnetic field measurement module within FizziQ. This module allows teachers to conduct a wide range of classroom experiments, such as studying the Earth's magnetic field, magnetic dipoles, Oersted's effect, and the magnetic properties of different materials.






47 views0 comments

Comments


bottom of page