UPM

The UPM API is a high level sensor library for IoT devices using MRAA. See examples here. Back to index page.
SparkFun sensor images provided under CC BY-NC-SA-3.0.

L3GD20 Class

Module: l3gd20

The L3GD20 The L3GD20 is a low-power three-axis angular rate sensor. This driver supports IIO and I2C modes. Some methods will only work in one mode or the other. See the documentation on the methods to determine whether a given method is operation in a given mode. Both the I2C and IIO mechanisms make use of the calibration and denoise algorithms.
For I2C mode, not all capabilities of the device are supported, but a complete register map and low level read/write methods are provided to add any missing functionality.
Example using IIO Example using I2C

Item Index

Properties

Methods

L3GD20

(
  • device
)
Number

L3GD20 Tri-axis Digital Gyroscope Contructor for IIO operation

Parameters:

  • device Number

    iio device number

Returns:

Number:

L3GD20

(
  • bus
  • addr
)
Number

L3GD20 Tri-axis Digital Gyroscope Contructor for I2C operation

Parameters:

  • bus Number

    i2c bus

  • addr Number

    I2C address

Returns:

Number:

getChipID

() Number

Return the chip ID. I2C only.

Returns:

Number:

The chip ID (L3GD20_DEFAULT_CHIP_ID).

getGyroscope

(
  • x
  • y
  • z
)

Return gyroscope data in radians per second. update() must have been called prior to calling this method. I2C only.

Parameters:

  • x Float *

    Pointer to a floating point value that will have the current x component placed into it.

  • y Float *

    Pointer to a floating point value that will have the current y component placed into it.

  • z Float *

    Pointer to a floating point value that will have the current z component placed into it.

setPowerMode

(
  • mode
)

Set the power mode of the device. I2C only.

Parameters:

  • mode POWER_MODES_T

    One of the POWER_MODES_T values.

setRange

(
  • range
)

Set the gyroscope detection scaling range. This device supports 250, 500 and 2000 degree/s ranges. I2C only.

Parameters:

  • range FS_T

    One of the FS_T values.

update

()

Update the internal stored values from sensor data. This method must be called before querying any data ( getTemperature() and getGyroscope() ). I2C only.

getTemperature

(
  • fahrenheit
)
Number

Return the current measured temperature. Note, this is not ambient temperature. update() must have been called prior to calling this method. I2C only.

Parameters:

  • fahrenheit Boolean

    true to return data in Fahrenheit, false for Celicus. Celsius is the default.

Returns:

Number:

The temperature in degrees Celsius or Fahrenheit.

setODR

(
  • odr
)

Set the output data rate and cut off frequency of the device. I2C only.

Parameters:

  • odr ODR_CUTOFF_T

    One of the ODR_CUTOFF_T values.

enableBDU

(
  • enable
)

Enable or disable Block Data Update. When enabled, this ensures that LSB's or MSB's of a given axis are not being updated while the other is being read. This is enabled by default. I2C only.

Parameters:

  • enable Boolean

    true to enable, false to disable

getStatusBits

() Number

Return the bitfields of the Status register. This register provides information on the status of data gathering. I2C only.

Returns:

Number:

The contents of the REG_STATUS_REG register.

installISR

(
  • isr
  • arg
)

Installs an interrupt service routine (ISR) to be called when an interrupt occurs. IIO only.

Parameters:

  • isr Void()(char *, void *)

    Pointer to a function to be called on interrupt

  • arg Void *

    Pointer to an object to be supplied as an argument to the ISR.

getChannelValue

(
  • input
  • chan
)
Number

Extract the channel value based on channel type. IIO only.

Parameters:

  • input String

    Channel data

  • chan Mraa_iio_channel *

    MRAA iio-layer channel info

Returns:

Number:

enableBuffer

(
  • length
)
Boolean

Enable trigger buffer. IIO only.

Parameters:

  • length Number

    buffer length in integer

Returns:

Boolean:

disableBuffer

() Boolean

Disable trigger buffer. IIO only.

Returns:

Boolean:

setScale

(
  • scale
)
Boolean

Set scale. IIO only. For I2C operation, use setRange() with the appropriate FS_T value.

Parameters:

  • scale Number

    in float Available scales are 0.000153(250dps), 0.000305(500dps), and 0.001222(2000dps) Default scale is 0.000153

