API Reference

ads1x15

CircuitPython base class driver for ADS1015/1115 ADCs.

  • Author(s): Carter Nelson

class adafruit_ads1x15.ads1x15.ADS1x15(i2c: I2C, gain: float = 1, data_rate: int | None = None, mode: int = 256, comparator_queue_length: int = 0, comparator_low_threshold: int = -32768, comparator_high_threshold: int = 32767, comparator_mode: int = 0, comparator_polarity: int = 0, comparator_latch: int = 0, address: int = 72)[source]

Base functionality for ADS1x15 analog to digital converters.

Parameters:
  • i2c (I2C) – The I2C bus the device is connected to.

  • gain (float) – The ADC gain.

  • data_rate (int) – The data rate for ADC conversion in samples per second. Default value depends on the device.

  • mode (Mode) – The conversion mode, defaults to Mode.SINGLE.

  • comparator_queue_length (int) – The number of successive conversions exceeding the comparator threshold before asserting ALERT/RDY pin. Defaults to 0 (comparator function disabled).

  • comparator_low_threshold (int) – Voltage limit under which comparator de-asserts ALERT/RDY pin. Must be lower than high threshold to use comparator function. Range of -32768 to 32767, default -32768

  • comparator_high_threshold (int) – Voltage limit over which comparator asserts ALERT/RDY pin. Must be higher than low threshold to use comparator function. Range of -32768 to 32767, default 32767

  • comparator_mode (Comp_Mode) – Configures the comparator as either traditional or window. Defaults to ‘Comp_Mode.TRADITIONAL’

  • comparator_polarity (Comp_Polarity) – Configures the comparator output as either active low or active high. Defaults to ‘Comp_Polarity.ACTIVE_LOW’

  • comparator_latch (Comp_Latch) – Configures the comparator output to only stay asserted while readings exceed threshold or latch on assertion until data is read. Defaults to ‘Comp_Latch.NONLATCHING’

  • address (int) – The I2C address of the device.

property bits: int

The ADC bit resolution.

property comparator_high_threshold: int

The ADC Comparator Higher Limit Threshold.

property comparator_latch: int

The ADC comparator latching mode.

property comparator_low_threshold: int

The ADC Comparator Lower Limit Threshold.

property comparator_mode: int

The ADC comparator mode.

property comparator_polarity: int

The ADC comparator polarity mode.

property comparator_queue_length: int

The ADC comparator queue length.

property comparator_queue_lengths: List[int]

Possible comparator queue length settings.

property data_rate: int

The data rate for ADC conversion in samples per second.

property gain: float

The ADC gain.

property gains: List[float]

Possible gain settings.

get_last_result(fast: bool = False) int[source]

Read the last conversion result when in continuous conversion mode. Will return a signed integer value. If fast is True, the register pointer is not updated as part of the read. This reduces I2C traffic and increases possible read rate.

property mode: int

The ADC conversion mode.

property rate_config: Dict[int, int]

Rate configuration masks.

property rates: List[int]

Possible data rate settings.

read(pin: int) int[source]

I2C Interface for ADS1x15-based ADCs reads.

Parameters:
  • pin (int) – individual or differential pin.

  • is_differential (bool) – single-ended or differential read.

class adafruit_ads1x15.ads1x15.Comp_Latch[source]

An enum-like class representing possible ADC Comparator latching modes.

LATCHING = 4

ALERT_RDY pin remains asserted until data is read by controller

NONLATCHING = 0

ALERT_RDY pin does not latch when asserted

class adafruit_ads1x15.ads1x15.Comp_Mode[source]

An enum-like class representing possible ADC Comparator operating modes.

TRADITIONAL = 0

Traditional Compartor Mode activates above high threshold, de-activates below low

WINDOW = 16

Window Comparator Mode activates when reading is outside of high and low thresholds

class adafruit_ads1x15.ads1x15.Comp_Polarity[source]

An enum-like class representing possible ADC Comparator polarity modes.

ACTIVE_HIGH = 8

ALERT_RDY pin is HIGH when comparator is active

ACTIVE_LOW = 0

ALERT_RDY pin is LOW when comparator is active

class adafruit_ads1x15.ads1x15.Mode[source]

An enum-like class representing possible ADC operating modes.

CONTINUOUS = 0

Continuous Mode

SINGLE = 256

Single-Shot Mode

class adafruit_ads1x15.ads1x15.Pin[source]

An enum-like class representing possible ADC pins.

A0 = 0

Analog Pin 0

A1 = 1

Analog Pin 1

A2 = 2

Analog Pin 2

A3 = 3

Analog Pin 3

ads1015

CircuitPython driver for ADS1015 ADCs.

  • Author(s): Carter Nelson

class adafruit_ads1x15.ads1015.ADS1015(i2c: I2C, gain: float = 1, data_rate: int | None = None, mode: int = 256, comparator_queue_length: int = 0, comparator_low_threshold: int = -32768, comparator_high_threshold: int = 32767, comparator_mode: int = 0, comparator_polarity: int = 0, comparator_latch: int = 0, address: int = 72)[source]

Class for the ADS1015 12 bit ADC.

property bits: Literal[12]

The ADC bit resolution.

property rate_config: Dict[int, int]

Rate configuration masks.

property rates: List[int]

Possible data rate settings.

ads1115

CircuitPython driver for 1115 ADCs.

  • Author(s): Carter Nelson

class adafruit_ads1x15.ads1115.ADS1115(i2c: I2C, gain: float = 1, data_rate: int | None = None, mode: int = 256, comparator_queue_length: int = 0, comparator_low_threshold: int = -32768, comparator_high_threshold: int = 32767, comparator_mode: int = 0, comparator_polarity: int = 0, comparator_latch: int = 0, address: int = 72)[source]

Class for the ADS1115 16 bit ADC.

property bits: Literal[16]

The ADC bit resolution.

property rate_config: Dict[int, int]

Rate configuration masks.

property rates: List[int]

Possible data rate settings.

analog_in

AnalogIn for single-ended and differential ADC readings.

  • Author(s): Carter Nelson, adapted from MCP3xxx original by Brent Rubell

class adafruit_ads1x15.analog_in.AnalogIn(ads: ADS1x15, positive_pin: int, negative_pin: int | None = None)[source]

AnalogIn Mock Implementation for ADC Reads.

Parameters:
  • ads (ADS1x15) – The ads object.

  • positive_pin (int) – Required pin for single-ended.

  • negative_pin (int) – Optional pin for differential reads.

convert_to_value(volts: float) int[source]

Calculates a standard 16-bit integer value for a given voltage

convert_to_voltage(value_int: int) float[source]

Calculates voltage from 16-bit ADC reading

property value: int

The value on the analog pin between 0 and 65535 inclusive (16-bit). (read-only)

Even if the underlying analog to digital converter (ADC) is lower resolution, the value is 16-bit.

property voltage: float

Returns the voltage from the ADC pin as a floating point value.