mirror of
https://github.com/chirimen-oh/node-web-i2c.git
synced 2025-01-18 16:08:06 +00:00
dd94f1f8da
README ドキュメント追加 --------- Co-authored-by: bot <bot@example> Co-authored-by: akihiko kigure <akihiko.kigure@lifewood-m1.local> Co-authored-by: Kohei Watanabe <kou029w@gmail.com>
31 lines
619 B
Markdown
31 lines
619 B
Markdown
# node-web-i2c
|
|
|
|
I2C access with Node.js
|
|
|
|
## Usage
|
|
|
|
```js
|
|
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
|
|
|
|
- [TSDoc](http://chirimen.org/node-web-i2c/)
|
|
|
|
## Reference
|
|
|
|
- [Web I2C API for W3C Draft](http://browserobo.github.io/WebI2C)
|