I2C access with Node.js
Find a file
2019-10-18 10:27:56 +09:00
.gitignore initial commit 2019-10-18 03:23:29 +09:00
index.d.ts initial commit 2019-10-18 03:23:29 +09:00
index.js initial commit 2019-10-18 03:23:29 +09:00
index.ts initial commit 2019-10-18 03:23:29 +09:00
package.json initial commit 2019-10-18 03:23:29 +09:00
README.md docs: fix undefined variable 2019-10-18 10:27:56 +09:00
tsconfig.json initial commit 2019-10-18 03:23:29 +09:00
yarn.lock initial commit 2019-10-18 03:23:29 +09:00

@notweb/i2c

I2C access with Node.js

Usage

const { requestI2CAccess } = require("@notweb/i2c");

const ADT7410_ADDR = 0x48;

async function main() {
  const i2cAccess = await requestI2CAccess();
  const port = i2cAccess.ports.get(1);
  const i2cSlave = await port.open(ADT7410_ADDR);
  const temperature =
    (((await i2cSlave.read8(0x00)) << 8) + (await i2cSlave.read8(0x01))) / 128;
  console.log(`Temperature: ${temperature} ℃`);
}

main();

Document

Web I2C API