Capture phone Accelerometer and Gyroscope data

Hi there, is it possible with the Home Assistant companion app to capture the phones Accelerometer and Gyroscope data? I have a spare Android phone and would love to use it to capture any very local earthquake data by using these two sensors.

If this is possible to set up, I haven’t been able to find any documentation on it.

Thanks!

I would also be interested to know, using phone’s accelerometer would enable a fall detection automation to send alert

That’s also a very good use for it, my Google Pixel watch also notified me the other day about a potential fall – would also be nice to capture that data as well while using the companion app on the watch.

Since a Google search leads here, I had to do my own app to collect sensor data and push it to MQTT.

It is available in Google Play as well if you join as a tester.

The following sensor configuration in config.yaml works for me:

mqtt:
  sensor:
    - name: "Accelerometer X"
      state_topic: "opensensor/sensor/accelerometer"
      value_template: "{{ (value_json.x | float)| round(2) + 0.0 }}"
      unit_of_measurement: "4m/s^2"
      unique_id: "accelerometer_x"
      suggested_display_precision: 2
      state_class: "measurement"
    - name: "Accelerometer Y"
      state_topic: "opensensor/sensor/accelerometer"
      value_template: "{{ (value_json.y | float) | round(2) + 0.0 }}"
      unit_of_measurement: "4m/s^2"
      unique_id: "accelerometer_y"
      suggested_display_precision: 2
      state_class: "measurement"
    - name: "Accelerometer Z"
      state_topic: "opensensor/sensor/accelerometer"
      value_template: "{{ (value_json.z | float) | round(2) + 0.0 }}"
      unit_of_measurement: "4m/s^2"
      unique_id: "accelerometer_z"
      suggested_display_precision: 2
      state_class: "measurement"