We've been using Adafruit ADS1115 A/D Converters in our project to measure various voltages from sensors with great success. So far, each Pi in the system has been able to cater for all the sensor values at that location using a single converter. Here is a code fragment that we used:
We have one last requirement; we have three sensors at a single location, each needing four channels of measurement. I've sussed out how to set up the addressing, so we can physically install three A/D Converters, each connected to the Pi via the I2C Bus. The first of these has the default address of 0x48 (configured in the Adafruit CircuitPython Module) and the other two are 0x49 and 0x4B respectively. So far so good.
Code: Select all
import board import busio import adafruit_ads1x15.ads1115 as ADS from adafruit_ads1x15.analog_in import AnalogIn # Create the I2C bus i2c = busio.I2C(board.SCL, board.SDA) # Create the ADC object using the I2C bus try: ads = ADS.ADS1115(i2c) except OSError: print(" OSError. No ADS Device.") except ValueError: print(" ValueError. No I2C Device. Exiting...") exit(0) # Create four single-ended inputs on channels 0 to 3 try: chan0 = AnalogIn(ads, ADS.P0) chan1 = AnalogIn(ads, ADS.P1) chan2 = AnalogIn(ads, ADS.P2) chan3 = AnalogIn(ads, ADS.P3) except OSError: print(" OSError. A/D Channel(s) missing.")
I've looked at the code in the Adafruit Git Repository (https://github.com/adafruit/Adafruit_Ci ... it_ads1x15), but cannot see how to pass the required address. I realise that it isn't the Adafruit device that needs the address; it's the I2C bus, so I had a look at it from that point of view. The problem is that I'm not 100% happy with the code side of things, so I'm uncertain as to the best approach.
I believe that I will have to create three objects (ads1, ads2, ads3), but how do I pass the addresses to ads2 and ads3?