LIS3DH Accelerometer
The lis3dh motion platform allows you to use your LIS3DH 3-axis accelerometer
(datasheet)
with ESPHome. The I²C Bus is required to be set up in your
configuration for this sensor to work.
The LIS3DH is a low-power 3-axis accelerometer with selectable ±2/4/8/16 g
full-scale ranges and an on-chip temperature sensor. It also has a programmable
motion interrupt that can be wired to a GPIO and used as a wakeup_pin for the
Deep Sleep component to wake an ESP32 from deep sleep
when the device is moved.
# Example configuration entrymotion: - platform: lis3dh address: 0x18 accelerometer_range: 2G
sensor: - platform: lis3dh type: temperature name: "LIS3DH Temperature" - platform: motion type: acceleration_x name: "LIS3DH Accel X" - platform: motion type: roll name: "LIS3DH Roll"Configuration variables
Section titled “Configuration variables”-
address (Optional, int): Manually specify the I²C address of the sensor. Defaults to
0x18; on boards where the SDO/SA0 pin is tied high it is0x19. -
accelerometer_range (Optional, string): The full-scale range of the accelerometer. One of
2G,4G,8G,16G. Defaults to2G. A smaller range gives finer resolution; a larger range measures stronger accelerations. -
accelerometer_odr (Optional, string): The output data rate of the accelerometer. One of
1HZ,10HZ,25HZ,50HZ,100HZ,200HZ,400HZ,1620HZ,1344HZ. Defaults to100HZ.1620HZis only available inLOW_POWERmode, and1344HZbecomes 5376 Hz inLOW_POWERmode. -
operating_mode (Optional, string): Selects the resolution, which also affects power usage. One of
LOW_POWER(8-bit),NORMAL(10-bit),HIGH_RESOLUTION(12-bit). Defaults toHIGH_RESOLUTION. -
interrupt (Optional): Configure the on-chip motion (activity) interrupt. When present, the LIS3DH drives one of its physical INT pads whenever the acceleration crosses the threshold. See Motion wake-up below.
- pin (Optional, string): Which physical interrupt pad to drive,
INT1orINT2. Defaults toINT1. - threshold (Optional, acceleration): The acceleration above which the interrupt fires. Defaults to
1.1g. By default this is compared against the total measured acceleration, which always includes the ~1 g of gravity, so it must be set above1g. Enablehigh_pass_filterto compare against the change in acceleration instead, which allows much smaller values. - duration (Optional, int): The number of consecutive samples (in output-data-rate periods) the
threshold must be exceeded before the interrupt fires. Defaults to
0. Range0to127. - axes (Optional, list): Which axes may trigger the interrupt, any of
x,y,z. Defaults to all three. - latched (Optional, boolean): If
true, the interrupt stays asserted until the interrupt source register is read (which happens automatically on the next boot). Iffalse, the pad follows the motion. Defaults totrue. For deep-sleep wake-up,falseis often preferable so the device can return to sleep once movement stops. - active_high (Optional, boolean): The polarity of the interrupt pad.
true= the pad goes high when the interrupt is active,false= it goes low. Defaults totrue. - high_pass_filter (Optional, boolean): Apply the high-pass filter to the interrupt so the standing
gravity component is removed from the threshold comparison, letting you use a small threshold (the change
in acceleration). The reported acceleration values are not affected. Defaults to
false.
- pin (Optional, string): Which physical interrupt pad to drive,
-
All other options from Motion.
Motion wake-up
Section titled “Motion wake-up”The motion interrupt can wake an ESP32 from deep sleep. Wire the selected INT pad to a GPIO and point the
Deep Sleep component’s wakeup_pin at it. The accelerometer keeps sampling on its
own while the ESP is asleep, so any movement above the threshold pulls the pin and wakes the device.
# Wire the LIS3DH INT1 pad to GPIO4motion: - platform: lis3dh operating_mode: LOW_POWER accelerometer_odr: 50HZ interrupt: pin: INT1 threshold: 0.2g high_pass_filter: true # remove gravity so a small threshold works latched: false # follow the motion so the device can sleep again
deep_sleep: run_duration: 30s wakeup_pin: GPIO4 # active-high by default; matches active_high: true