Returns:

Boolean:

setSamplingFrequency

(
  • sampling_frequency
)
Boolean

Set sampling frequency. IIO only. For I2C operation, use the setODR() method with the appropriate ODR_CUTOFF_T value.

Parameters:

  • sampling_frequency Number

    sampling frequency in float Available sampling frequency are 95, 190, 380, and 760 Default sampling frequency is 95

Returns:

Boolean:

enable3AxisChannel

() Boolean

Enable 3 axis scan element. IIO only.

Returns:

Boolean:

extract3Axis

(
  • data
  • x
  • y
  • z
)
Boolean

Process enabled channel buffer and return x, y, z axis. IIO only.

Parameters:

  • data String

    Enabled channel data, 6 bytes, each axis 2 bytes

  • x Float *

    X-Axis

  • y Float *

    Y-Axis

  • z Float *

    Z-Axis

Returns:

Boolean:

initCalibrate

()

Reset calibration data and start collect calibration data again

getCalibratedStatus

() Boolean

Get calibrated status, return true if calibrate successfully

Returns:

Boolean:

getCalibratedData

(
  • bias_x
  • bias_y
  • bias_z
)

Get calibrated data

Parameters:

  • bias_x Float *

    undefined

  • bias_y Float *

    undefined

  • bias_z Float *

    undefined

loadCalibratedData

(
  • bias_x
  • bias_y
  • bias_z
)

Load calibrated data

Parameters:

  • bias_x Number

    undefined

  • bias_y Number

    undefined

  • bias_z Number

    undefined

readReg

(
  • reg
)
Number

Read a register. I2C mode only.

Parameters:

  • reg Number

    The register to read.

Returns:

Number:

The value of the register.

readRegs

(
  • reg
  • buffer
  • len
)
Number

Read contiguous registers into a buffer. I2C mode only.

Parameters:

  • reg Number

    undefined

  • buffer Uint8_t *

    The buffer to store the results.

  • len Number

    The number of registers to read.

Returns:

Number:

The number of bytes read.

writeReg

(
  • reg
  • val
)

Write to a register. I2C mode only.

Parameters:

  • reg Number

    The register to write to.

  • val Number

    The value to write.

gyroCollect

(
  • x
  • y
  • z
)
Boolean

Calibrate gyro

Parameters:

  • x Number

    X-Axis

  • y Number

    Y-Axis

  • z Number

    Z-Axis

Returns:

Boolean:

gyroDenoiseMedian

(
  • x
  • y
  • z
)

Denoise gyro

Parameters:

  • x Float *

    X-Axis

  • y Float *

    Y-Axis

  • z Float *

    Z-Axis

median

(
  • queue
  • size
)
Number

median algorithm

Parameters:

  • queue Float *
  • size Number

Returns:

Number:

partition

(
  • list
  • left
  • right
  • pivot_index
)
Number

partition algorithm

Parameters:

  • list Float *
  • left Number
  • right Number
  • pivot_index Number

Returns:

Number:

clampGyroReadingsToZero

(
  • x
  • y
  • z
)

Clamp Gyro Readings to Zero

Parameters:

  • x Float *

    X-Axis

  • y Float *

    Y-Axis

  • z Float *

    Z-Axis

Properties

REG_WHO_AM_I

Enum L3GD20_REGS_T

REG_CTRL_REG1

Enum L3GD20_REGS_T

REG_CTRL_REG2

Enum L3GD20_REGS_T

REG_CTRL_REG3

Enum L3GD20_REGS_T

REG_CTRL_REG4

Enum L3GD20_REGS_T

REG_CTRL_REG5

Enum L3GD20_REGS_T

REG_REFERENCE

Enum L3GD20_REGS_T

REG_OUT_TEMPERATURE

Enum L3GD20_REGS_T

REG_STATUS_REG

Enum L3GD20_REGS_T

REG_OUT_X_L

Enum L3GD20_REGS_T

REG_OUT_X_H

Enum L3GD20_REGS_T

REG_OUT_Y_L

Enum L3GD20_REGS_T

REG_OUT_Y_H

Enum L3GD20_REGS_T

REG_OUT_Z_L

Enum L3GD20_REGS_T

REG_OUT_Z_H

Enum L3GD20_REGS_T

REG_FIFO_CTRL_REG

