I just broke my s3. 3 years ago it was one of the best smartphones.
Question How can I get the values of the inertial sensors of the phone via usb?
I would like to use the accelerometer, gyroscope, magnetometer, barometer and gps sensors of the device.
Let's say that we want to get:
- the raw acceleration's data along the three axes.
I connected the usb cable and ran adb root
and adb shell
. Ok.
root@android:/ # find / -type d -iname "sensors"
/sys/devices/virtual/sensors
/sys/class/sensors
The '/sys/class/sensors' directory contains:
root@android:/ # ls sys/class/sensors
accelerometer_sensor
barometer_sensor
gyro_sensor
light_sensor
magnetic_sensor
proximity_sensor
The problem
The raw measurements do not change even if I tilt the phone. The sensor is in standby mode. It always displays the same values.
root@android:/sys/class/sensors/accelerometer_sensor # cat raw_data
-74,121,1016
I have noticed the folder power/control which controls the power state of the sensor.
root@android:/sys/class/sensors/accelerometer_sensor # cat power/control
auto
I tried with echo on/yes/ok/yeah/wtf > power/control
but nothing changed.
I remember that when I had the screen of the phone working, it was sufficient to open an Android application with sensors' permissions, like Google Maps with the compass feature, to Enable the sensors and get the values refreshed at a constant rate. The Java application probably writes something in a file to activate the sensors and reads the raw values.
How can I activate the sensors from the shell?