Sensors

Devices usually have some sensors such as IMU, light or proximity sensors in them. This page is intended to provide various tips on enabling and testing those sensors.

Accelerometer
The accelerometer is used for automatic screen rotation.

iio-sensor-proxy is used by some UI's to track the display orientation, you can use  tool to see, what it thinks the orientation of the device is.

If the rotation is reported incorrectly, you may need to define. See e.g. the device tree bindings.

A Python script to generate the mount matrix can be found here and here (Same script but with additional patches.)

Magnetometer
See separate article on magnetometer.

Proximity sensor
Proximity sensor is usually located behind the screen on top of the device and is used to blank the screen when the user takes the device near the ear.

iio-sensor-proxy
iio-sensor-proxy can report the "near" state to other programs on the device but it needs to know what's the "near" level to report it.

There are multiple ways to provide that information:


 * Define  in the devicetree. The iio device driver must support reading and reporting that value.
 * For those drivers that don't support the DT property, it's possible to add an udev rule like this: (Consider extending the driver like this instead)

As with other sensors that iio-sensor-proxy monitors, you can use  tool to check the proximity sensor.

Hall sensor
Also known as Hall IC or flip cover sensor. When a piece of magnet approaches the sensor, the phone suspends. Note that suspending is not implemented on some SoCs yet.