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.

ADS1X15 Class

Module: ads1x15

Methods

ADS1X15

(
  • bus
  • address
)
Number

ADS1X15 constructor

Parameters:

  • bus Number

    i2c bus the sensor is attached to.

  • address Number

    Device address. Default is 0x48.

Returns:

Number:

name

() String

Returns the name of the sensor

Returns:

String:

getLastSample

(
  • reg
)
Number

Returns the contents of conversion register without performing a conversion operation. Will use a multiplier based on the current gain setting to give the voltage as a float. Used internally to return the HI and LOW threshold values.

Parameters:

  • reg Number

    uint8_t value specifying register to read. Should generally be called with no parameter.

Returns:

Number:

getSample

(
  • mode
)
Number

Performs a read as specified by ADS1X15::ADSMUXMOE and returns the value as a float. Uses getLastSample() internally to return voltage value.
mode ADSMUXMODE specifying inputs to be sampled.

Parameters:

  • mode ADSMUXMODE

    undefined

Returns:

Number:

getGain

() ADSGAIN

Returns the current gain setting being used by the device as an ADSGAIN value.

Returns:

ADSGAIN:

setGain

(
  • gain
)

Sets the PGA gain bits to the desired gain. Default is +/- 2.094 volts.

Parameters:

  • gain ADSGAIN

    ADSGAIN value reprenting the desired gain. See warnings in spec sheet.

getSPS

() ADSSAMPLERATE

Returns the current device sample rate a an ADSSAMPLERATE value.

Returns:

ADSSAMPLERATE:

setSPS

(
  • rate
)

Sets the sample rate of the device. This function needs to be overrode in subclasses as the ADS1115 and ADS1015 have different data rates.

Parameters:

  • rate ADSSAMPLERATE

    undefined

getCompMode

() Boolean

Returns the comparator mode. False = Traditional comparator with Hysteresis (default) True = Window Comparator

Returns:

Boolean:

setCompMode

(
  • mode
)

Sets the comparator mode of the device.

Parameters:

  • mode Boolean

    bool value denoting mode. False = Traditional comparator with Hysteresis (default) True = Window Comparator

getCompPol

() Boolean

Get comparator polarity. Reports the polarity of the ALERT/RDY pin. Returns: False = Active Low (default) True = Active High

Returns:

Boolean:

setCompPol

(
  • mode
)

Sets the comparator polarity. Controls the polarity of the ALERT/RDY pin.

Parameters:

  • mode Boolean

    bool. False = Active Low (default) True = Active High

getCompLatch

() Boolean

Returns bool representing the state of the comparator latching functionality. False = Non Latching comparator (default) True = Latching Comparator

Returns:

Boolean:

setCompLatch

(
  • mode
)

Sets bit controlling comparator operation.

Parameters:

  • mode Boolean

    bool False = Non Latching comparator (default) True = Latching Comparator

getCompQue

() ADSCOMP

Returns ADSCOMP value representing the state of comparator queue.
CQUE_1CONV = Assert after one conversion CQUE_2CONV = Assert after two conversions CQUE_2CONV = Assert after four conversions CQUE_NONE = Disable comparator (default)

Returns:

ADSCOMP:

setCompQue

(
  • mode
)

Sets bits controlling Comparator queue operation.

Parameters:

  • mode ADSCOMP

    ADSCOMP enum. CQUE_1CONV = Assert after one conversion CQUE_2CONV = Assert after two conversions CQUE_2CONV = Assert after four conversions CQUE_NONE = Disable comparator (default)

getContinuous

() Boolean

Returns bool reflecting state of device mode bit.
False = Power Down Single shot mode (default) True = Continuous conversion mode

Returns:

Boolean:

setContinuous

(
  • mode
)

Sets the state of device mode but.

Parameters:

  • mode Boolean

    bool False = Power Down Single shot mode (default) True = Continuous conversion mode

getThresh

(
  • reg
)
Number

Returns current high or low threshold setting.

Parameters:

  • reg ADSTHRESH

    ADSTHRES enum value. Returns 0.0 unless THRESH_HIGH or THRESH_LOW requested.

Returns:

Number:

setThresh

(
  • reg
  • value
)

Sets threshold levels or configures for conversion ready operation of ALERT/RDY output.
THRESH_LOW = Sets low thresh register. THRESH_HIGH = Sets high thresh register. CONVERSION_RDY = Configures conversion ready operation THRESH_DEFAULT = resets high/low registers to startup values.

Parameters:

  • reg ADSTHRESH

    ADSTHRESH enum

  • value Number

    float value to set threshold register to.

Properties

GAIN_TWOTHIRDS

Enum ADSGAIN

GAIN_ONE

Enum ADSGAIN

GAIN_TWO

Enum ADSGAIN

GAIN_FOUR

Enum ADSGAIN

GAIN_EIGHT

Enum ADSGAIN

GAIN_SIXTEEN

Enum ADSGAIN

DIFF_0_1

Enum ADSMUXMODE

DIFF_0_3

Enum ADSMUXMODE

DIFF_1_3

Enum ADSMUXMODE

DIFF_2_3

Enum ADSMUXMODE

SINGLE_0

Enum ADSMUXMODE

SINGLE_1

Enum ADSMUXMODE

SINGLE_2

Enum ADSMUXMODE

SINGLE_3

Enum ADSMUXMODE

CQUE_1CONV

Enum ADSCOMP

CQUE_2CONV

Enum ADSCOMP

CQUE_4CONV

Enum ADSCOMP

CQUE_NONE

Enum ADSCOMP

THRESH_LOW

Enum ADSTHRESH

THRESH_HIGH

Enum ADSTHRESH

CONVERSION_RDY

Enum ADSTHRESH

THRESH_DEFAULT

Enum ADSTHRESH

SPS_DEFAULT

Enum ADSSAMPLERATE