The magnetometer is a magnetoresistive permalloy sensor found in the iPhone 3GS, iPhone 4 and iPad 2, in addition to the accelerometer. The iPhone 3GS uses the AN-203 integrated circuit produced by Honeywell, while the iPhone 4 and iPad 2 make use of the newer AKM8975 produced by AKM Semiconductor. The sensor is located towards the top right hand corner of the device, and measures fields within a ±2 gauss (200 microtesla) range, and is sensitive to magnetic fields of less than 100 microgauss (0.01 microtesla).
The Earth’s magnetic field is roughly 0.6 gauss (60 microtesla). The field around a rare earth magnet can be 14,000 gauss or more.
The magnetometer measures the strength of the magnetic field surrounding the device. In the absence of any strong local fields, these measurements will be of the ambient magnetic field of the Earth, allowing the device to determine its “heading” with respect to the geomagnetic North Pole and act as a digital compass. The geomagnetic heading and true heading relative to the geographical North Pole can vary widely, by several tens of degrees depending on your location.
Combining the heading (yaw) information (see Figure 5-1) returned by this device with the roll and pitch information returned by the accelerometer will let you determine the true orientation of the device in real time.