Qwiic_ADS1015_Py  2.0.0-1-g291ac82
Python for SFE Qwiic ADS1015
Loading...
Searching...
No Matches
qwiic_ads1015.QwiicADS1015 Class Reference
Inheritance diagram for qwiic_ads1015.QwiicADS1015:

Public Member Functions

def __init__ (self, address=None, i2c_driver=None)
 Constructor. More...
 
def is_connected (self)
 Determines if this device is connected. More...
 
def begin (self)
 Initializes this device with default parameters. More...
 
def get_single_ended (self, channel)
 Returns the decimal value of sensor channel single-ended input. More...
 
def get_single_ended_signed (self, channel)
 Returns the signed value of sensor channel single-ended input. More...
 
def get_single_ended_millivolts (self, channel)
 Returns the millivolt value of sensor channel single-ended input. More...
 
def get_differential (self, config_mux_diff=kConfigMuxDiffP0N1)
 Returns the signed decimal value of sensor differential input Note, there are 4 possible differential pin setups: kConfigMuxDiffP0N1 kConfigMuxDiffP0N3 kConfigMuxDiffP1N3 kConfigMuxDiffP2N3. More...
 
def get_differential_millivolts (self, config_mux_diff=kConfigMuxDiffP0N1)
 Returns the millivolt value of sensor differential input Note, there are 4 possible differential pin setups: kConfigMuxDiffP0N1 kConfigMuxDiffP0N3 kConfigMuxDiffP1N3 kConfigMuxDiffP2N3. More...
 
def mapf (self, val, in_min, in_max, out_min, out_max)
 Maps a value from one range to another. More...
 
def get_scaled_analog_data (self, channel)
 Returns a value between 0 and 1 based on how bent the finger is. More...
 
def calibrate (self)
 Perform calibration on the sensor. More...
 
def get_calibration (self, channel, hiLo)
 Returns the calibration value for the specified channel and hiLo. More...
 
def set_calibration (self, channel, hiLo, value)
 Sets the calibration value for the specified channel and hiLo. More...
 
def reset_calibration (self)
 Resets the calibration values to 0. More...
 
def set_mode (self, mode)
 Sets the mode of the device. More...
 
def get_mode (self)
 Returns the mode of the device. More...
 
def set_gain (self, gain)
 Sets the gain of the device. More...
 
def get_gain (self)
 Returns the gain of the device Will return a differnet hex value of each gain setting: 0x0E00: +/- 0.256V 0X0000: +/- 6.144V 0X0200: +/- 4.096V 0X0400: +/- 2.048V 0X0600: +/- 1.024V 0X0800: +/- 0.512V 0X0A00: +/- 0.256V. More...
 
def update_multiplier_to_volts (self)
 Updates the multiplier to convert to volts. More...
 
def get_multiplier (self)
 Returns the multiplier to convert to volts. More...
 
def set_sample_rate (self, rate)
 Sets the sample rate of the device. More...
 
def get_sample_rate (self)
 Will return a different hex value for each sample rate Possible Values: 0x0000: 128 Hz 0X0020: 250 Hz 0X0040: 490 Hz 0X0060: 920 Hz 0X0080: 1600 Hz 0X00A0: 2400 Hz 0X00C0: 3300 Hz. More...
 
def available (self)
 Checks to see if the Operational Status (OS) flag is set in the status register. More...
 
def set_comparator_single_ended (self, channel, threshold)
 Sets up the comparator to operate in basic mode, causing the ALERT/RDY pin to assert (go from high to low) when the ADC value exceeds the specified threshold. More...
 
def get_last_conversion_results (self)
 In order to clear the comparator, we need to read the conversion results. More...
 
def conversion_delay (self)
 Delay for experimentally-determined delay times based on sample rate. More...
 
def use_conversion_ready (self, enable)
 Enables or disables the use of useConversionReady. More...
 

Public Attributes

 address
 

Static Public Attributes

 device_name = _DEFAULT_NAME
 
 available_addresses = _AVAILABLE_I2C_ADDRESS
 
int ADS1015_DELAY = 1
 
int kPointerConvert = 0x00
 
int kPointerConfig = 0x01
 
int kPointerLowThresh = 0x02
 
