Several outlets have been reporting on an apparent hardware bug in the iPhone 5s accelerometer/gyroscope (see CNET, Gizmodo, ExtremeTech, Apple Support Communities, and MacRumors). The defect manifests itself in accelerometer-based apps and Apple's Compass app, which show discrepancies of as much as 8 to 10 degrees compared to the iPhone 5.
RealityCap, a developer of 3D APIs, theorizes that the bug may be in the new Bosch Sensortech accelerometer, a new part supplier in the iPhone 5s. In a blog post RealityCap CEO Eagle Jones points to the Chipworks teardown of the iPhone 5s, which identifies a Bosch Sensortech BMA220 accelerometer in the new flagship iPhone 5s. The iPhone 5 uses a STMicroelectronics LIS331DLH part according to iFixit.
Accelerometers have two key numbers that tell you the quality of their outputs. Note: in the spec sheets, and the next couple paragraphs, the abbreviation mg refers to milli-g, or one one thousandth of standard gravity, not milligram. The first key spec is the noise density (ST) or output noise (Bosch). This tells you how much random jitter you will see in measurements. At first it looks like the spec for the Bosch part is much worse, but this is deceiving as these numbers are reported for a specific measurement rate (bandwidth), and the ST datasheet doesn’t specify that rate. In our measurements, the noise output of the accelerometer in the iPhone 5S is reasonably similar to that of previous iOS devices.
The second key spec for accelerometers is the zero-g offset, or bias. This indicates the range for a roughly constant offset that will be added to every output sample of data due to manufacturing variance. This can also change over time due to mechanical stress or temperature variation. This is where we find the problem: the typical bias for the ST part is +/- 20mg, while the Bosch part lists +/-95mg. This almost 5x greater offset range is confirmed by our measurements, and is absolutely consistent with the failures being reported by users and the media. Specifically, a +/- 20mg offset range would translate to around a +/-1 degree accuracy range in tilt detection, and a +/-95mg offset translates to +/-5 degrees in tilt.
Jones notes that both parts cost about one dollar in quantity making it unlikely that Apple switched suppliers to save money. His theory is that Apple chose the Bosch part based on its lower power consumption (in normal mode the Bosch part uses 450μW and the ST part uses 625μW), concluding that it's a poor tradeoff for the inherent inaccuracy.
Unfortunately, hardware defects can't be patched with a simple iOS dot release. Luckily, Jones thinks that developers can work around the chip flaw by incorporating a calibration procedure into their apps - like the Compass app does when you first launch it. This would allow the app to determine the accelerometer bias which can then be subtracted from the data coming from the accelerometer to get a correct reading.
I compared Compass.app my iPhone 5s to my wife's iPhone 5c and they were pretty close, which appears to validate reports that both new iPhones use the same Bosch part. (I don't have an iPhone 5 on hand to compare them to). There's a 70-page thread discussing the issue on the MacRumors Forums, if you'd like to follow the blow-by-blow.