This module provides access to all I2C GPIO expansion pins via a 32 bit bus.
The expansion module has 2 ports and each port has 2 banks which are 8 bits wide.
These are mapped onto a single 32 bit value that can be read and written.
http://ww1.microchip.com/downloads/en/DeviceDoc/21952b.pdf
Usage: i2cset [-f] [-y] [-m MASK] [-r] I2CBUS CHIP-ADDRESS DATA-ADDRESS [VALUE] ... [MODE]
I2CBUS is an integer or an I2C bus name
ADDRESS is an integer (0x03 - 0x77)
MODE is one of:
c (byte, no value)
b (byte data, default)
w (word data)
i (I2C block data)
s (SMBus block data)
E.g. Switch on watchdog led =>
DIR:0=out:
i2cset -y 1 0x21 0x0 0xBF
i2cset -y 1 0x21 0x12 0x40
Close Valve 0
DIR:0=out:
i2cset -y 1 0x20 0x1 0xFE
i2cset -y 1 0x20 0x13 0x1
Switch On Heater
DIR:0=out:
i2cset -y 1 0x21 0x0 0xFD
i2cset -y 1 0x21 0x12 0x2
chip data value pin
Flow 7 0x21 0x13 0x80 31 In
Flow 6 0x21 0x13 0x40 30 In
Flow 5 0x21 0x13 0x20 29 In
Flow 4 0x21 0x13 0x10 28 In
Flow 3 0x21 0x13 0x8 27 In
Heater(was Flow 2)0x21 0x13 0x4 26 In
Flow 1 0x21 0x13 0x2 25 In
Flow 0 0x21 0x13 0x1 24 In
chip data value pin
Watchdog Halt 0x21 0x12 0x80 23 In
Watchdog LED 0x21 0x12 0x40 22 Out 1 = On
//Heater 0x21 0x12 0x20 21 Out 1 = On
//Heater 0x21 0x12 0x10 16 Out 1 = On
//Heater 0x21 0x12 0x02 17 Out 1 = On
Relay ? 0x20 0x13 0x80 15 Out
Relay ? 0x20 0x13 0x40 14 Out
Relay ? 0x20 0x13 0x20 13 Out
Pump 0 0x20 0x13 0x10 12 Out 0 = On
Valve 6 0x20 0x13 0x8 11 Out 0 = Open
Valve 4 0x20 0x13 0x4 10 Out 0 = Open
Valve 2 0x20 0x13 0x2 9 Out 0 = Open
valve 0 0x20 0x13 0x1 8 Out 0 = Open
Valve 1 0x20 0x12 0x80 7 Out 0 = Open
Valve 3 0x20 0x12 0x40 6 Out 0 = Open
Valve 5 0x20 0x12 0x20 5 Out 0 = Open
Valve 7 0x20 0x12 0x10 4 Out 0 = Open
Pump 1 0x20 0x12 0x8 3 Out
Relay ? 0x20 0x12 0x4 2 Out
Relay ? 0x20 0x12 0x2 1 Out
Relay ? 0x20 0x12 0x1 0 Out
Requires
- module:brewlog
- module:node-mcp23017
- module:child_process
Members
setDir
static
Set direction of a single bit
I2C
inner
Raspi I2C is part of the Raspi.js suite that provides access to the hardware I2C
on pins 3 (SDA0) and 5 (SCL0).
Methods
init()
static
Initialise an individual bit.
init()
static
Initialise an individual bit.
{number, dir, value} bitInfo
readBit(bit)
static
Read any single bit
Arguments:
-
bit
(number)
 Bit number [0:31]
readBit(bit)
static
Read any single bit
Arguments:
-
bit
(number)
 Bit number [0:31]
setDir(bit, value)
static
Set direction of a single bit
Arguments:
-
bit
(number)
 Bit number [0:31]
-
value
(number)
 DIR_INPUT | DIR_OUTPUT
toggleBit(n)
static
Toggle any bit
Arguments:
-
n
(number)
 Bit number [0:31]
toggleBit(bit)
static
Toggle any bit
Arguments:
-
bit
(number)
 Bit number [0:31]
writeBit(bit, value)
static
Set or clear any bit
Arguments:
-
bit
(number)
 Bit number [0:31]
-
value
(number)
 0 or 1
writeBit(bit, value)
static
Set or clear any bit
Arguments:
-
bit
(number)
 Bit number [0:31]
-
value
(number)
 0 or 1
getBit(byte, bit)
inner
Arguments:
-
byte
(Number)
-
bit
(Number)
getBit(byte, bit)
inner
Arguments:
-
byte
(Number)
-
bit
(Number)
writeReg(data, bit, value)
inner
Write a bit into the register
| @param {Number} bankAddr
Arguments:
-
data
(Number)
-
bit
(Number)
-
value
(Number)
writeReg(currentByte, bit, value)
inner
Write a bit into the register
| @param {Number} bankAddr
Arguments:
-
currentByte
(Number)
-
bit
(Number)
-
value
(Number)
init() static
Initialise an individual bit.
init() static
Initialise an individual bit.
{number, dir, value} bitInfo
readBit(bit) static
Read any single bit
Arguments:
-
bit
(number)
 Bit number [0:31]
readBit(bit) static
Read any single bit
Arguments:
-
bit
(number)
 Bit number [0:31]
setDir(bit, value) static
Set direction of a single bit
Arguments:
-
bit
(number)
 Bit number [0:31] -
value
(number)
 DIR_INPUT | DIR_OUTPUT
toggleBit(n) static
Toggle any bit
Arguments:
-
n
(number)
 Bit number [0:31]
toggleBit(bit) static
Toggle any bit
Arguments:
-
bit
(number)
 Bit number [0:31]
writeBit(bit, value) static
Set or clear any bit
Arguments:
-
bit
(number)
 Bit number [0:31] -
value
(number)
 0 or 1
writeBit(bit, value) static
Set or clear any bit
Arguments:
-
bit
(number)
 Bit number [0:31] -
value
(number)
 0 or 1
getBit(byte, bit) inner
Arguments:
-
byte
(Number)
-
bit
(Number)
getBit(byte, bit) inner
Arguments:
-
byte
(Number)
-
bit
(Number)
writeReg(data, bit, value) inner
Write a bit into the register
| @param {Number} bankAddr
Arguments:
-
data
(Number)
-
bit
(Number)
-
value
(Number)
writeReg(currentByte, bit, value) inner
Write a bit into the register
| @param {Number} bankAddr
Arguments:
-
currentByte
(Number)
-
bit
(Number)
-
value
(Number)