Enum L3GD20_REGS_T

REG_FIFO_SRC_REG

Enum L3GD20_REGS_T

REG_INT1_CFG

Enum L3GD20_REGS_T

REG_INT1_SRC

Enum L3GD20_REGS_T

REG_INT1_TSH_XH

Enum L3GD20_REGS_T

REG_INT1_TSH_XL

Enum L3GD20_REGS_T

REG_INT1_TSH_YH

Enum L3GD20_REGS_T

REG_INT1_TSH_YL

Enum L3GD20_REGS_T

REG_INT1_TSH_ZH

Enum L3GD20_REGS_T

REG_INT1_TSH_ZL

Enum L3GD20_REGS_T

REG_INT1_DURATION

Enum L3GD20_REGS_T

CTRL_REG1_YEN

Enum CTRL_REG1_BITS_T

CTRL_REG1_XEN

Enum CTRL_REG1_BITS_T

CTRL_REG1_ZEN

Enum CTRL_REG1_BITS_T

CTRL_REG1_PD

Enum CTRL_REG1_BITS_T

CTRL_REG1_BW0

Enum CTRL_REG1_BITS_T

CTRL_REG1_BW1

Enum CTRL_REG1_BITS_T

_CTRL_REG1_BW_MASK

Enum CTRL_REG1_BITS_T

_CTRL_REG1_BW_SHIFT

Enum CTRL_REG1_BITS_T

CTRL_REG1_DR0

Enum CTRL_REG1_BITS_T

CTRL_REG1_DR1

Enum CTRL_REG1_BITS_T

_CTRL_REG1_DR_MASK

Enum CTRL_REG1_BITS_T

_CTRL_REG1_DR_SHIFT

Enum CTRL_REG1_BITS_T

_CTRL_REG1_ODR_CUTOFF0

Enum CTRL_REG1_BITS_T

_CTRL_REG1_ODR_CUTOFF1

Enum CTRL_REG1_BITS_T

_CTRL_REG1_ODR_CUTOFF2

Enum CTRL_REG1_BITS_T

_CTRL_REG1_ODR_CUTOFF3

Enum CTRL_REG1_BITS_T

_CTRL_REG1_ODR_CUTOFF_MASK

Enum CTRL_REG1_BITS_T

_CTRL_REG1_ODR_CUTOFF_SHIFT

Enum CTRL_REG1_BITS_T

ODR_CUTOFF_95_12_5

Enum ODR_CUTOFF_T

ODR_CUTOFF_95_25

Enum ODR_CUTOFF_T

ODR_CUTOFF_190_12_5

Enum ODR_CUTOFF_T

ODR_CUTOFF_190_25

Enum ODR_CUTOFF_T

ODR_CUTOFF_190_50

Enum ODR_CUTOFF_T

ODR_CUTOFF_190_70

Enum ODR_CUTOFF_T

ODR_CUTOFF_380_20

Enum ODR_CUTOFF_T

ODR_CUTOFF_380_25

Enum ODR_CUTOFF_T

ODR_CUTOFF_380_50

Enum ODR_CUTOFF_T

ODR_CUTOFF_380_100

Enum ODR_CUTOFF_T

ODR_CUTOFF_760_30

Enum ODR_CUTOFF_T

ODR_CUTOFF_760_35

Enum ODR_CUTOFF_T

ODR_CUTOFF_760_50

Enum ODR_CUTOFF_T

ODR_CUTOFF_760_100

Enum ODR_CUTOFF_T

POWER_DOWN

Enum POWER_MODES_T

POWER_SLEEP

Enum POWER_MODES_T

POWER_NORMAL

Enum POWER_MODES_T

_CTRL_REG2_RESERVED_BITS

Enum CTRL_REG2_BITS_T

CTRL_REG2_HPCF0

Enum CTRL_REG2_BITS_T

CTRL_REG2_HPCF1

Enum CTRL_REG2_BITS_T

CTRL_REG2_HPCF2

Enum CTRL_REG2_BITS_T

CTRL_REG2_HPCF3

Enum CTRL_REG2_BITS_T

_CTRL_REG2_HPCF_MASK

Enum CTRL_REG2_BITS_T

_CTRL_REG2_HPCF_SHIFT

Enum CTRL_REG2_BITS_T

CTRL_REG2_HPM0

