adafruit / Adafruit_CircuitPython_ADS1x15

CircuitPython drivers for the ADS1x15 series of ADCs.
MIT License
140 stars 59 forks source link

Procedure for 4 in 1 raspberry pi ADS1115. #20

Closed jamborloi closed 5 years ago

jamborloi commented 5 years ago

Last time you can chose to read which address like this: adc = Adafruit_ADS1x15.ADS1015(address=0x49, busnum=1)

how about this library for ADS1115?

ladyada commented 5 years ago

you can set the address in init https://github.com/adafruit/Adafruit_CircuitPython_ADS1x15/blob/master/adafruit_ads1x15/ads1x15.py#L60 in circuitpython you dont pass the busnumber into the object, you create a bus device separately then pass it in, there's only one on the raspi: https://learn.adafruit.com/circuitpython-on-raspberrypi-linux/i2c-sensors-and-devices

jamborloi commented 5 years ago

Hi Ladyada, Thanks you for the reply and thanks for the Adafruit libraries. If I will use 2 or 3 ADS1115 in my circuit how to set it up on my python commands? Previously I am setting it up by: adc0 = Adafruit_ADS1x15.ADS1015(address=0x49, busnum=1) adc1 = Adafruit_ADS1x15.ADS1015(address=0x48, busnum=1) On the init I can only change the address.

Thanks

ladyada commented 5 years ago

drop busnum, you don't need to specify it.

jamborloi commented 5 years ago

ok thanks.

caternuson commented 5 years ago

And don't forget to use the ADDR pin to set different addresses for each board: https://learn.adafruit.com/adafruit-4-channel-adc-breakouts/assembly-and-wiring#multiple-boards-2-14

jamborloi commented 5 years ago

Hey Thanks. I will do that.

jamborloi commented 5 years ago

Hi @ladyada @caternuson , Sorry to bring this up again, I am trying to update my existing system reading temperature from ADS1115. I want to upgrade my circuit with 4 ADS1115 to read 16 temperature and pressure sensors. Ad I am currently using the old script and below is the script to identify all 4: adc0 = Adafruit_ADS1x15.ADS1115(address=0x48) adc1 = Adafruit_ADS1x15.ADS1115(address=0x49) adc2 = Adafruit_ADS1x15.ADS1115(address=0x4A) adc3 = Adafruit_ADS1x15.ADS1115(address=0x4B) *this is on one python script

How can I adapt this on new circuitpython?

Thank you and regards,

caternuson commented 5 years ago

That looks fine. In general, you specify the address when you create the object. Looks like that is what you are doing. Is it not working?

jamborloi commented 5 years ago

That looks fine. In general, you specify the address when you create the object. Looks like that is what you are doing. Is it not working?

Hi, Thanks. I haven't tried it yet. I am wondering how to include it or modify the adafruit circuitpython simpletest python script. In the script it called the adc "ads = ADS.ADS1115(i2c)" Im not sure how to put the i2c address? Or is it like this? ads0 = ADS.ADS1115(i2c, address=0x48) ads1 = ADS.ADS1115(i2c, address=0x49) ads2 = ADS.ADS1115(i2c, address=0x4A) ads3 = ADS.ADS1115(i2c, address=0x4B)

Thanks for your help.

caternuson commented 5 years ago

That's it. You're setting the address with the parameter address=. So ads0 is 0x48, etc. If you don't specify an address, it just uses a default value.

Do you think it would help if the simpletest example had this in it?

# Create the ADC object
ads = ADS.ADS1015(i2c)                 # use the default address
#ads = ADS.ADS1015(i2c, address=0x49)  # specify an address
jamborloi commented 5 years ago

hey @caternuson, Ok I understand now. I will try soon, thank you.

Yes it would be very helpful if the simpletest had this specially a noob like me:

Create the ADC object

ads = ADS.ADS1015(i2c) # use the default address

ads = ADS.ADS1015(i2c, address=0x49) # specify an address

caternuson commented 5 years ago

Want to try and make a pull request with those changes? If you've never made a pull request before, this would be an excellent one to try.

We even have a few guides that might help. https://learn.adafruit.com/an-introduction-to-collaborating-with-version-control/overview https://learn.adafruit.com/contribute-to-circuitpython-with-git-and-github/overview

jamborloi commented 5 years ago

Hi @caternuson , Thanks. I will check and try to pull request with those chages.