A Node-RED wrapper of of the node-mcp23017 library for the I2C I/O Expander MCP23017 on a Raspberry Pi
It currently only supports writing to the chip. Though you can request a status which will generate a message per pin on the current state.
NOTE The outputs are inverted:
- ON gives a LOW on the pin.
- OFF gives a HIGH on the pin.
This is because I'm working with Sainsmart relay boards. See to-do below!
install via npm. just type the following in the terminal/console
cd ~/.node-red npm install node-red-contrib-mcp23017
This workflow shows a number of possible triggers feeding the common hardware interface node. The hardware is controlled via the contened of the payload (ON|OFF) and the Topic provided.
The topic path is not important, except it must end in a number 0..15 or the words ALL or STATUS.
These require a payload containing either "ON" or "OFF":
Status does not need or rather ignores the payload:
When the status topic is received, the node generates a message per pin as a json object and it can be routed out to MQTT as shown in the example above.
The topic is used to define the root of the outgoinf topic for status messages, in the example shown it says "devices/sprinklers/", this will results in "devices/sprinklers/0" through "devices/sprinlers/16" with their associated payloads.
Example Inject to get status
I want to add a checkbox to allow the ON/OFF to HIGH/LOW mapping to be inverted, to allow a more logical ON -> HIGH, OFF -> LOW.
Built using the node-mcp2301 library on github by kaihenzler (Kai Henzler)