From ac9cb053147230464751587024098918dec632bc Mon Sep 17 00:00:00 2001 From: andrethomas Date: Sun, 16 Sep 2018 22:08:29 +0200 Subject: [PATCH] Updated MCP23008 MCP23017 (markdown) --- MCP23008-MCP23017.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/MCP23008-MCP23017.md b/MCP23008-MCP23017.md index f5e2519c..def8a083 100644 --- a/MCP23008-MCP23017.md +++ b/MCP23008-MCP23017.md @@ -14,10 +14,14 @@ The chip, can however, be wired up quite easily especially if you can source the ![Manual Wiring for MCP23008 / MCP23017](https://github.com/andrethomas/images/blob/master/mcp230xx/mcp230xx_manual_wiring_v2.png) -You will need to pick an I2C address in either of the above scenario's but the driver will detect the address automatically. Address mapping according to pin A0,A1 and A2 as from the datasheet is as follows: +You will need to pick an I2C address in either of the above scenario's using the address mapping according to pin A0,A1 and A2 as from the datasheet as follows: ![MCP23008 / MCP23017 I2C Address Map](https://github.com/andrethomas/images/blob/master/mcp230xx/i2c_address_map.png) +You will need to define the address you are using in the user_config.h or user_config_override.h (if you use that method) for the driver to know which address the MCP23008/MCP23017 is expected to be found. + +`#define USE_MCP230xx_ADDR 0x20` + The MCP23008/MCP23017 chips allow for both INPUT and OUTPUT - Most of the functionality of the driver is focused on INPUT mode - especially since they allow interrupt reporting and are 5V tolerant. OUTPUT functionality is however available as pinmode 5 (Documented later in this Wiki) as an additional option for those who want to use the OUTPUT functionality using the sensor29 command at the expense of ~1Kbyte of flash. @@ -59,9 +63,14 @@ If you do not find it, check your wiring and pin configuration. The 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 +In order to use the MCP23008/MCP23017 in your build you need to uncomment the following two lines in your user_config.h or user_config_override.h as the MCP chip support is not enabled by default -`#define USE_MCP230xx` +``` +#define USE_MCP230xx +#define USE_MCP230xx_ADDR 0x20 +``` + +The MCP23008/MCP23017 supports I2C address range of 0x20 through 0x27 so be careful you are not using an address which is already used by another device (e.g. 0x27 is a known address for some I2C Liquid Crystal Displays) The behaviour of all pins on the MCP23008/MCP23017 can be reset to a specific setting/mode globally to simplify the initial configuration as follows