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

@zebrajaeger/remote-i2c

v0.1.5

Published

Access i²C over http for development purpose

Downloads

2

Readme

i2c-over-http

NPM

Transparent connection to local i2c-bus or remote i2c-bus via http rest interface.

Start Server from commandline

$ i2c-server --help
Usage: i2c-server [options]

Options:
  -b, --busNumber <nr>   I²C-Bus number (default: "0")
  -p, --port <port>      Port to bind on (default: "8080")
  -h, --host <hostname>  Host, IP, ... to bind on (default: "0.0.0.0")
  --help                 display help for command 

Use Client from commandline

$ i2c-read --help
Usage: i2c-read [options]

Options:
  -p, --port <port>        Port for send request to (default: "8080")
  -h, --host <hostname>    Host for send request to (default: "localhost")
  -a, --address <address>  i²C Address (default: "0")
  -c, --count <count>      Number of bytes to read (default: "1")
  --help                   display help for command

Use Client from code

For remote connection, first start server on the remote device.

// const {HardwareI2C} = require('@zebrajaeger/remote-i2c');
const {HardwareI2C, HttpI2C} = require('../src/client');

// for local execution use this one
//const i2c = new HardwareI2C(1); // on raspberry pi, we use i2c-bus #1

// for remote execution use this one
const i2c = new HttpI2C('192.168.178.69', 8080); // remote raspberry pi

(async () => {
    try {
        // read two 16 bit values (from i2c-joystick)
        const buffer = await i2c.read(0x30, 4);
        const x = buffer.readInt16LE(0);
        const y = buffer.readInt16LE(2);
        console.log({x, y});

        // read as hex-string for whatever
        const hexString = await i2c.readAsHex(0x30, 4);
        console.log({hexString});
    } catch (err) {
        console.log('Error', err)
    }
})();