mirror of
https://github.com/chirimen-oh/node-web-i2c.git
synced 2025-01-18 08:05:10 +00:00
docs: use @chirimen/adt7410
This commit is contained in:
parent
74b8a5db93
commit
16cbc86aef
1 changed files with 4 additions and 3 deletions
|
@ -6,15 +6,16 @@ I2C access with Node.js
|
|||
|
||||
```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 i2cSlave = await port.open(ADT7410_ADDR);
|
||||
const temperature =
|
||||
(((await i2cSlave.read8(0x00)) << 8) + (await i2cSlave.read8(0x01))) / 128;
|
||||
const adt7410 = new ADT7410(port, ADT7410_ADDR);
|
||||
await adt7410.init();
|
||||
const temperature = await adt7410.read();
|
||||
console.log(`Temperature: ${temperature} ℃`);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue