mirror of https://github.com/arendst/Tasmota.git
Updated MCP23008 MCP23017 (markdown)
parent
e76cb49eda
commit
8e8865202e
|
@ -28,15 +28,35 @@ 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)
|
||||
|
||||
There are two methods of configuration
|
||||
|
||||
### Option #1 - Use sensor29 commands via serial, web console or MQTT messages
|
||||
Configuration of MCP23008/MCP23017 by using 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:
|
||||
There is a single command that may be used for resetting all pins to INPUT without the weak internal pull-up resistor DISABLED as follows:
|
||||
|
||||
`sensor29 reset`
|
||||
|
||||
This will be confirmed by a response like this - note the 99's indicated in each value to differentiate it from other MQTT responses
|
||||
|
||||
`MQT: stat/sonoff/RESULT = {"Sensor29":{"D":99,"MODE":99,"PULL-UP":99}}`
|
||||
|
||||
You may also query the existing configuration for a particular pin using
|
||||
|
||||
`sensor29 pin,?`
|
||||
|
||||
For example:
|
||||
|
||||
`sensor29 0,?`
|
||||
|
||||
Will report as follows:
|
||||
|
||||
`MQT: stat/sonoff/RESULT = {"Sensor29":{"D":0,"MODE":1,"PULL-UP":0}}`
|
||||
|
||||
Confirming that the pin is in pinmode 1 and that the pull-up resistor is not enabled.
|
||||
|
||||
The format for sending configuration messages for individual pins via serial, web console or MQTT messages are as follows:
|
||||
|
||||
`sensor29 pin,pinmode,pullup`
|
||||
|
||||
|
@ -76,42 +96,19 @@ Examples of this:
|
|||
|
||||
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)
|
||||
|
||||
It sometimes takes a few seconds after a reboot for the menu item to become available. Refresh the page if it does not show - if it never shows it means that the chip is not detected... check wiring and logs if the chip is detected.
|
||||
|
||||
Entering the marked menu item will provide the configuration for the MCP230xx chip which you have connected and will look as follows:
|
||||
|
||||
![https://github.com/andrethomas/images/raw/master/mcp230xx/MCP230xx_Config.PNG](https://github.com/andrethomas/images/raw/master/mcp230xx/MCP230xx_Config.PNG)
|
||||
|
||||
The above image is for an MCP23016 which has two 8 pin ports - PORTA bit 0 through 7 is marked as D0 through D7 whereas PORTB bit 0 through 7 is marked as D8 through D15 effectively making up a 16-bit input configuration.
|
||||
|
||||
If you have an MCP23008 connected it will only list 8 bits corresponding to the 8 input pins and marked as D0 through D7 on this configuration page.
|
||||
|
||||
Each of the input pins has two main settings:
|
||||
|
||||
* Enable Pullup checkbox enables the weak pull-up resistor built into the MCP230xx chip.
|
||||
|
||||
Each pin can be in the following modes:
|
||||
|
||||
* Disabled - Will not report anything in telemetry, log or to mqtt
|
||||
* Input (Int on Change) - Will respond with immediate telemetry, log and mqtt for the specific pin which has changed either from 0 to 1 or from 1 to 0 (Low to High or High to Low)
|
||||
* Input (Int on Low) - Will only respond with immediate telemetry, log and mqtt for the specific pin if the said pin was pulled down to ground (0, or Low)
|
||||
* Input (Int on High) - Will only respond with immediate telemetry, log and mqtt for the specific pin if the said pin was pulled high to VCC (3.3V or 5V), that would be 1 or High in binary for the specific pin.
|
||||
* (0) Disabled - Will not report anything in telemetry, log or to mqtt
|
||||
* (1) Input - Will report to telemetry, log or mqtt based on telemetry interval settings in Tasmota
|
||||
* (2) Input (Int on Change) - Will respond with immediate telemetry, log and mqtt for the specific pin which has changed either from 0 to 1 or from 1 to 0 (Low to High or High to Low)
|
||||
* (3) Input (Int on Low) - Will only respond with immediate telemetry, log and mqtt for the specific pin if the said pin was pulled down to ground (0, or Low)
|
||||
* (4) Input (Int on High) - Will only respond with immediate telemetry, log and mqtt for the specific pin if the said pin was pulled high to VCC (3.3V or 5V), that would be 1 or High in binary for the specific pin.
|
||||
|
||||
Default telemetry logging will occur for all pins as per the configured logging interval of the ESP8266 as configured in the Tasmota firmware options. The telemetry logging will push out to log and mqtt a JSON as follows:
|
||||
|
||||
`tele/sonoff/SENSOR = {"Time":"2018-06-30T18:31:49","MCP23008":{"D0":0, "D1":0, "D2":0, "D3":0, "D4":0, "D5":0, "D6":0, "D7":0 }}`
|
||||
|
||||
Again, this will depend on whether an MCP23008 or MCP23017 is used insofar that the number of pins/bits reported will be 8 or 16 respectively.
|
||||
Again, this will depend on whether an MCP23008 or MCP23017 is used insofar that the number of pins/bits reported will be 8 (0 to 7) or 16 (0 to 15) respectively.
|
||||
|
||||
Interrupts will report for individual pins as and when the conditions which were configured are met and will look something like this:
|
||||
|
||||
|
@ -119,14 +116,3 @@ Interrupts will report for individual pins as and when the conditions which were
|
|||
|
||||
`21:50:11 MQT: stat/sonoff/RESULT = {"Time":"2018-07-05T21:50:11","MCP230XX_INT":{"Pin":"D1", "State":1}}`
|
||||
|
||||
### 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)
|
||||
|
||||
Only pins that are enabled will be listed. If an input pin is disabled it will be excluded in this list.
|
Loading…
Reference in New Issue