npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@chirimen/tca9548a

v3.0.0

Published

Driver for TCA9548A with WebI2C

Readme

@chirimen/tca9548a

Driver for TCA9548A with WebI2C

Usage

get(channel) returns an object implementing I2CPort, scoped to one downstream channel. Pass it straight into another driver's constructor, just like a plain I2CPort. It selects the channel and serializes access on its own, so you don't need to call write() before every read or write:

import { requestI2CAccess } from "node-web-i2c";
import TCA9548A from "@chirimen/tca9548a";
import SHT30 from "@chirimen/sht30";

const i2cAccess = await requestI2CAccess();

const mux = new TCA9548A(i2cAccess.ports.get(1));

const s0 = new SHT30(mux.get(0));
const s1 = new SHT30(mux.get(1));

await s0.init();
await s1.init();

while (true) {
  console.log(await s0.readData());
  console.log(await s1.readData());
}

read() and write() still work too, for selecting a channel manually before each access.

Every I2C operation issued through a mux instance (whether via read()/write() or a get(channel)-wrapped device) is serialized, so it's safe to call them concurrently. If a single operation doesn't complete within 5 seconds, that call rejects with TCA9548ALockTimeoutError so your code isn't left waiting forever. Later calls on the same mux still wait for the stuck operation to actually finish, though — there's no way to cancel an I2C transaction once it's issued, so letting other calls proceed early could interleave with whatever the stuck operation eventually does to the bus.

Breaking changes in 3.0.0

TCA9548A is now a real class. new TCA9548A(bus) still works exactly as before, but calling it as a plain function (TCA9548A(bus), without new) now throws instead of returning a driver instance.

API

Class: TCA9548A

Defined in packages/tca9548a/index.js:55

Constructor

▸ new TCA9548A(bus: I2CPort, address: TCA9548AAddress): TCA9548A

Defined in packages/tca9548a/index.js:79

Parameters:

| Name | Type | Default | | --------- | ---------------------------------------------------------------- | ------- | | bus | I2CPort | - | | address | TCA9548AAddress | 112 |

Properties and methods

  • i2cSlave: null | I2CSlaveDevice = null as I2CSlaveDevice | null

  • init(): Promise‹void›

  • read(): Promise‹TCA9548AChannel | null›

  • write(channel: TCA9548AChannel): Promise‹void› — throws RangeError for a channel outside 0-7.

  • get(channel: TCA9548AChannel): I2CPort-like object — see Usage. Calling get() twice with the same channel returns the same object. Throws RangeError for a channel outside 0-7.

Const TCA9548AChannels

• TCA9548AChannels: ReadonlyArray‹TCA9548AChannel› = [ 0, 1, 2, 3, 4, 5, 6, 7 ]

Defined in packages/tca9548a/index.js:23

TCA9548AAddress

Ƭ TCA9548AAddress: 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119

Defined in packages/tca9548a/index.js:4

I2C bus slave address (default 0x70; when A0-A2 pins are high(1)/low(0) 0x70+4*A2+2*A1+A0 )

TCA9548AChannel

Ƭ TCA9548AChannel: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7

Defined in packages/tca9548a/index.js:9

8 switch channels for I2C data flow

TCA9548ANotFoundError

An Error thrown when the mux chip itself doesn't respond at its configured address.

TCA9548ALockTimeoutError

An Error thrown when a single I2C operation doesn't complete within 5 seconds.

License

MIT