Skip to content

Allow setting the I2C address register as kwarg #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 26, 2020

Conversation

markus-k
Copy link
Contributor

With the kwarg addr_reg, multiple sensors can be used on one bus without fiddling with the ADDR/SDA line. The sensors ADDR register is set to its value upon initialization.

Each sensors VCC has to be connected to a GPIO pin. Sensors can then be enabled one by one, setting a new address each time. Up to 4 sensors can be used on one bus this way.

Example, VCC of TLV493Ds connected to D4 and D17:

en_pin = digitalio.DigitalInOut(board.D4)
en_pin.switch_to_output()

en2_pin = digitalio.DigitalInOut(board.D17)
en2_pin.switch_to_output()

i2c = busio.I2C(board.SCL, board.SDA)

en_pin.value = False
en2_pin.value = False
time.sleep(0.2)

en_pin.value = True

tlv = adafruit_tlv493d.TLV493D(i2c, addr_reg=1)
tlv = adafruit_tlv493d.TLV493D(i2c, address=0x5a, addr_reg=1)

en2_pin.value = True
tlv2 = adafruit_tlv493d.TLV493D(i2c, addr_reg=3)
tlv2 = adafruit_tlv493d.TLV493D(i2c, address=0x4a, addr_reg=3)

It's surely not as nice of an API as it could be, but I didn't really have a better idea on an easy way to get multiple sensors working.

With this kwarg, multiple sensors can be used on one bus without
fiddling with the ADDR/SDA line.

Each sensors VCC has to be connected to a GPIO pin. Sensors can then be
enabled one by one, setting a new address each time. Up to 4 sensors
can be used on one bus this way.
@ladyada ladyada merged commit b04a8bb into adafruit:master Oct 26, 2020
@ladyada
Copy link
Member

ladyada commented Oct 26, 2020

nifty!

adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Oct 30, 2020
Updating https://github.com/adafruit/Adafruit_CircuitPython_BNO055 to 5.2.1 from 5.2.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_BNO055#57 from markus-k/patch-1

Updating https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI to 3.5.2 from 3.5.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_ESP32SPI#112 from tannewt/return_earlier
  > Merge pull request adafruit/Adafruit_CircuitPython_ESP32SPI#111 from adafruit/rssi_fix

Updating https://github.com/adafruit/Adafruit_CircuitPython_IL0373 to 1.3.1 from 1.2.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_IL0373#12 from tannewt/grayscale

Updating https://github.com/adafruit/Adafruit_CircuitPython_MAX31865 to 2.2.5 from 2.2.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_MAX31865#23 from ben-lewis/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_TLV493D to 1.2.0 from 1.1.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_TLV493D#7 from markus-k/reg-addr

Updating https://github.com/adafruit/Adafruit_CircuitPython_ProgressBar to 1.3.4 from 1.3.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_ProgressBar#18 from mtowara/mtowara-patch-1

Updating https://github.com/adafruit/Adafruit_CircuitPython_Register to 1.9.1 from 1.9.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_Register#40 from AdamCummick/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_Requests to 1.7.3 from 1.7.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_Requests#43 from makermelissa/master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants