From postmarketOS
Icon TODO: This page needs some tips on testing all the sensors that can be found in the device

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.


A visualization of different rotation states.

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 monitor-sensor tool to see, what it thinks the orientation of the device is.

If the rotation is reported incorrectly, you may need to define mount-matrix. 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.)


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 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 proximity-near-level 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)
# iio-sensor-proxy
# Set PROXIMITY_NEAR_LEVEL for iio-sensor-proxy to pick up the proximity sensor

# Set the sensor type for all the types we recognise
ACTION=="add", SUBSYSTEM=="iio", TEST=="in_proximity_raw", ENV{PROXIMITY_NEAR_LEVEL}="250"

As with other sensors that iio-sensor-proxy monitors, you can use monitor-sensor 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.