adafruit / Adafruit_CircuitPython_ADS1x15

CircuitPython drivers for the ADS1x15 series of ADCs.
MIT License
133 stars 58 forks source link

how to read two ADS1115 on I2C bus? #69

Closed dretful closed 3 years ago

dretful commented 3 years ago

With two ADS1115's connected directly to the i2c bus and using the option to instantiate them with different addresses, I cant read each of them (having followed the example syntax).

ads1 = ADS.ADS1115(i2c, address=0x48)
chan1 = AnalogIn(ads1, ADS.P0)
ads2 = ADS.ADS1115(i2c, address=0x49)
chan2 = AnalogIn(ads2, ADS.P0)
print("ads1 {:>5}\t{:>5.3f}".format(chan1.value, chan1.voltage))
print("ads2 {:>5}\t{:>5.3f}".format(chan2.value, chan2.voltage))

output

ads1 4673 0.584 Traceback (most recent call last): File "", line 173, in File adafruit_ads1x15/analog_in.py", line 47, in value File "adafruit_ads1x15/ads1x15.py", line 127, in read File "adafruit_ads1x15/ads1x15.py", line 162, in _read File "adafruit_ads1x15/ads1x15.py", line 198, in _write_register File "adafruit_ads1x15/ads1x15.py", line 198, in _write_register File "adafruit_bus_device/i2c_device.py", line 84, in write OSError: [Errno 19] Unsupported operation

What's wrong here?

caternuson commented 3 years ago

Did you use the ADDR pin to set the alt address for the second ADS? Try an I2C scan and make sure both are being seen.

ladyada commented 3 years ago

hihi -this should be posted in the tech support forums

dretful commented 3 years ago

Sorry of wrong place, but just wanted to say, yes thank you following the advice Did you use the ADDR pin to set the alt address for the second ADS? Try an I2C scan and make sure both are being seen. and that solved it for me.