diff --git a/MCP23008-MCP23017.md b/MCP23008-MCP23017.md index 592395c2..d10fff76 100644 --- a/MCP23008-MCP23017.md +++ b/MCP23008-MCP23017.md @@ -28,7 +28,61 @@ The MCP230xx chip (or breakout board) must be connected to the ESP8266 and the I ![https://github.com/andrethomas/images/raw/master/mcp230xx/Generic_Config_Menu.PNG](https://github.com/andrethomas/images/raw/master/mcp230xx/Generic_Config_Menu.PNG) -Once configured, a new option to configure the MCP230xx parameters will appear under the Configuration menu as follows: +There are two methods of configuration + +### Option #1 - Use sensor29 commands via serial, web console or MQTT messages + +This option only requires the main define to be uncommented prior to compilation + +`#define USE_MCP230xx` + +The format for sending configuration messages via serial, web console or MQTT messages are as follows: + +sensor29 _pin_,_pinmode_,_pullup_ + +Where: + +**pin** = The digital IO pin on the MCP230xx chip as a numeric e.g. 0 through 7 for MCP23008 and 0 through 15 for the MCP23017 + +**pinmode** = The operational mode of the pin as follows: + +**0** = Disabled + +**1** = INPUT (Floating - only telemetry data will be sent according to Tasmota firmware configuration intervals + +**2** = INPUT with INTERRUPT on CHANGE (Will send an MQTT output on state change from LOW to HIGH **and** HIGH to LOW) + +**3** = INPUT with INTERRUPT on CHANGE to **LOW** (Will send an MQTT output on state change **only** from HIGH to LOW) + +**4** = INPUT with INTERRUPT on CHANGE to **HIGH** (Will send an MQTT output on state change **only** from LOW to HIGH) + +**pinmode** = The operational mode of the pin as follows: + +**0** = Weak internal pull-up **DISABLED** + +**1** = Weak internal pull-up **ENABLED** + +Examples of this: + +`sensor27 4,1,0` - Will enable D4 for INPUT without internal pull-up resistor + +`sensor27 3,1,1` - Will enable D3 for INPUT with the internal pull-up resistor ENABLED + +`sensor27 5,2,1` - Will enable D5 for INPUT and report on change state from LOW to HIGH and HIGH to LOW via MQTT + +`sensor27 6,3,1` - Will enable D6 for INPUT and report on change state from HIGH to LOW (note pull-up is also enabled) + +`sensor27 2,4,0` - Will enable D2 for INPUT and report on change state from LOW to HIGH (note pull-up is not enabled) + +Pull-up resistor support is valid for all modes from 1 through 4 + +### Option #2 - Use Tasmota web interface to configure behaviour of MCP230xx pins + +For this to work the following additional line needs to be uncommented prior to compilation + +`#define USE_MCP230xx_webconfig` + +This will add a new option to configure the MCP230xx parameters will appear under the Configuration menu as follows: ![https://github.com/andrethomas/images/raw/master/mcp230xx/Configuration_Menu.png](https://github.com/andrethomas/images/raw/master/mcp230xx/Configuration_Menu.png) @@ -62,9 +116,16 @@ Again, this will depend on whether an MCP23008 or MCP23017 is used insofar that Interrupts will report for individual pins as and when the conditions which were configured are met and will look something like this: `21:50:05 MQT: stat/sonoff/RESULT = {"Time":"2018-07-05T21:50:05","MCP230XX_INT":{"Pin":"D1", "State":0}}` + `21:50:11 MQT: stat/sonoff/RESULT = {"Time":"2018-07-05T21:50:11","MCP230XX_INT":{"Pin":"D1", "State":1}}` -The state of enabled input pins will also be reported on the main Tasmota web interface as follows: +### Additional Option - Display pin state on Tasmota main web interface + +Uncommenting the following line will enable this feature + +`#define USE_MCP230xx_displaymain` + +This will cause the state of enabled input pins will also be reported on the main Tasmota web interface as follows: ![https://github.com/andrethomas/images/raw/master/mcp230xx/Web_Main.PNG](https://github.com/andrethomas/images/raw/master/mcp230xx/Web_Main.PNG)