raspihats
Node.js package for interfacing Raspberry Pi add-on boards located at raspihats.com
Installation
$ npm install raspihats --save
I2C clock stretch timeout
It's important for the I2C clock stretch timeout to have the right value before issuing requests to a I2C-HAT, cd to 'node_modules/raspihats' and run the following command to set the right clock stretch timeout:
$ sudo npm run i2c_clks_timeout
I2C-HAT usage example
var raspihats = ;var DI6acDQ6rly = raspihatsi2cHatsDI6acDQ6rly; var b = 0x60; // All the following methods will issue a request and get a response from the board over the I2C bus.b; // reads board nameb; // reads firmware version//b.reset(); // resets the board, wait at least 1ms after reset before issuing another requestb; // reads status word, bits [0: power on reset, 1: software reset, 2: watchdog reset] // Digital InputsbDI; // read all digital input channelsbDI; // read single digital input channel // Digital OutputsbDQ; // write all digital output channelsbDQ; // write single digital output channel bDQ; // read all digital output channelsbDQ; // read single digital output channel
Release History
-
1.0.0 Initial release
Supported functionality:
- Basic(read board name, read firmware version, read status word, reset)
- Communication WatchDog(read/write period)
- Digital Inputs(read value, read channel, read channel counter, reset channel counter)
- Digital Outputs(read/write value, read/write channel, read/write PowerOnValue, read/write SafetyValue)
Supported boards:
-
1.1.0 Added DQ8rly
Added boards:
-
1.1.1 Small fix
Modified exception message thrown if an unexpected board is found at the desired address.
-
1.1.2 Updated i2c-bus dependency version and small fix
Now using i2c-bus@5.2.0, and using Buffer.alloc instead of new Buffer.
License
MIT