int kPointerHiThresh = 0x03
 
int kConfigOsNo = 0x0000
 
int kConfigOsSingle = 0x8000
 
int kConfigOsNotReady = 0x0000
 
int kConfigOsReady = 0x8000
 
int kConfigModeCont = 0x0000
 
int kConfigModeSingle = 0x0100
 
int kConfigMuxSingle0 = 0x4000
 
int kConfigMuxSingle1 = 0x5000
 
int kConfigMuxSingle2 = 0x6000
 
int kConfigMuxSingle3 = 0x7000
 
int kConfigMuxDiffP0N1 = 0x0000
 
int kConfigMuxDiffP0N3 = 0x1000
 
int kConfigMuxDiffP1N3 = 0x2000
 
int kConfigMuxDiffP2N3 = 0x3000
 
int kConfigRateMask = 0x00E0
 
int kConfigRate128Hz = 0x0000
 
int kConfigRate250Hz = 0x0020
 
int kConfigRate490Hz = 0x0040
 
int kConfigRate920Hz = 0x0060
 
int kConfigRate1600Hz = 0x0080
 
int kConfigRate2400Hz = 0x00A0
 
int kConfigRate3300Hz = 0x00C0
 
int kConfigPgaMask = 0x0E00
 
int kConfigPgaTwoThirds = 0x0000
 
int kConfigPga1 = 0x0200
 
int kConfigPga2 = 0x0400
 
int kConfigPga4 = 0x0600
 
int kConfigPga8 = 0x0800
 
int kConfigPga16 = 0x0A00
 
int kConfigCmodeTrad = 0x0000
 
int kConfigCmodeWindow = 0x0010
 
int kConfigCpolActvLow = 0x0000
 
int kConfigCpolActvHi = 0x0008
 
int kConfigClatNonLat = 0x0000
 
int kConfigClatLatch = 0x0004
 
int kConfigCque1Conv = 0x0000
 
int kConfigCque2Conv = 0x0001
 
int kConfigCque4Conv = 0x0002
 
int kConfigCqueNone = 0x0003
 

Properties

 connected = property(is_connected)
 

Constructor & Destructor Documentation

◆ __init__()

def qwiic_ads1015.QwiicADS1015.__init__ (   self,
  address = None,
  i2c_driver = None 
)

Constructor.

Parameters
int,optionaladdress: The I2C address to use for the device If not provided, the default address is used
I2CDriver,optionali2c_driver: An existing i2c driver object If not provided, a driver object is created

Member Function Documentation

◆ available()

def qwiic_ads1015.QwiicADS1015.available (   self)

Checks to see if the Operational Status (OS) flag is set in the status register.

Returns
bool True if the OS flag is set, otherwise False

◆ begin()

def qwiic_ads1015.QwiicADS1015.begin (   self)

Initializes this device with default parameters.

Returns
bool Returns True if successful, otherwise False

◆ calibrate()

def qwiic_ads1015.QwiicADS1015.calibrate (   self)

Perform calibration on the sensor.

This function will set the calibration values for each finger

◆ conversion_delay()

def qwiic_ads1015.QwiicADS1015.conversion_delay (   self)

Delay for experimentally-determined delay times based on sample rate.

These were determined experimentally by using Example7

◆ get_calibration()

def qwiic_ads1015.QwiicADS1015.get_calibration (   self,
  channel,
  hiLo 
)

Returns the calibration value for the specified channel and hiLo.

Parameters
intchannel: The channel to read
inthiLo: The hiLo to read
Returns
int The calibration value

◆ get_differential()

def qwiic_ads1015.QwiicADS1015.get_differential (   self,
  config_mux_diff = kConfigMuxDiffP0N1 
)

Returns the signed decimal value of sensor differential input Note, there are 4 possible differential pin setups: kConfigMuxDiffP0N1 kConfigMuxDiffP0N3 kConfigMuxDiffP1N3 kConfigMuxDiffP2N3.

Parameters
intconfig_mux_dif: The differential pin set up from the list above
Returns
int The signed value of the sensor differential input channel

◆ get_differential_millivolts()