Enum CTRL_REG2_BITS_T

CTRL_REG2_HPM1

Enum CTRL_REG2_BITS_T

_CTRL_REG2_HPM_MASK

Enum CTRL_REG2_BITS_T

_CTRL_REG2_HPM_SHIFT

Enum CTRL_REG2_BITS_T

HPCF_7_2

Enum HPCF_T

HPCF_3_5

Enum HPCF_T

HPCF_1_8

Enum HPCF_T

HPCF_0_9

Enum HPCF_T

HPCF_0_45

Enum HPCF_T

HPCF_0_18

Enum HPCF_T

HPCF_0_09

Enum HPCF_T

HPCF_0_045

Enum HPCF_T

HPCF_0_018

Enum HPCF_T

HPCF_0_009

Enum HPCF_T

HPM_NORMAL_RESET_FILTER

Enum HPM_T

HPM_REFERENCE_SIGNAL

Enum HPM_T

HPM_NORMAL

Enum HPM_T

HPM_AUTORESET_ON_INT

Enum HPM_T

CTRL_REG3_I2_EMPTY

Enum CTRL_REG3_BITS_T

CTRL_REG3_I2_ORUN

Enum CTRL_REG3_BITS_T

CTRL_REG3_I2_WTM

Enum CTRL_REG3_BITS_T

CTRL_REG3_I2_DRDY

Enum CTRL_REG3_BITS_T

CTRL_REG3_PP_OD

Enum CTRL_REG3_BITS_T

CTRL_REG3_H_LACTIVE

Enum CTRL_REG3_BITS_T

CTRL_REG3_I1_BOOT

Enum CTRL_REG3_BITS_T

CTRL_REG3_I1_INT1

Enum CTRL_REG3_BITS_T

_CTRL_REG4_RESERVED_BITS

Enum CTRL_REG4_BITS_T

CTRL_REG4_SIM

Enum CTRL_REG4_BITS_T

CTRL_REG4_FS0

Enum CTRL_REG4_BITS_T

CTRL_REG4_FS1

Enum CTRL_REG4_BITS_T

_CTRL_REG4_FS_MASK

Enum CTRL_REG4_BITS_T

_CTRL_REG4_FS_SHIFT

Enum CTRL_REG4_BITS_T

CTRL_REG4_BLE

Enum CTRL_REG4_BITS_T

CTRL_REG4_BDU

Enum CTRL_REG4_BITS_T

FS_250

Enum FS_T

FS_500

Enum FS_T

FS_2000

Enum FS_T

_CTRL_REG5_RESERVED_BITS

Enum CTRL_REG5_BITS_T

CTRL_REG5_OUT_SEL0

Enum CTRL_REG5_BITS_T

CTRL_REG5_OUT_SEL1

Enum CTRL_REG5_BITS_T

_CTRL_REG5_OUT_SEL_MASK

Enum CTRL_REG5_BITS_T

_CTRL_REG5_OUT_SEL_SHIFT

Enum CTRL_REG5_BITS_T

CTRL_REG5_INT1_SEL0

Enum CTRL_REG5_BITS_T

CTRL_REG5_INT1_SEL1

Enum CTRL_REG5_BITS_T

_CTRL_REG5_INT1_SEL_MASK

Enum CTRL_REG5_BITS_T

_CTRL_REG5_INT1_SEL_SHIFT

Enum CTRL_REG5_BITS_T

CTRL_REG5_HPEN

Enum CTRL_REG5_BITS_T

CTRL_REG5_FIFO_EN

Enum CTRL_REG5_BITS_T

CTRL_REG5_BOOT

Enum CTRL_REG5_BITS_T

STATUS_REG_XDA

Enum STATUS_REG_BITS_T

STATUS_REG_YDA

Enum STATUS_REG_BITS_T

STATUS_REG_ZDA

Enum STATUS_REG_BITS_T

STATUS_REG_ZYXDA

Enum STATUS_REG_BITS_T

STATUS_REG_XOR

Enum STATUS_REG_BITS_T

STATUS_REG_YOR

Enum STATUS_REG_BITS_T

STATUS_REG_ZOR

Enum STATUS_REG_BITS_T

STATUS_REG_ZYXOR

Enum STATUS_REG_BITS_T

FIFO_CTRL_REG_WTM0

