gpio.sensor.accelerometer

class platypush.plugins.gpio.sensor.accelerometer.GpioSensorAccelerometerPlugin(g=4, precision=None, **kwargs)[source]

Bases: GpioSensorPlugin

Plugin to interact with an accelerometer sensor and get X,Y,Z position. Tested with Adafruit LIS3DH accelerometer (https://www.adafruit.com/product/2809) with Raspberry Pi over I2C connection.

Requires:

  • Adafruit-GPIO (pip install Adafruit-GPIO)

__init__(g=4, precision=None, **kwargs)[source]

Only LIS3DH in I2C mode is currently supported: https://learn.adafruit.com/assets/59080.

Parameters:
  • g (int) – Accelerometer range as a multiple of G - can be 2G, 4G, 8G or 16G

  • precision (int) – If set, the position values will be rounded to the specified number of decimal digits (default: no rounding)

get_measurement()[source]

Extends GpioSensorPlugin.get_measurement()

Returns:

The sensor’s current position as a dictionary with the three components (x,y,z) in degrees, each between -90 and 90