QMI8658 Accelerometer/Gyroscope Sensor

The qmi8658 sensor platform allows you to use your QMI8658 Accelerometer/Gyroscope (datasheet) sensors with ESPHome. The I²C Bus is required to be set up in your configuration for this sensor to work.

This component only does some basic filtering and no calibration. Due to the complexity of this sensor and the amount of possible configuration options, you should probably create an external component by copying and modifying the existing code if you want a specific new feature. Supporting all possible use cases would be quite hard.

Image
QMI8658 Accelerometer/Gyroscope Sensor.
Image
# Example configuration entry
sensor:
  - platform: qmi8658
    address: 0x6B
    acceleration_lpf_mode: MODE_3
    acceleration_odr: 1000Hz
    acceleration_range: 8g
    acceleration_x:
      name: "QMI8658 Accel X"
    acceleration_y:
      name: "QMI8658 Accel Y"
    acceleration_z:
      name: "QMI8658 Accel z"
    gyroscope_lpf_mode: MODE_3
    gyroscope_odr: 1000Hz
    gyroscope_range: 256dps
    gyroscope_x:
      name: "QMI8658 Gyro X"
    gyroscope_y:
      name: "QMI8658 Gyro Y"
    gyroscope_z:
      name: "QMI8658 Gyro z"
    temperature:
      name: "QMI8658 Temperature"
    update_interval: 60s

Configuration variables

  • address (Optional, int): Manually specify the I²C address of the sensor. Defaults to 0x6B, may also be 0x6A.

  • acceleration_lpf_mode (Optional, enum): One of supported LPF modes for accelerometer:

    • OFF - LPF is disabled (Default)
    • MODE_0 or 2.62% - 2.62% of ODR
    • MODE_1 or 3.59% - 3.59% of ODR
    • MODE_2 or 5.32% - 5.32% of ODR
    • MODE_3 or 14% - 14% of ODR
  • acceleration_odr (Optional, enum): One of supported ODR modes for accelerometer:

    • 8000HZ - 8000HZ (Default)
    • 4000HZ - 4000HZ
    • 2000HZ - 2000HZ
    • 1000HZ - 1000HZ
    • 500HZ - 500HZ
    • 250HZ - 250HZ
    • 125HZ - 125HZ
    • 62.5HZ - 62.5HZ
    • 31.25HZ - 31.25HZ
    • LOWPOWER_128HZ - 128HZ (Low Power)
    • LOWPOWER_21HZ - 21HZ (Low Power)
    • LOWPOWER_11HZ - 11HZ (Low Power)
    • LOWPOWER_3HZ - 3HZ (Low Power)
  • acceleration_range (Optional, enum): One of supported accelerometer ranges:

    • 2g - Full-scale = ±2 g (Default)
    • 4g - Full-scale = ±4 g
    • 8g - Full-scale = ±8 g
    • 16g - Full-scale = ±16 g
  • acceleration_x (Optional): Use the X-Axis of the Accelerometer. All options from Sensor.

  • acceleration_y (Optional): Use the Y-Axis of the Accelerometer. All options from Sensor.

  • acceleration_z (Optional): Use the Z-Axis of the Accelerometer. All options from Sensor.

  • gyroscope_lpf_mode (Optional, enum): One of supported LPF modes for gyroscope:

    • OFF - LPF is disabled (Default)
    • MODE_0 or 2.62% - 2.62% of ODR
    • MODE_1 or 3.59% - 3.59% of ODR
    • MODE_2 or 5.32% - 5.32% of ODR
    • MODE_3 or 14% - 14% of ODR
  • gyroscope_odr (Optional, enum): One of supported ODR modes for gyroscope:

    • 8000HZ - 8000HZ (Default)
    • 4000HZ - 4000HZ
    • 2000HZ - 2000HZ
    • 1000HZ - 1000HZ
    • 500HZ - 500HZ
    • 250HZ - 250HZ
    • 125HZ - 125HZ
    • 62.5HZ - 62.5HZ
    • 31.25HZ - 31.25HZ
  • gyroscope_range (Optional, enum): One of supported gyroscope ranges:

    • 16dps - Full-scale = ±16dps (Default)
    • 32dps - Full-scale = ±32dps
    • 64dps - Full-scale = ±64dps
    • 128dps - Full-scale = ±128dps
    • 256dps - Full-scale = ±256dps
    • 512dps - Full-scale = ±512dps
    • 1024dps - Full-scale = ±1024dps
    • 2048dps - Full-scale = ±2048dps
  • gyroscope_x (Optional): Use the X-Axis of the Gyroscope. All options from Sensor.

  • gyroscope_y (Optional): Use the Y-Axis of the Gyroscope. All options from Sensor.

  • gyroscope_z (Optional): Use the Z-Axis of the Gyroscope. All options from Sensor.

  • temperature (Optional): Use the internal temperature of the sensor. All options from Sensor.

  • update_interval (Optional, Time): The interval to check the sensor. Defaults to 60s.

  • id (Optional, ID): Manually specify the ID used for code generation.

qmi8658.enable_wake_on_motion Action

You can put qmi8658 chip into special low-power consumption Wake on Motion (WoM) mode. When module will detect motion exceeding the specified threshold it will toggle one of it’s interrupt pins. That can be helpful when building low power consumption systems with Deep Sleep Component. Here is an example:

# Example configuration entry
deep_sleep:
  wakeup_pin:
    number: GPIO13

sensor:
  - platform: template
    id: wakeup_cause
    lambda: return esp_sleep_get_wakeup_cause();
    on_value_range:
      above: 1
      then:
        qmi8658.disable_wake_on_motion:
  - platform: qmi8658
    acceleration_x:
      name: "QMI8658 Accel X"
    acceleration_y:
      name: "QMI8658 Accel Y"
    acceleration_z:
      name: "QMI8658 Accel Z"

# in some trigger
on_...:
  - qmi8658.enable_wake_on_motion:
      initial_pin_state: 0
      interrupt_pin: INT2
      threshold: 250
  - lambda: id(wakeup_cause).publish_state(0);
  - deep_sleep.enter:

ℹ️ Note

In this example in deep_sleep component we set GPIO13 as wakeup pin, it is wired to INT2 pin of QMI8658. On some trigger we enable WoM that will set INT2 pin to LOW and toggle it to HIGH on motion exceeding 250 threshold waking up the host.

After host wake up we need to disable WoM to be able to consume new data from a sensor so we use template sensor that utilizes esp_sleep_get_wakeup_cause() method.

Configuration options:

  • id (Optional, ID): The ID of the qmi8658 sensor.

  • acceleration_odr (Optional, enum, templatable): One of Low Power ODR modes, defaults to LOWPOWER_21HZ.

  • blanking_time (Optional, int, templatable): Interrupt blanking time (in number of accelerometer samples), defaults to 0.

  • initial_pin_state (Required, int, templatable): Initial interrupt pin state: 0 for LOW, 1 for HIGH.

  • interrupt_pin (Required, enum, templatable): Interrupt pin to trigger WoM: INT1 or INT2.

  • threshold (Required, int, templatable): Absolute value (1-255) in mg to trigger interrupt pin. The smaller threshold - the less acceleration it is required to trigger WoM.

qmi8658.disable_wake_on_motion Action

Disable WoM functionality and allow consuming new data from sensor: see example above.

Configuration options:

  • id (Optional, ID): The ID of the qmi8658 sensor.

See Also