def qwiic_ads1015.QwiicADS1015.get_differential_millivolts (   self,
  config_mux_diff = kConfigMuxDiffP0N1 
)

Returns the millivolt value of sensor differential input Note, there are 4 possible differential pin setups: kConfigMuxDiffP0N1 kConfigMuxDiffP0N3 kConfigMuxDiffP1N3 kConfigMuxDiffP2N3.

Parameters
intconfig_mux_dif: The differential pin set up from the list above
Returns
float The millivolt value of the sensor differential input channel

◆ get_gain()

def qwiic_ads1015.QwiicADS1015.get_gain (   self)

Returns the gain of the device Will return a differnet hex value of each gain setting: 0x0E00: +/- 0.256V 0X0000: +/- 6.144V 0X0200: +/- 4.096V 0X0400: +/- 2.048V 0X0600: +/- 1.024V 0X0800: +/- 0.512V 0X0A00: +/- 0.256V.

Returns
int The gain of the device

◆ get_last_conversion_results()

def qwiic_ads1015.QwiicADS1015.get_last_conversion_results (   self)

In order to clear the comparator, we need to read the conversion results.

This function reads the last conversion results without changing the config value.

Note, this function was adapted from the Adafruit Industries located here: https://github.com/adafruit/Adafruit_ADS1X15

Returns
int The last conversion result

◆ get_mode()

def qwiic_ads1015.QwiicADS1015.get_mode (   self)

Returns the mode of the device.

get_mode will return 0 for continuous and ADS1015_CONFIG_MODE_SINGLE for single shot

Returns
int The mode of the device

◆ get_multiplier()

def qwiic_ads1015.QwiicADS1015.get_multiplier (   self)

Returns the multiplier to convert to volts.

Returns
float The multiplier to convert to volts

◆ get_sample_rate()

def qwiic_ads1015.QwiicADS1015.get_sample_rate (   self)

Will return a different hex value for each sample rate Possible Values: 0x0000: 128 Hz 0X0020: 250 Hz 0X0040: 490 Hz 0X0060: 920 Hz 0X0080: 1600 Hz 0X00A0: 2400 Hz 0X00C0: 3300 Hz.

Returns
int The sample rate of the device

◆ get_scaled_analog_data()

def qwiic_ads1015.QwiicADS1015.get_scaled_analog_data (   self,
  channel 
)

Returns a value between 0 and 1 based on how bent the finger is.

This function will not work with an uncalibrated sensor

Parameters
intchannel: The channel to read
Returns
float The scaled value of the sensor

◆ get_single_ended()

def qwiic_ads1015.QwiicADS1015.get_single_ended (   self,
  channel 
)

Returns the decimal value of sensor channel single-ended input.

Parameters
intchannel: The channel to read
Returns
int The decimal value of the sensor channel

◆ get_single_ended_millivolts()

def qwiic_ads1015.QwiicADS1015.get_single_ended_millivolts (   self,
  channel 
)

Returns the millivolt value of sensor channel single-ended input.

Parameters
intchannel: The channel to read
Returns
float The millivolt value of the sensor channel

◆ get_single_ended_signed()

def qwiic_ads1015.QwiicADS1015.get_single_ended_signed (   self,
  channel 
)

Returns the signed value of sensor channel single-ended input.

Parameters
intchannel: The channel to read
Returns
int The signed value of the sensor channel

◆ is_connected()

def qwiic_ads1015.QwiicADS1015.is_connected (   self)

Determines if this device is connected.

Returns
bool True if connected, otherwise False

◆ mapf()

def qwiic_ads1015.QwiicADS1015.mapf (   self,
  val,
  in_min,
  in_max,
  out_min,
  out_max 
)

Maps a value from one range to another.

Parameters
floatval: The value to map
floatin_min: The minimum value of the input range
floatin_max: The maximum value of the input range
floatout_min: The minimum value of the output range
floatout_max: The maximum value of the output range
Returns
float The mapped value

◆ reset_calibration()

def qwiic_ads1015.QwiicADS1015.reset_calibration (   self)

Resets the calibration values to 0.

◆ set_calibration()

def qwiic_ads1015.QwiicADS1015.set_calibration (   self,
  channel,
  hiLo,
  value 
)

Sets the calibration value for the specified channel and hiLo.

Parameters
intchannel: The channel to read
inthiLo: The hiLo to read
intvalue: The value to set

◆ set_comparator_single_ended()

def qwiic_ads1015.QwiicADS1015.set_comparator_single_ended (   self,
  channel,
  threshold 
)

Sets up the comparator to operate in basic mode, causing the ALERT/RDY pin to assert (go from high to low) when the ADC value exceeds the specified threshold.

This will also set the ADC in continuous conversion mode.

Note, this function was adapted from the Adafruit Industries located here: https://github.com/adafruit/Adafruit_ADS1X15

Parameters
intchannel: The channel to read
intthreshold: The threshold value to compare

◆ set_gain()

def qwiic_ads1015.QwiicADS1015.set_gain (   self,
  gain 
)

Sets the gain of the device.

Valid values are: kConfigPgaTwoThirds, kConfigPga1, kConfigPga2, kConfigPga4, kConfigPga8, kConfigPga16

Parameters
intgain: The gain to set

◆ set_mode()

def qwiic_ads1015.QwiicADS1015.set_mode (   self,
  mode 
)

Sets the mode of the device.

Continuous mode 0 is favored

Parameters
intmode: The mode to set

◆ set_sample_rate()

def qwiic_ads1015.QwiicADS1015.set_sample_rate (   self,
  rate 
)

Sets the sample rate of the device.

Parameters
intrate: The sample rate to set

◆ update_multiplier_to_volts()

def qwiic_ads1015.QwiicADS1015.update_multiplier_to_volts (   self)

Updates the multiplier to convert to volts.

◆ use_conversion_ready()

def qwiic_ads1015.QwiicADS1015.use_conversion_ready (   self,
  enable 
)

Enables or disables the use of useConversionReady.

When useConversionReady is enabled: The Config Register OS bit is read to determine when the conversion is complete - instead of using conversionDelay. Single-shot mode is always selected. _mode is ignored.

Parameters
boolenable: True to enable, False to disable

Member Data Documentation

◆ address

qwiic_ads1015.QwiicADS1015.address

◆ ADS1015_DELAY

int qwiic_ads1015.QwiicADS1015.ADS1015_DELAY = 1
static

◆ available_addresses

qwiic_ads1015.QwiicADS1015.available_addresses = _AVAILABLE_I2C_ADDRESS
static

◆ device_name

qwiic_ads1015.QwiicADS1015.device_name = _DEFAULT_NAME
static

◆ kConfigClatLatch

int qwiic_ads1015.QwiicADS1015.kConfigClatLatch = 0x0004
static

◆ kConfigClatNonLat

int qwiic_ads1015.QwiicADS1015.kConfigClatNonLat = 0x0000
static

◆ kConfigCmodeTrad

int qwiic_ads1015.QwiicADS1015.kConfigCmodeTrad = 0x0000
static

◆ kConfigCmodeWindow

int qwiic_ads1015.QwiicADS1015.kConfigCmodeWindow = 0x0010
static

◆ kConfigCpolActvHi

int qwiic_ads1015.QwiicADS1015.kConfigCpolActvHi = 0x0008
static

◆ kConfigCpolActvLow

int qwiic_ads1015.QwiicADS1015.kConfigCpolActvLow = 0x0000
static

◆ kConfigCque1Conv

int qwiic_ads1015.QwiicADS1015.kConfigCque1Conv = 0x0000
static

◆ kConfigCque2Conv

int qwiic_ads1015.QwiicADS1015.kConfigCque2Conv = 0x0001
static

◆ kConfigCque4Conv

int qwiic_ads1015.QwiicADS1015.kConfigCque4Conv = 0x0002
static

◆ kConfigCqueNone

int qwiic_ads1015.QwiicADS1015.kConfigCqueNone = 0x0003
static

◆ kConfigModeCont

int qwiic_ads1015.QwiicADS1015.kConfigModeCont = 0x0000
static

◆ kConfigModeSingle

int qwiic_ads1015.QwiicADS1015.kConfigModeSingle = 0x0100
static

◆ kConfigMuxDiffP0N1

int qwiic_ads1015.QwiicADS1015.kConfigMuxDiffP0N1 = 0x0000
static

