1
0
Fork 0
mirror of https://github.com/chirimen-oh/node-web-i2c.git synced 2025-04-04 04:06:24 +00:00
I2C access with Node.js
Find a file
2022-01-25 00:22:28 +09:00
.github/workflows temporary commit 2022-01-21 00:50:07 +09:00
.husky husky, lint-staged, prettier 導入によるコミット時の自動フォーマット () 2021-12-08 23:03:28 +09:00
docs permission modified 2022-01-25 00:22:28 +09:00
.eslintrc.yml permission modified 2022-01-25 00:22:28 +09:00
.gitignore permission modified 2022-01-25 00:22:28 +09:00
.lintstagedrc.yaml permission modified 2022-01-25 00:22:28 +09:00
index.ts permission modified 2022-01-25 00:22:28 +09:00
LICENSE permission modified 2022-01-25 00:22:28 +09:00
package.json permission modified 2022-01-25 00:22:28 +09:00
README.md permission modified 2022-01-25 00:22:28 +09:00
renovate.json permission modified 2022-01-25 00:22:28 +09:00
tsconfig.eslint.json permission modified 2022-01-25 00:22:28 +09:00
tsconfig.json permission modified 2022-01-25 00:22:28 +09:00
typedoc.json permission modified 2022-01-25 00:22:28 +09:00
yarn.lock permission modified 2022-01-25 00:22:28 +09:00

node-web-i2c

I2C access with Node.js

Usage

const { requestI2CAccess } = require("node-web-i2c");
const ADT7410 = require("@chirimen/adt7410");

const ADT7410_ADDR = 0x48;

async function main() {
  const i2cAccess = await requestI2CAccess();
  const port = i2cAccess.ports.get(1);
  const adt7410 = new ADT7410(port, ADT7410_ADDR);
  await adt7410.init();
  const temperature = await adt7410.read();
  console.log(`Temperature: ${temperature} ℃`);
}

main();

Document

Web I2C API