GY-63_MS5611/libraries/TCA9548
2021-08-22 10:49:53 +02:00
..
.github/workflows add arduino-lint 2021-05-28 13:17:38 +02:00
examples/tca9548_demo Add TCA9548 2021-05-26 12:09:27 +02:00
test Add TCA9548 2021-05-26 12:09:27 +02:00
.arduino-ci.yml Add TCA9548 2021-05-26 12:09:27 +02:00
keywords.txt Add TCA9548 2021-05-26 12:09:27 +02:00
library.json add license to library,json 2021-05-28 14:16:25 +02:00
library.properties Add TCA9548 2021-05-26 12:09:27 +02:00
LICENSE Add TCA9548 2021-05-26 12:09:27 +02:00
README.md update readme.md 2021-08-22 10:49:53 +02:00
TCA9548.cpp Add TCA9548 2021-05-26 12:09:27 +02:00
TCA9548.h Add TCA9548 2021-05-26 12:09:27 +02:00

Arduino CI License: MIT GitHub release

TCA9548

Arduino Library for TCA9548 I2C multiplexer.

Description

Library for the TCA9548 and TCA9548a I2C multiplexer. The library allows you to enable 0 to 7 I2C channels (ports) uniquely or simultaneously. This is especially handy if you have multiple devices/sensors that have a fixed address.

Warning The library is not tested extensively.

I2C address is 0x70 .. 0x77.

The library caches the channels enabled, and if a channel is enabled, it will not be enabled again (low level) to optimize performance.

Interface

Constructor

  • TCA9548(const uint8_t deviceAddress, TwoWire *wire = &Wire);) Constructor, Address = 0x70 .. 0x77, wire = Wire or WireN.
  • bool begin(uint8_t sda, uint8_t scl, uint8_t mask = 0x00); Set I2C pins for ESP32 alikes, set mask of channels to be enabled.
  • bool begin(uint8_t mask = 0x00); set mask of channels to be enabled.
  • bool isConnected() retuns true if address of the multiplexer itself is found on I2C bus.

Find device

  • bool isConnected(uint8_t addr) retuns true if arbitrary address is found on I2C bus. This can be used to verify a certain device is available (or not) on an enabled channel.

Channel functions

  • void enableChannel(uint8_t channel) enables channel 0 .. 7. Multiple channels can be enabled in parallel.
  • void disableChannel(uint8_t channel) disables channel 0 .. 7. Will not disable other channels.
  • void selectChannel(uint8_t channel) enables a single channel 0 .. 7 uniquely. All other channels will be disabled, although these can be set again with enableChannel.
  • bool isEnabled(uint8_t channel) returns true is a channel is enabled.
  • void setChannelMask(uint8_t mask) enables 0 or more channels simultaneously with a bitmask.
  • uint8_t getChannelMask() reads back the bitmask of the channels enabled.
  • void setResetPin(uint8_t resetPin) sets the pin to reset the chip. (Not tested)
  • void reset() trigger the reset pin.
  • getError() returns the last I2C error.

Operation

See example

Future

  • test test and test
  • write unit test
  • forced write to chip ? robustness vs performance
  • set an "always enabled" mask (have to investigate the consequences)