◆ kConfigMuxDiffP0N3

int qwiic_ads1015.QwiicADS1015.kConfigMuxDiffP0N3 = 0x1000
static

◆ kConfigMuxDiffP1N3

int qwiic_ads1015.QwiicADS1015.kConfigMuxDiffP1N3 = 0x2000
static

◆ kConfigMuxDiffP2N3

int qwiic_ads1015.QwiicADS1015.kConfigMuxDiffP2N3 = 0x3000
static

◆ kConfigMuxSingle0

int qwiic_ads1015.QwiicADS1015.kConfigMuxSingle0 = 0x4000
static

◆ kConfigMuxSingle1

int qwiic_ads1015.QwiicADS1015.kConfigMuxSingle1 = 0x5000
static

◆ kConfigMuxSingle2

int qwiic_ads1015.QwiicADS1015.kConfigMuxSingle2 = 0x6000
static

◆ kConfigMuxSingle3

int qwiic_ads1015.QwiicADS1015.kConfigMuxSingle3 = 0x7000
static

◆ kConfigOsNo

int qwiic_ads1015.QwiicADS1015.kConfigOsNo = 0x0000
static

◆ kConfigOsNotReady

int qwiic_ads1015.QwiicADS1015.kConfigOsNotReady = 0x0000
static

◆ kConfigOsReady

int qwiic_ads1015.QwiicADS1015.kConfigOsReady = 0x8000
static

◆ kConfigOsSingle

int qwiic_ads1015.QwiicADS1015.kConfigOsSingle = 0x8000
static

◆ kConfigPga1

int qwiic_ads1015.QwiicADS1015.kConfigPga1 = 0x0200
static

◆ kConfigPga16

int qwiic_ads1015.QwiicADS1015.kConfigPga16 = 0x0A00
static

◆ kConfigPga2

int qwiic_ads1015.QwiicADS1015.kConfigPga2 = 0x0400
static

◆ kConfigPga4

int qwiic_ads1015.QwiicADS1015.kConfigPga4 = 0x0600
static

◆ kConfigPga8

int qwiic_ads1015.QwiicADS1015.kConfigPga8 = 0x0800
static

◆ kConfigPgaMask

int qwiic_ads1015.QwiicADS1015.kConfigPgaMask = 0x0E00
static

◆ kConfigPgaTwoThirds

int qwiic_ads1015.QwiicADS1015.kConfigPgaTwoThirds = 0x0000
static

◆ kConfigRate128Hz

int qwiic_ads1015.QwiicADS1015.kConfigRate128Hz = 0x0000
static

◆ kConfigRate1600Hz

int qwiic_ads1015.QwiicADS1015.kConfigRate1600Hz = 0x0080
static

◆ kConfigRate2400Hz

int qwiic_ads1015.QwiicADS1015.kConfigRate2400Hz = 0x00A0
static

◆ kConfigRate250Hz

int qwiic_ads1015.QwiicADS1015.kConfigRate250Hz = 0x0020
static

◆ kConfigRate3300Hz

int qwiic_ads1015.QwiicADS1015.kConfigRate3300Hz = 0x00C0
static

◆ kConfigRate490Hz

int qwiic_ads1015.QwiicADS1015.kConfigRate490Hz = 0x0040
static

◆ kConfigRate920Hz

int qwiic_ads1015.QwiicADS1015.kConfigRate920Hz = 0x0060
static

◆ kConfigRateMask

int qwiic_ads1015.QwiicADS1015.kConfigRateMask = 0x00E0
static

◆ kPointerConfig

int qwiic_ads1015.QwiicADS1015.kPointerConfig = 0x01
static

◆ kPointerConvert

int qwiic_ads1015.QwiicADS1015.kPointerConvert = 0x00
static

◆ kPointerHiThresh

int qwiic_ads1015.QwiicADS1015.kPointerHiThresh = 0x03
static

◆ kPointerLowThresh

int qwiic_ads1015.QwiicADS1015.kPointerLowThresh = 0x02
static

Property Documentation

◆ connected

qwiic_ads1015.QwiicADS1015.connected = property(is_connected)
static

The documentation for this class was generated from the following file: