![]() |
Qwiic_ADS1015_Py
2.0.0-1-g291ac82
Python for SFE Qwiic ADS1015
|
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 | |
Properties | |
connected = property(is_connected) | |
def qwiic_ads1015.QwiicADS1015.__init__ | ( | self, | |
address = None , |
|||
i2c_driver = None |
|||
) |
Constructor.
int,optional | address: The I2C address to use for the device If not provided, the default address is used |
I2CDriver,optional | i2c_driver: An existing i2c driver object If not provided, a driver object is created |
def qwiic_ads1015.QwiicADS1015.available | ( | self | ) |
Checks to see if the Operational Status (OS) flag is set in the status register.
def qwiic_ads1015.QwiicADS1015.begin | ( | self | ) |
Initializes this device with default parameters.
True
if successful, otherwise False
def qwiic_ads1015.QwiicADS1015.calibrate | ( | self | ) |
Perform calibration on the sensor.
This function will set the calibration values for each finger
def qwiic_ads1015.QwiicADS1015.conversion_delay | ( | self | ) |
Delay for experimentally-determined delay times based on sample rate.
These were determined experimentally by using Example7
def qwiic_ads1015.QwiicADS1015.get_calibration | ( | self, | |
channel, | |||
hiLo | |||
) |
Returns the calibration value for the specified channel and hiLo.
int | channel: The channel to read |
int | hiLo: The hiLo to read |
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.
int | config_mux_dif: The differential pin set up from the list above |
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.
int | config_mux_dif: The differential pin set up from the list above |
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.
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
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
def qwiic_ads1015.QwiicADS1015.get_multiplier | ( | self | ) |
Returns the multiplier to convert to volts.
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.
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
int | channel: The channel to read |
def qwiic_ads1015.QwiicADS1015.get_single_ended | ( | self, | |
channel | |||
) |
Returns the decimal value of sensor channel single-ended input.
int | channel: The channel to read |
def qwiic_ads1015.QwiicADS1015.get_single_ended_millivolts | ( | self, | |
channel | |||
) |
Returns the millivolt value of sensor channel single-ended input.
int | channel: The channel to read |
def qwiic_ads1015.QwiicADS1015.get_single_ended_signed | ( | self, | |
channel | |||
) |
Returns the signed value of sensor channel single-ended input.
int | channel: The channel to read |
def qwiic_ads1015.QwiicADS1015.is_connected | ( | self | ) |
Determines if this device is connected.
True
if connected, otherwise False
def qwiic_ads1015.QwiicADS1015.mapf | ( | self, | |
val, | |||
in_min, | |||
in_max, | |||
out_min, | |||
out_max | |||
) |
Maps a value from one range to another.
float | val: The value to map |
float | in_min: The minimum value of the input range |
float | in_max: The maximum value of the input range |
float | out_min: The minimum value of the output range |
float | out_max: The maximum value of the output range |
def qwiic_ads1015.QwiicADS1015.reset_calibration | ( | self | ) |
Resets the calibration values to 0.
def qwiic_ads1015.QwiicADS1015.set_calibration | ( | self, | |
channel, | |||
hiLo, | |||
value | |||
) |
Sets the calibration value for the specified channel and hiLo.
int | channel: The channel to read |
int | hiLo: The hiLo to read |
int | value: The value to set |
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
int | channel: The channel to read |
int | threshold: The threshold value to compare |
def qwiic_ads1015.QwiicADS1015.set_gain | ( | self, | |
gain | |||
) |
Sets the gain of the device.
Valid values are: kConfigPgaTwoThirds, kConfigPga1, kConfigPga2, kConfigPga4, kConfigPga8, kConfigPga16
int | gain: The gain to set |
def qwiic_ads1015.QwiicADS1015.set_mode | ( | self, | |
mode | |||
) |
Sets the mode of the device.
Continuous mode 0 is favored
int | mode: The mode to set |
def qwiic_ads1015.QwiicADS1015.set_sample_rate | ( | self, | |
rate | |||
) |
Sets the sample rate of the device.
int | rate: The sample rate to set |
def qwiic_ads1015.QwiicADS1015.update_multiplier_to_volts | ( | self | ) |
Updates the multiplier to convert to volts.
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.
bool | enable: True to enable, False to disable |
qwiic_ads1015.QwiicADS1015.address |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |