i2c-bus-promise
v2.0.0
Published
A promise wrapper around the i2c-bus module
Downloads
7
Readme
ATTENTION!
i2c-bus > 5.0.0 now has a promise API included. If you're unable to upgrade, you can use this module - this module serves as a polyfill.
i2c-bus-promise
Nothing complicated here. Just a promise wrapper for i2c-bus.
i2c-bus dependency defined as ^4
to allow wide compatibility with existing version you may have installed already.
Install
npm install i2c-bus-promise
Use
const i2c = require('i2c-bus-promise');
i2c.openPromisified(1).then(async bus => {
console.log(await bus.scan())
})
BYO[i2c-bus]
If you already have an i2c-bus bus
instance, you can just wrap it...
const i2c = require('i2c-bus');
const wrap = require('i2c-bus-promise').wrap;
const bus = wrap(i2c.open(1, async (err) => {
if (err) throw err
console.log(await bus.scan())
}))
License
MIT