You were watching a video on YouTube in portrait mode, and the screen real estate wasn't enough. To solve this problem, you did what any person with a smartphone would do. Turn the phone on its side.

As soon as you did this, the video engulfed the whole screen, and all the menu options were invisible, but how did your phone know about its orientation?

Well, in addition to the high refresh rate screen and a great user interface, your phone has several sensors that detect its orientation in space, but how do these sensors work?

Understanding the Fundamental Forces of Nature

Although you can feel the wind on your face and the water on your hands when it rains, what you can't feel are the fundamental forces of nature.

These forces include the gravitational force and the electromagnetic force. Even though these forces are intangible, they affect everything we do. In fact, the screen on your smartphone detects small changes in electromagnetic forces to detect your finger. Not only this, but your body weight is also defined because of the forces of gravity.

Simply put, gravity applies a force on objects causing them to accelerate at a speed of 9.8 m/s^2. Due to this acceleration, things fall back on the ground when you throw them.

Electromagnetic spectrum
Image Credit: Wikimedia Commons 

On the other hand, electromagnetic force cannot be felt like the forces of gravity. That said, if you were to place a compass anywhere in the world, it would detect the Earth's magnetic field in that area and align itself to the North Pole.

Although electromagnetic forces have enabled several technological advancements, they are not all for good, and electromagnetic radiation in high doses can be dangerous for the human body.

Understanding the Sensor Technology on Your Smartphone

The sensors on your smartphone detect changes in the forces of nature to understand its orientation in space, but how do these sensors work?

Well, your smartphone has thousands of sensors on its motherboard, but three main sensor types that enable your phone to detect changes in its orientation.

These orientation detection sensors use Micro-Electro-Mechanical Systems (MEMS) to measure the forces of nature. To measure data, MEMS devices use mechanical parts embedded in silicon to generate an electrical signal. Using these signals, your smartphone detects changes in the forces acting on it.

Given below is a brief explanation of how these sensors work.

  • Accelerometer: As the name suggests, an accelerometer is used to detect the changes in acceleration on a smartphone. To detect these changes, the accelerometer uses the law of inertia which states that a body at rest will stay at rest until and unless an external force is applied. To use this concept, a fixed mass is suspended between spring-like structures in a MEMS sensor. Therefore, the fixed mass stays in place when the phone is accelerated due to its inertia compressing the springs. This spring compression generates an electrical signal telling the smartphone that it's being accelerated.
  • Gyroscope: The gyroscope monitors the rotational forces on your smartphone. This rotation measures the Coriolis force acting on the smartphone to estimate how much it has rotated about its center of gravity. Simply put, the Coriolis force acts on any body inside a rotating object due to its rotation. The gyroscope uses a design similar to an accelerometer but is modified to detect changes when the smartphone rotates.
  • Magnetometer: Due to the currents flowing in the Earth's core, a magnetic field engulfs it. Detecting these fields helps the smartphone understand its orientation with the true north of the Earth's magnetic field. Smartphones are equipped with a three-axis Hall effect sensor to detect these changes. This sensor uses Faraday's laws of electromagnetic induction to detect magnetic fields. According to this law, a current-carrying conductor generates an electromotive force when the magnetic field around it changes. Due to these changes in voltage, the sensors can be used to detect its orientation concerning the Earth's magnetic poles.

Now that we have a basic understanding of the sensors in our smartphones, we can look at how they work together to detect the position of your smartphone.

How Does Your Phone Know When to Turn the Screen?

As explained earlier, the accelerometer can detect changes in acceleration, but this data alone cannot be used to detect the orientation of a smartphone. The reason is that the forces of gravity are always acting on the accelerometer, and it's difficult for the sensor to detect when the changes in acceleration are meant to rotate the smartphone.

iPhone teardown with battery visible

Smartphones use sensor fusion to solve this problem, which enables different sensors to communicate with one another. To detect a phone's orientation, the accelerometer communicates with the gyroscope and the magnetometer.

Therefore, when a phone rotates, the accelerometer detects changes in acceleration and then communicates with the gyroscope. Due to this communication, the smartphone can understand if the changes in acceleration are intended for rotation.

That said, the gyroscope is susceptible to errors as it cannot consider the forces of gravity acting on the smartphone. Therefore, a third sensor is needed to detect the changes in the orientation of a smartphone. This sensor is none other than the magnetometer on your device.

This magnetometer is used to detect the changes in the smartphone's position with respect to the Earth's magnetic field. This data, along with the data from the accelerometer and the gyroscope, is used to decide if your screen needs to be in portrait or landscape mode.

Is Sensor Technology the Future?

The accelerometer, gyroscope, and magnetometer detect changes in the fundamental forces of nature by using the laws of inertia and electromagnetic induction.

Smartphones use these fundamental laws to enable features like autorotation and optical image stabilization. That said, smartphones now offer innovative features by combining data from different sensors.

A prime example of this is the release of crash detection on Apple devices which enables data from these sensors to detect an accident and alert emergency services.