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.

ENC03R Class

Module: enc03r

UPM module for the ENC03R single axis analog gyro. This gyroscope measures x-axis angular velocity, that is how fast the sensor is rotating around the x-axis. Calibration of the sensor is necessary for accurate readings.
enc03r.jpg

Methods

ENC03R

(
  • pin
  • aref
)
Number

ENC03R sensor constructor

Parameters:

  • pin Number

    Analog pin to use

  • aref Number

    Reference voltage to use; default is 5.0 V

Returns:

Number:

calibrate

(
  • samples
)

Calibrates the sensor by determining an analog reading over many samples with no movement of the sensor. This must be done before attempting to use the sensor.

Parameters:

  • samples Number

    Number of samples to use for calibration

update

()

Update the internal state with the current reading. This function must be called prior to calling angularVelocity() .

calibrationValue

() Number

Returns the currently stored calibration value

Returns:

Number:

Current calibration value

angularVelocity

() Number

Computes angular velocity based on the value and stored calibration reference.

Returns:

Number:

Computed angular velocity

setOffset

(
  • offset
)

Set sensor offset. The offset is applied to the return value before scaling. Default is 0.

Parameters:

  • offset Number

    Offset to apply to value

setScale

(
  • scale
)

Set sensor scale. The return value is scaled by this value after the offset is applied. Default is 1.0.

Parameters:

  • scale Number

    Scale to apply to value

getNormalized

() Number

Get a normalized ADC value from the sensor. The return value will be between 0.0 (indicating no voltage) and 1.0 indicating max voltage (aref). update() must be called prior to calling this function.

Returns:

Number:

The normalized reading from the ADC.