Testing proximity/ambient-sensor

The developer docs describe how to test the sensors for proximity and ambient light.

https://developer.puri.sm/Librem5/Development_Environment/Phone/Troubleshooting/Testing_Proximity.html

root@pureos:~# /usr/sbin/i2cdetect -y 1                                                                 
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- 1e -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- UU -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- UU -- -- -- -- -- -- -- -- -- -- -- -- 
60: UU -- -- -- -- -- -- -- -- -- UU -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

Stopping iio-sensor-proxy didn’t help. The mentioned address for the sensors is still blocked by some driver.

Any suggestions how to make the sensors accessible?

That’s good, this means the drivers are there :wink:

That article is quite outdated at this point, it describes how to talk to the sensors without using any driver - you’d use that knowledge while writing a driver, which you don’t have to do because it’s there now :wink: For use in applications, you rather want to use iio-sensor-proxy’s API, and for testing, you can use monitor-sensor.

In case you want to talk to sensors directly anyway, you can still do it by using -y switch. Keep in mind that the sensors could be powered down by the driver while not in use though.

3 Likes

Thanks, that works for ambient light. But how do I test/get values of the proximity sensor and the accelerometer:

purism@pureos:~$ monitor-sensor 
    Waiting for iio-sensor-proxy to appear
+++ iio-sensor-proxy appeared
=== Has accelerometer (orientation: undefined)
=== Has ambient light sensor (value: 1.920000, unit: lux)
=== Has proximity sensor (near: 0)

monitor-sensor will show you the orientation (just move the phone around and see it changing), and proximity sensor getting above its threshold (just cover the area above the screen and see it changing). However, to get raw values from the sensors, you’ll have to resort to using i2c directly at this point. AFAIK there is a raw API for accelerometers being worked on in iio-sensor-proxy (so things like games could then use it), but that’s not ready yet.

2 Likes

Yeah, nice. That did it. I had expected something more ‘analog’…

Enabling lockdown mode and disabling it again, proximity sensor does not come up again:

purism@pureos:~$ monitor-sensor 
Waiting for iio-sensor-proxy to appear
+++ iio-sensor-proxy appeared
=== Has accelerometer (orientation: left-up)
=== Has ambient light sensor (value: 12.240000, unit: lux)
=== No proximity sensor

After restart proximity sensor is back. This seems to be a bug.

2 Likes

Check @ChriChri’s posts here: Librem 5 various observations on that (link to related issue ticket)

Thank you very much! This seems to be a similar issue. There the problem is that the “accelerometer not regonized”, here it is the proximity sensor. The common thing is the lockdown mode which makes the problem.

Purism already knowing that bug time ago.