Enum FIFO_CTRL_REG_BITS_T

FIFO_CTRL_REG_WTM1

Enum FIFO_CTRL_REG_BITS_T

FIFO_CTRL_REG_WTM2

Enum FIFO_CTRL_REG_BITS_T

FIFO_CTRL_REG_WTM3

Enum FIFO_CTRL_REG_BITS_T

FIFO_CTRL_REG_WTM4

Enum FIFO_CTRL_REG_BITS_T

_FIFO_CTRL_REG_WTM_MASK

Enum FIFO_CTRL_REG_BITS_T

_FIFO_CTRL_REG_WTM_SHIFT

Enum FIFO_CTRL_REG_BITS_T

FIFO_CTRL_REG_FM0

Enum FIFO_CTRL_REG_BITS_T

FIFO_CTRL_REG_FM1

Enum FIFO_CTRL_REG_BITS_T

FIFO_CTRL_REG_FM2

Enum FIFO_CTRL_REG_BITS_T

_FIFO_CTRL_REG_FM_MASK

Enum FIFO_CTRL_REG_BITS_T

_FIFO_CTRL_REG_FM_SHIFT

Enum FIFO_CTRL_REG_BITS_T

FIFO_MODE_BYPASS

Enum FIFO_MODE_T

FIFO_MODE_FIFO

Enum FIFO_MODE_T

FIFO_MODE_STREAM

Enum FIFO_MODE_T

FIFO_MODE_STREAM_TO_FIFO

Enum FIFO_MODE_T

FIFO_MODE_BYPASS_TO_STREAM

Enum FIFO_MODE_T

FIFO_SRC_REG_FSS0

Enum FIFO_SRC_BITS_T

FIFO_SRC_REG_FSS1

Enum FIFO_SRC_BITS_T

FIFO_SRC_REG_FSS2

Enum FIFO_SRC_BITS_T

FIFO_SRC_REG_FSS3

Enum FIFO_SRC_BITS_T

FIFO_SRC_REG_FSS4

Enum FIFO_SRC_BITS_T

_FIFO_SRC_REG_FSS_MASK

Enum FIFO_SRC_BITS_T

_FIFO_SRC_REG_FSS_SHIFT

Enum FIFO_SRC_BITS_T

FIFO_SRC_REG_EMPTY

Enum FIFO_SRC_BITS_T

FIFO_SRC_REG_OVRN

Enum FIFO_SRC_BITS_T

FIFO_SRC_REG_WTM

Enum FIFO_SRC_BITS_T

INT1_CFG_XLIE

Enum INT1_CFG_BITS_T

INT1_CFG_XHIE

Enum INT1_CFG_BITS_T

INT1_CFG_YLIE

Enum INT1_CFG_BITS_T

INT1_CFG_YHIE

Enum INT1_CFG_BITS_T

INT1_CFG_ZLIE

Enum INT1_CFG_BITS_T

INT1_CFG_ZHIE

Enum INT1_CFG_BITS_T

INT1_CFG_LIR

Enum INT1_CFG_BITS_T

INT1_CFG_AND_OR

Enum INT1_CFG_BITS_T

_INT1_SRC_RESERVED_BITS

Enum INT1_SRC_BITS_T

INT1_SRC_XL

Enum INT1_SRC_BITS_T

INT1_SRC_XH

Enum INT1_SRC_BITS_T

INT1_SRC_YL

Enum INT1_SRC_BITS_T

INT1_SRC_YH

Enum INT1_SRC_BITS_T

INT1_SRC_ZL

Enum INT1_SRC_BITS_T

INT1_SRC_ZH

Enum INT1_SRC_BITS_T

INT1_SRC_IA

Enum INT1_SRC_BITS_T

INT1_DURATION_D0

Enum INT1_DURATION_BITS_T

INT1_DURATION_D1

Enum INT1_DURATION_BITS_T

INT1_DURATION_D2

Enum INT1_DURATION_BITS_T

INT1_DURATION_D3

Enum INT1_DURATION_BITS_T

INT1_DURATION_D4

Enum INT1_DURATION_BITS_T

INT1_DURATION_D5

Enum INT1_DURATION_BITS_T

INT1_DURATION_D6

Enum INT1_DURATION_BITS_T

INT1_DURATION_WAIT

Enum INT1_DURATION_BITS_T