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 🙏

© 2024 – Pkg Stats / Ryan Hefner

tca9548a

v1.0.0

Published

A Node.js module for the TCA9548A I2C 8-channel Multiplexer

Downloads

12

Readme

tca9548a

A Node.js module for the TCA9548A I2C 8-channel Multiplexer.

Built using node v11.9.0

This is Node.js I2C module for the TCA9548A Low-Voltage 8-Channel I2C Switch/Multiplexer.

This module uses i2c-bus which should provide access with Node.js on Linux boards like the Raspberry Pi Zero, 1, 2, or 3B and +, BeagleBone, BeagleBone Black, or Intel Edison.

Since TCA9548A needs to talk directly to the I2C bus and requires access to /dev/i2c, you will typically need run Node with elevated privileges or add your user account to the i2c group: $ sudo adduser $USER i2c. On Raspberry PI, be sure to enable I2C protocol in system configuration before proceeding.


Example Code:

//require module
//
const TCA9548A = require('tca9548a');

//module is constructed via Class so first call a new instance
//device is automatically initialized and ready to use
//addr defaults to 0x70 and bus defaults to 1
//
const tca9548a_1 = new TCA9548A({addr: 0x70, bus: 1});

//if you have more than one TCA9548A, can call another instance
//make sure that the addr is correct!!!
//
const tca9548a_2 = new TCA9548A({addr: 0x71, bus: 1});


//as an example, if using two bme280 temp sensors (sensor1 and sensor2)
//that have the same address need to enable the specific 
//multiplexer port each time you want to read from a certain device
//singlePortOn activates the port of the argument and 
//disables all other ports
//argument has to be a number 0-7
//
//use a callback to ensure that the port is enabled 
//before proceeding with other processing
//
//for example, sensor1 is attached to port 2 on the multiplexer
//
tca9548a_1.singlePortOn(2, doSomethingWithSensor());

//then read from sensor2 attached to port 6 on the multiplexer
//
tca9548a_1.singlePortOn(6, doSomethingWithSensor());


function doSomethingWithSensor () {
  //process sensor data magic
  console.log('doSomethingWithSensor called');
}



//can also enable all ports
tca9548a_1.allPortsOn();

//or disable all ports
tca9548a_1.allPortsOff();