### Install adafruit-circuitpython-ads1x15 Source: https://github.com/adafruit/adafruit_circuitpython_ads1x15/blob/main/docs/index.md Install the driver using pip. Use `sudo` for system-wide installation or create a virtual environment for project-specific installation. ```shell pip3 install adafruit-circuitpython-ads1x15 ``` ```shell sudo pip3 install adafruit-circuitpython-ads1x15 ``` ```shell mkdir project-name && cd project-name python3 -m venv .venv source .venv/bin/activate pip3 install adafruit-circuitpython-ads1x15 ``` -------------------------------- ### Install adafruit-circuitpython-ads1x15 using pip Source: https://github.com/adafruit/adafruit_circuitpython_ads1x15/blob/main/README.rst Install the library for current user, system-wide, or in a virtual environment. ```shell pip3 install adafruit-circuitpython-ads1x15 ``` ```shell sudo pip3 install adafruit-circuitpython-ads15 ``` ```shell mkdir project-name && cd project-name python3 -m venv .venv source .venv/bin/activate pip3 install adafruit-circuitpython-ads1x15 ``` -------------------------------- ### Read Analog Input with ADS1015 Source: https://github.com/adafruit/adafruit_circuitpython_ads1x15/blob/main/docs/examples.md Use this example to read analog values from a single-ended input channel on the ADS1015. Ensure the ADS1015 is connected via I2C. ```default # SPDX-FileCopyright-Text: 2021 ladyada for Adafruit Industries # SPDX-License-Identifier: MIT import time import board from adafruit_ads1x15 import ADS1015, AnalogIn, ads1x15 # Create the I2C bus i2c = board.I2C() # Create the ADC object using the I2C bus ads = ADS1015(i2c) # Create single-ended input on channel 0 chan = AnalogIn(ads, ads1x15.Pin.A0) # Create differential input between channel 0 and 1 # chan = AnalogIn(ads, ads1x15.Pin.A0, ads1x15.Pin.A1) print("{:>5}\t{:>5}".format("raw", "v")) while True: print(f"{chan.value:>5}\t{chan.voltage:>5.3f}") time.sleep(0.5) ``` -------------------------------- ### Read Analog Input with ADS1115 Source: https://github.com/adafruit/adafruit_circuitpython_ads1x15/blob/main/docs/examples.md This example demonstrates reading analog values from a single-ended input channel using the ADS1115. The ADS1115 offers higher precision than the ADS1015. You can specify an alternative I2C address if needed. ```default # SPDX-FileCopyright-Text: 2021 ladyada for Adafruit Industries # SPDX-License-Identifier: MIT import time import board from adafruit_ads1x15 import ADS1115, AnalogIn, ads1x15 # Create the I2C bus i2c = board.I2C() # Create the ADC object using the I2C bus ads = ADS1115(i2c) # you can specify an I2C adress instead of the default 0x48 # ads = ADS.ADS1115(i2c, address=0x49) # Create single-ended input on channel 0 chan = AnalogIn(ads, ads1x15.Pin.A0) # Create differential input between channel 0 and 1 # chan = AnalogIn(ads, ads1x15.Pin.A0, ads1x15.Pin.A1) print("{:>5}\t{:>5}".format("raw", "v")) while True: print(f"{chan.value:>5}\t{chan.voltage:>5.3f}") time.sleep(0.5) ``` -------------------------------- ### Read Analog Input with ADS1x15 Source: https://github.com/adafruit/adafruit_circuitpython_ads1x15/blob/main/docs/index.md Read analog values from a single-ended input channel (A0) and print the raw value and voltage. Requires I2C setup and the ADS1015 or ADS1115 object. ```python import time import board from adafruit_ads1x15 import ADS1015, AnalogIn, ads1x15 # Create the I2C bus i2c = board.I2C() # Create the ADC object using the I2C bus ads = ADS1015(i2c) # Create single-ended input on channel 0 chan = AnalogIn(ads, ads1x15.Pin.A0) # Create differential input between channel 0 and 1 # chan = AnalogIn(ads, ads1x15.Pin.A0, ads1x15.Pin.A1) print("{:>5}\t{:>5}".format("raw", "v")) while True: print("{:>5}\t{:>5.3f}".format(chan.value, chan.voltage)) time.sleep(0.5) ``` -------------------------------- ### Read Analog Input with ADS1x15 Source: https://github.com/adafruit/adafruit_circuitpython_ads1x15/blob/main/README.rst Reads analog input from a specified channel on the ADS1x15 ADC and prints the raw value and voltage. Ensure the I2C bus and ADC object are initialized. ```python import time import board from adafruit_ads1x15 import ADS1015, AnalogIn, ads1x15 # Create the I2C bus i2c = board.I2C() # Create the ADC object using the I2C bus ads = ADS1015(i2c) # Create single-ended input on channel 0 chan = AnalogIn(ads, ads1x15.Pin.A0) # Create differential input between channel 0 and 1 # chan = AnalogIn(ads, ads1x15.Pin.A0, ads1x15.Pin.A1) print("{:>5} {:>5}".format("raw", "v")) while True: print("{:>5} {:>5.3f}".format(chan.value, chan.voltage)) time.sleep(0.5) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.