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

mod-io

v1.1.2

Published

Package for interfacing with the Olimex MOD-IO board

Readme

MOD IO

Package for interfacing with the Olimex MOD-IO development board. Since the board communicates over I2C, i2c-bus is used.

I2C setup

To give the node module i2c-bus access to I2C ports, i2c-dev needs to be added to system modules and given R/W permission. This can be done with

echo i2c-dev >> /etc/modules
touch /etc/udev/rules.d/99-i2c.rules
echo SUBSYSTEM==\"i2c-dev\", MODE=\"0666\" >> /etc/udev/rules.d/99-i2c.rules

Use

A connection is opened in the constructor of the ModIoConnection class. Both synchronous and Promisifed calls are supported.

Synchronous call example

for (let index = 1; index < 5; index++) {
    console.log(`Analog input ${index}: ${connection.readAnalogInputSync(index)}`);
}

Promisified call example

for (let index = 1; index < 5; index++) {
    promises.push(connection.readAnalogInputPromisified(index))
}
Promise.all(promises).then(result => console.log(result))

API

Synchronous and Promisified methods accept the same parameters, the only difference is their execution and return type

ModIoConnection(deviceId, address)

Both the device ID and address are optional and will default to 1 and 0x58 respectively. To check available list IDs, use

sudo i2cdetect -l

and then

sudo i2cdetect -y [deviceId]

to see if the set board address shows up (0x58 by default)

Previously read values can be accessed from the state attribute without the need to query the board

state = {
      relays: 0x00,
      analogInputs: Array(4),
      digitalInputs: Array(4),
    }

setRelaySync(id: number, value: boolean): number

setRelayPromisified(id: number, value: boolean): Promise

Set individual relay to provided value and stores the change in local state

@param id — Relay ID from 1 to 4

@param value - boolean to set the controll bit

@returns - current state of all relays

getRelay(id: number): boolean

Helper function that reads the individual bits that were set for each relay. The values are read from the internal object state, not from the board.

@param id — Relay ID from 1 to 4

@returns — Relay value

readAnalogInputSync(id: number): number

readAnalogInputPromisified(id: number): Promise

Read voltage from analog input in the range 0-3.3V

@param id — Analog input ID from 1 to 4

@returns — Voltage of selected input

readDigitalInputSync(id?: number | undefined): boolean | boolean[]

readDigitalInputPromisified(id?: number | undefined): Promise | Promise<boolean[]>

Reads all four digital inputs from the board. If a valid ID is provided, will return only that boolean, otherwise returns the entire Array. Values are stored in the local state so they can be checked without querying again.

@param id — Digital input ID from 1 to 4

@returns — Specific input value or all four values

sendCustomCommandSync(command: number, input?: number | Buffer | undefined, outputBuffer?: Buffer | undefined): void

sendCustomCommandPromisified(command: number, input?: number | Buffer | undefined, outputBuffer?: Buffer | undefined): Promise | void

Sending custom commands to MOD IO boards with modified firmware

@param command

@param input — Can be either a number as a command parameter or a Buffer with more parameters

@param outputBuffer — Userd for returning values and isn't mandatory

setNewAddressSync(newAddress: number): void

setNewAddressPromisified(newAddress: number): Promise

Special conditions must be met in order to change the MOD IO board address To protect the device from accidental address updates the user should hold the on-board button pressed (not the RESET button!) while issuing the command. Successful update is indicated with the onboard status LED being lit for 2-3 seconds. Address is immediately updated so the board will not respond to its old address any more.

@param newAddress