-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
[motion] Document motion hub component and sensors #6568
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
clydebarrow
wants to merge
26
commits into
esphome:next
Choose a base branch
from
clydebarrow:motion
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
646a0d4
[bmi270] Document new component
clydebarrow 13fa5d7
Clarify headings; add dark_invert
clydebarrow 31c7572
Add axis_map docs
clydebarrow 1001017
Restructure
clydebarrow 60b9684
Merge branch 'next' of https://github.com/esphome/esphome-docs into b…
clydebarrow f27a073
Merge branch 'motion' into bmi270
clydebarrow bb60ff9
Update bmi270
clydebarrow 3ac8a49
[lsm6ds3] Document new motion component
clydebarrow 1db42a9
Fix config examples
clydebarrow 066976b
Add OFF as a data rate option
clydebarrow 937aa4c
Merge branch 'next' of https://github.com/esphome/esphome-docs into m…
clydebarrow 1771e17
Add calibration docs
clydebarrow b2d5f60
Merge branch 'next' of https://github.com/esphome/esphome-docs into m…
clydebarrow e2609d3
[lvgl] Document `rounded` property for meter arcs
clydebarrow f8254dc
Remove unrelated change
clydebarrow a1e4f57
Fix indent
clydebarrow 559da45
Merge branch 'next' of https://github.com/esphome/esphome.io into motion
clydebarrow abf8928
Remove redundant import
clydebarrow 19e5068
Add image
clydebarrow f19bd4b
Convert image
clydebarrow d695fab
Merge branch 'next' of https://github.com/esphome/esphome.io into motion
clydebarrow 52f72b0
Merge branch 'motion' into bmi270
clydebarrow 8b23930
Merge branch 'next' of https://github.com/esphome/esphome.io into lsd…
clydebarrow 7158cf7
Merge branch 'motion' into lsdm6ds3
clydebarrow fb406a1
Merge branch 'lsdm6ds3' into motion
clydebarrow d138b5a
Add link; fix image
clydebarrow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| --- | ||
| description: "Instructions for setting up BMI270 Accelerometer/Gyroscope sensors." | ||
| title: "BMI270 Accelerometer/Gyroscope Sensor" | ||
| --- | ||
|
|
||
| import APIRef from '@components/APIRef.astro'; | ||
|
|
||
| The `bmi270` motion platform allows you to use your BMI270 Accelerometer/Gyroscope | ||
| ([datasheet](https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bmi270-ds000.pdf)) | ||
| sensors with ESPHome. The [I²C Bus](/components/i2c) is required to be set up in | ||
| your configuration for this sensor to work. | ||
|
|
||
| The BMI270 is an ultra-low-power IMU optimized for wearable applications. It includes | ||
| a 16-bit 3-axis accelerometer and a 16-bit 3-axis gyroscope, plus an on-chip temperature | ||
| sensor. It requires an internal configuration blob to be uploaded at each power-on | ||
| (handled automatically by this component). | ||
|
|
||
| ```yaml | ||
| # Example configuration entry | ||
| motion: | ||
| - platform: bmi270 | ||
| accelerometer_range: 4G | ||
| gyroscope_range: 2000DPS | ||
|
|
||
| sensor: | ||
| - platform: motion | ||
| type: acceleration_x | ||
| name: "BMI270 Accel X" | ||
| - platform: motion | ||
| type: gyroscope_x | ||
| name: "BMI270 Gyro X" | ||
| - platform: motion | ||
| type: roll | ||
| name: "BMI270 Roll" | ||
| ``` | ||
|
|
||
| ## Configuration variables | ||
|
|
||
| - **address** (*Optional*, int): Manually specify the I²C address of the sensor. Defaults to `0x68`. | ||
| The BMI270 supports `0x68` (SDO to GND) and `0x69` (SDO to VDDIO). | ||
| - **accelerometer_range** (*Optional*, string): The full-scale range of the accelerometer. One of | ||
| `2G`, `4G`, `8G`, `16G`. Defaults to `4G`. | ||
| - **accelerometer_odr** (*Optional*, string): The output data rate of the accelerometer. One of | ||
| `12_5HZ`, `25HZ`, `50HZ`, `100HZ`, `200HZ`, `400HZ`, `800HZ`, `1600HZ`. Defaults to `100HZ`. | ||
| - **gyroscope_range** (*Optional*, string): The full-scale range of the gyroscope. One of | ||
| `125DPS`, `250DPS`, `500DPS`, `1000DPS`, `2000DPS`. Defaults to `2000DPS`. | ||
| - **gyroscope_odr** (*Optional*, string): The output data rate of the gyroscope. One of | ||
| `25HZ`, `50HZ`, `100HZ`, `200HZ`, `400HZ`, `800HZ`, `1600HZ`, `3200HZ`. Defaults to `200HZ`. | ||
|
|
||
| - All other options from [Motion](/components/motion). | ||
|
|
||
| ## See Also | ||
|
|
||
| - [BMI270 Temperature Sensor](/components/sensor/bmi270/) | ||
| - <APIRef text="bmi270.h" path="bmi270/bmi270.h" /> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,198 @@ | ||
| --- | ||
| description: "Instructions for setting up Accelerometer/Gyroscope components." | ||
| title: "Motion Component (IMU)" | ||
| --- | ||
|
|
||
| import APIRef from '@components/APIRef.astro'; | ||
| import Figure from '@components/Figure.astro'; | ||
| import calibrationImg from './images/calibrate.jpg'; | ||
|
|
||
| The `motion` hub component allows you to define sensors that read data from inertial measurement units (IMUs) | ||
| such as accelerometers and gyroscopes. Not all IMU chips support all types of measurements, see the individual platform | ||
| documentation for details. | ||
|
clydebarrow marked this conversation as resolved.
|
||
|
|
||
| ```yaml | ||
| # Example configuration entry | ||
| motion: | ||
| - platform: ... | ||
| acceleration_range: 4G # Platform dependent options here | ||
|
|
||
| sensor: | ||
| - platform: motion | ||
| type: acceleration_x | ||
| name: "Accel X" | ||
| - platform: motion | ||
| type: angular_rate_x | ||
| name: "Gyro X" | ||
| - platform: motion | ||
| type: pitch | ||
| name: "Pitch Angle" | ||
| ``` | ||
|
|
||
| ## Configuration variables | ||
|
|
||
| ### Base configuration | ||
|
|
||
| - **axis_map** (*Optional*, mapping): Remap or invert the physical axes of the sensor to match | ||
| your board orientation. Each key (`x`, `y`, `z`) maps to the physical axis it should read from, | ||
| optionally prefixed with `-` to invert. All three axes must be present and each physical axis | ||
| may only appear once. Mutually exclusive with `transform_matrix`. | ||
|
|
||
| ```yaml | ||
| # Example: swap X and Y, invert Z | ||
| motion: | ||
| - platform: ... | ||
| axis_map: | ||
| x: y | ||
| y: x | ||
| z: "-z" | ||
| ``` | ||
|
|
||
| - **transform_matrix** (*Optional*, list of floats): A 3×3 transformation matrix applied to | ||
| raw accelerometer and gyroscope readings. This allows arbitrary calibration beyond simple | ||
| axis remapping. Can be specified as a flat list of 9 values (row-major order) or as a | ||
| 3×3 nested list. Mutually exclusive with `axis_map`. | ||
|
|
||
| ```yaml | ||
| # Example: 3x3 nested format | ||
| motion: | ||
| - platform: ... | ||
| transform_matrix: | ||
| - [0.998, 0.010, -0.050] | ||
| - [-0.010, 0.999, 0.020] | ||
| - [0.050, -0.020, 0.998] | ||
| ``` | ||
|
|
||
| ```yaml | ||
| # Example: flat format | ||
| motion: | ||
| - platform: ... | ||
| transform_matrix: [0.998, 0.010, -0.050, -0.010, 0.999, 0.020, 0.050, -0.020, 0.998] | ||
| ``` | ||
|
|
||
| The matrix can be obtained from the runtime calibration actions described below — after | ||
| calibration the computed matrix is logged in a format that can be copied directly into | ||
| your configuration for persistent use. | ||
|
|
||
| - **update_interval** (*Optional*, [Time](/guides/configuration-types#time)): The interval at which | ||
| sensor data is read. Defaults to `250ms`. | ||
| - **id** (*Optional*, [ID](/guides/configuration-types#id)): Manually specify the ID used for code generation. | ||
|
|
||
| ### Sensor configuration | ||
|
|
||
| - **type** (**Required**, string): The type of measurement to expose. One of: | ||
| - `acceleration_x`: X-axis acceleration in `g`. | ||
| - `acceleration_y`: Y-axis acceleration in `g`. | ||
| - `acceleration_z`: Z-axis acceleration in `g`. | ||
| - `angular_rate_x`: X-axis angular velocity in `°/s`. | ||
| - `angular_rate_y`: Y-axis angular velocity in `°/s`. | ||
| - `angular_rate_z`: Z-axis angular velocity in `°/s`. | ||
| - `gyroscope_x`: Synonym for `angular_rate_x`. | ||
| - `gyroscope_y`: Synonym for `angular_rate_y`. | ||
| - `gyroscope_z`: Synonym for `angular_rate_z`. | ||
| - `pitch`: Pitch angle in `°`. | ||
| - `roll`: Roll angle in `°`. | ||
| - All other options from [Sensor](/components/sensor). | ||
|
|
||
| ## Actions | ||
|
|
||
| ### `motion.calibrate_level` Action | ||
|
|
||
| This [action](/automations/actions#all-actions) computes a calibration matrix so that the | ||
| current accelerometer reading maps to `[0, 0, 1]` (device flat, Z pointing up). Place the | ||
| device on a level surface and trigger this action. It replaces the current `transform_matrix`. | ||
|
|
||
| - **save** (*Optional*, boolean): Save the resulting matrix to NVS flash so it is | ||
| automatically restored on the next boot. Defaults to `false`. | ||
| - **on_success** (*Optional*, [Automation](/automations/actions)): Actions to run when calibration succeeds. | ||
| - **on_error** (*Optional*, [Automation](/automations/actions)): Actions to run when calibration fails | ||
| (e.g. sensor read failure or insufficient tilt). | ||
|
|
||
| ```yaml | ||
| on_...: | ||
| then: | ||
| - motion.calibrate_level: | ||
| id: my_motion | ||
| save: true | ||
| on_success: | ||
| - logger.log: "Level calibration succeeded" | ||
| on_error: | ||
| - logger.log: "Level calibration failed" | ||
| ``` | ||
|
|
||
| After execution the resulting matrix is logged at INFO level in a format that can be | ||
| copied into the `transform_matrix` configuration for persistent calibration. | ||
|
|
||
| ### `motion.calibrate_heading` Action | ||
|
|
||
| This [action](/automations/actions#all-actions) corrects the heading (rotation around Z) | ||
| after a prior level calibration. Tilt the device around its Y axis only (pitch forward or | ||
| backward) and trigger this action. It composes a Z-rotation correction with the existing | ||
| matrix so that the horizontal acceleration component falls entirely on the X axis, with its | ||
| sign preserved. | ||
|
|
||
| - **save** (*Optional*, boolean): Save the resulting matrix to NVS flash. Defaults to `false`. | ||
| - **on_success** (*Optional*, [Automation](/automations/actions)): Actions to run when calibration succeeds. | ||
| - **on_error** (*Optional*, [Automation](/automations/actions)): Actions to run when calibration fails. | ||
|
|
||
| ```yaml | ||
| on_...: | ||
| then: | ||
| - motion.calibrate_heading: | ||
| id: my_motion | ||
| save: true | ||
| on_success: | ||
| - logger.log: "Heading calibration succeeded" | ||
| ``` | ||
|
|
||
| ### `motion.clear_calibration` Action | ||
|
|
||
| This [action](/automations/actions#all-actions) discards any runtime calibration and restores | ||
| the build-time matrix defined by `axis_map` or `transform_matrix` (or the identity matrix if | ||
| neither is configured). Use it to undo a `motion.calibrate_level` / `motion.calibrate_heading` | ||
| sequence without re-flashing. | ||
|
|
||
| - **save** (*Optional*, boolean): Also clear the saved calibration in NVS flash so the reset | ||
| persists across reboots. Defaults to `false`. When `false`, the in-memory matrix is reset but | ||
| a previously saved calibration will be restored again on the next boot. | ||
|
|
||
| ```yaml | ||
| on_...: | ||
| then: | ||
| - motion.clear_calibration: | ||
| id: my_motion | ||
| save: true | ||
| ``` | ||
|
|
||
| ### Calibration persistence | ||
|
|
||
| When a calibration action is run with `save: true`, the resulting matrix is stored in NVS flash | ||
| and automatically restored on the next boot, taking precedence over the `axis_map` / | ||
| `transform_matrix` configuration. The saved calibration is tied to the configured base matrix: | ||
| if you change `axis_map` or `transform_matrix` and re-flash, the stale saved calibration is | ||
| automatically discarded and the new configuration is used. To explicitly return to the | ||
| configured base at runtime, use `motion.clear_calibration`. | ||
|
|
||
| ### Calibration procedure | ||
|
|
||
| 1. Place the device on a flat, level surface. | ||
| 2. Trigger `motion.calibrate_level`. This aligns Z with gravity. | ||
| 3. Tilt the device around the Y axis only (e.g. prop one edge up along the X direction). | ||
| 4. Trigger `motion.calibrate_heading`. This fixes the X/Y heading. | ||
|
|
||
| The new calibration matrix is now active and can be saved to flash if desired. | ||
| If you have a way to monitor the logs, you can verify that the calibration succeeded by checking for an INFO log | ||
| entry with the resulting matrix in a format suitable for copy-pasting into your configuration. | ||
|
|
||
| <Figure | ||
| src={calibrationImg} | ||
| alt="Device being calibrated" | ||
| caption="Device Calibration" | ||
| /> | ||
|
|
||
| ## See Also | ||
|
|
||
| - [Sensor Filters](/components/sensor#sensor-filters) | ||
| - [BMI270 Accelerometer/Gyroscope platform](/components/motion/bmi270/) | ||
| - [LSM6DS3 Accelerometer/Gyroscope platform](/components/motion/lsm6ds3/) | ||
| - <APIRef text="motion_component.h" path="motion/motion_component.h" /> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| --- | ||
| description: "Instructions for setting up LSM6DS3 Accelerometer/Gyroscope sensors." | ||
| title: "LSM6DS3 Accelerometer/Gyroscope Sensor" | ||
| --- | ||
|
|
||
| import APIRef from '@components/APIRef.astro'; | ||
|
|
||
| The `lsm6ds3` motion platform allows you to use your LSM6DS3 Accelerometer/Gyroscope | ||
| ([datasheet](https://www.st.com/resource/en/datasheet/lsm6ds3tr-c.pdf)) | ||
| sensors with ESPHome. The [I²C Bus](/components/i2c) is required to be set up in | ||
| your configuration for this sensor to work. | ||
|
|
||
| The LSM6DS3 is an IMU including a 16-bit 3-axis accelerometer and a 16-bit 3-axis gyroscope, plus an on-chip temperature sensor. | ||
|
|
||
| ```yaml | ||
| # Example configuration entry | ||
| motion: | ||
| - platform: lsm6ds3 | ||
| accelerometer_range: 4G | ||
| gyroscope_range: 2000DPS | ||
|
|
||
| sensor: | ||
| - platform: motion | ||
| type: acceleration_x | ||
| name: "LSM6DS3 Accel X" | ||
| - platform: motion | ||
| type: gyroscope_x | ||
| name: "LSM6DS3 Gyro X" | ||
| - platform: motion | ||
| type: roll | ||
| name: "LSM6DS3 Roll" | ||
| ``` | ||
|
|
||
| ## Configuration variables | ||
|
|
||
| - **address** (*Optional*, int): Manually specify the I²C address of the sensor. Defaults to `0x6A`. | ||
| - **accelerometer_range** (*Optional*, string): The full-scale range of the accelerometer. One of | ||
| `2G`, `4G`, `8G`, `16G`. Defaults to `4G`. | ||
| - **accelerometer_odr** (*Optional*, string): The output data rate of the accelerometer. One of | ||
| `OFF`, `12_5HZ`, `26HZ`, `52HZ`, `104HZ`, `208HZ`, `416HZ`, `833HZ`, `1666HZ`, `3332HZ`, `6664HZ`. Defaults to `104HZ`. | ||
| - **gyroscope_range** (*Optional*, string): The full-scale range of the gyroscope. One of | ||
| `125DPS`, `250DPS`, `500DPS`, `1000DPS`, `2000DPS`. Defaults to `2000DPS`. | ||
| - **gyroscope_odr** (*Optional*, string): The output data rate of the gyroscope. One of | ||
| `OFF`, `12_5HZ`, `26HZ`, `52HZ`, `104HZ`, `208HZ`, `416HZ`, `833HZ`, `1666HZ`, `3332HZ`, `6664HZ`. Defaults to `208HZ`. | ||
|
|
||
| - All other options from [Motion](/components/motion). | ||
|
|
||
| ## See Also | ||
|
|
||
| - [LSM6DS3 Temperature Sensor](/components/sensor/lsm6ds3/) | ||
| - <APIRef text="lsm6ds3.h" path="lsm6ds3/lsm6ds3.h" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| --- | ||
| description: "Instructions for setting up BMI270 temperature sensor." | ||
| title: "BMI270 Temperature Sensor" | ||
| --- | ||
|
|
||
| The `bmi270` sensor platform provides access to the temperature sensor in a BMI270 Accelerometer/Gyroscope | ||
| ([datasheet](https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bmi270-ds000.pdf)) with ESPHome. | ||
| It requires a [`motion`](/components/motion) component to be configured with the `bmi270` platform, | ||
| which handles the accelerometer and gyroscope data processing and configures the device. See that component for more information. | ||
|
|
||
| ```yaml | ||
| # Example configuration entry | ||
| motion: | ||
| - platform: bmi270 | ||
|
|
||
| sensor: | ||
| - platform: bmi270 | ||
| type: temperature # Optional, temperature is the only supported type for this platform | ||
| name: "BMI270 Temperature" | ||
| ``` | ||
|
|
||
| ## Configuration variables | ||
|
|
||
| - **type** (*Optional*, string): Must be set to `temperature`, or simply omitted. | ||
| - All other options from [Sensor](/components/sensor). | ||
|
|
||
| ## See Also | ||
|
|
||
| - [Sensor Filters](/components/sensor#sensor-filters) | ||
| - [BMI270 Accelerometer/Gyroscope platform](/components/motion/bmi270/) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.