Major restructure to follow ESPHome conventions for multi-interface components: Component Structure Changes: - Renamed lsm6ds/ to lsm6ds_base/ to follow _base naming convention - Created lsm6ds_i2c/ for I2C interface implementation - Created lsm6ds_spi/ for SPI interface implementation - Both interfaces use AUTO_LOAD to automatically include base component - Updated C++ namespaces to match component folder names (lsm6ds_base, lsm6ds_i2c, lsm6ds_spi) Features: - Support for LSM6DSOX, LSM6DS3TR-C, LSM6DSO32 variants - Full 3-axis accelerometer and gyroscope support - Temperature sensor support - Configurable ranges: Accel (2G-16G), Gyro (125-2000 DPS) - Configurable output data rate (12.5Hz - 6.66kHz) - Two usage patterns: all-in-one and hub+sensor platform Implementation Details: - Base component (lsm6ds_base) contains shared code and abstract LSM6DSComponent class - I2C variant implements LSM6DSI2CDevice with I2C read/write methods - SPI variant implements LSM6DSSPIDevice with SPI read/write methods (MSB-based protocol) - Both variants support optional sensor.py for hub+sensor pattern - Added README_EXAMPLE.md files with usage examples for both interfaces - Added component test files for validation Documentation: - Added COMPONENT_STRUCTURE.md explaining architecture and usage patterns - Included example configurations for both I2C and SPI - Documented all configuration options and sensor variants
2.2 KiB
2.2 KiB
LSM6DS I2C Example Configuration
This component supports LSM6DS family IMU sensors (accelerometer + gyroscope) via I2C interface.
Supported Sensors
- LSM6DSOX (WHO_AM_I: 0x6C, I2C address: 0x6A or 0x6B)
- LSM6DS3TR-C (WHO_AM_I: 0x6A, I2C address: 0x6A or 0x6B)
- LSM6DSO32 (WHO_AM_I: 0x69, I2C address: 0x6A or 0x6B)
Example 1: All-in-one Pattern
Configure the sensor with all outputs in the component block:
i2c:
- id: i2c_bus
sda: GPIO21
scl: GPIO22
scan: true
lsm6ds_i2c:
id: imu_sensor
i2c_id: i2c_bus
address: 0x6B
accel_range: 4G
gyro_range: 500DPS
accel_odr: 104HZ
gyro_odr: 104HZ
update_interval: 50ms
accel_x:
name: "Accel X"
accel_y:
name: "Accel Y"
accel_z:
name: "Accel Z"
gyro_x:
name: "Gyro X"
gyro_y:
name: "Gyro Y"
gyro_z:
name: "Gyro Z"
temperature:
name: "IMU Temperature"
Example 2: Hub + Sensor Platform Pattern
Configure the hub separately, then add sensor outputs under the sensor platform:
i2c:
- id: i2c_bus
sda: GPIO21
scl: GPIO22
scan: true
lsm6ds_i2c:
id: imu_hub
i2c_id: i2c_bus
address: 0x6B
accel_range: 4G
gyro_range: 500DPS
accel_odr: 104HZ
gyro_odr: 104HZ
update_interval: 50ms
sensor:
- platform: lsm6ds_i2c
lsm6ds_id: imu_hub
accel_x:
name: "Accel X"
accel_y:
name: "Accel Y"
accel_z:
name: "Accel Z"
gyro_x:
name: "Gyro X"
gyro_y:
name: "Gyro Y"
gyro_z:
name: "Gyro Z"
temperature:
name: "IMU Temperature"
Configuration Options
I2C Address
0x6A(default, SDO/SA0 pin LOW)0x6B(SDO/SA0 pin HIGH)
Accelerometer Range
2G(default)4G8G16G
Gyroscope Range
125DPS250DPS(default)500DPS1000DPS2000DPS
Output Data Rate (ODR)
12.5HZ26HZ52HZ104HZ(default)208HZ416HZ833HZ1660HZ3330HZ6660HZ
I2C Configuration
The LSM6DS I2C implementation uses standard I2C communication:
- Speed: Supports up to 400 kHz (Fast mode)
- 7-bit addressing: 0x6A or 0x6B depending on SDO/SA0 pin state
- Auto-increment: Multi-byte reads automatically increment register address
The component handles the I2C protocol automatically.