How Does the iPhone Level Work?
The iPhone offers much useful technology, including applications that can tell you if a surface is level. While it may not be able to replace a professional's tools, it can certainly be handy for the average user, whether you're hanging pictures or just showing off to your friends. The key to this application lies in the iPhone's three-axis accelerometer.
A typical level looks like a long ruler. Generally, it has at least one small cylinder of liquid with a tiny air bubble. As you tilt the level, the air bubble slides to one side of the cylinder or the other. When the bubble is in the exact center of the cylinder, it indicates that the level is perfectly horizontal or vertical. The cylinder is typically filled with ethanol, which has a low viscosity.
An accelerometer is a device that measures forces of acceleration. This can be movement, such as a push or a shake, but it can also be a static force, such as gravity. By measuring the force due to gravity, an accelerometer can determine the tilt of the object relative to the ground. Typically, sensors measure the amount of pressure being exerted and translate this pressure into useful data, such as whether something is falling, going uphill or resting horizontally.
The iPhone contains a tiny three-axis accelerometer. Three-axis indicates that it can measure acceleration forces in three dimensions, so no matter which way you tilt it or move it, one of the axes can tell. The accelerometer has springs that are calibrated with a specific weight, or mechanical resistance. Even the slightest movement changes the pressure on these springs. The iPhone processes this change in pressure and translates it into a meaningful change in space or orientation.
Many level applications exist for the iPhone, but they all work the same way, by interpreting data from the accelerometer. The program translates the static forces of gravity on the iPhone's tiny springs into a position relative to a specific surface. The application must either be pre-programmed to know what measurements indicate perfectly horizontal ("level") or vertical ("plumb"), or you must calibrate these measurements before you begin taking readings -- which means you already have to know at least one surface is level. In addition, the iPhone's accelerometer is never entirely stationary, and each accelerometer is slightly different, so different iPhones can give slightly different readings.