Remarks
Mcp23xxxx | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
The MCP chip family, referred to as MCP23XXX to represent the variations, is a digital I/O expander chip that uses I2C to communicate. It can be used to add additional digital input and output ports to Meadow and can be combined with up to eight MCP23xxx chips in total, providing 64 additional ports.
MCP23XXX chips are ubiquitous in the hardware world and is the typical interface chip for common I2C LCD backpacks, with the 74595 chip being the typical interface chip for SPI LCD backpacks.
MCP Chip Family
The MCP23XXX family includes the 8-bit MCP23008 and also includes the MCP23017, which is a 16-bit version of the MCP23008, offering 16 digital ports in total, and the MCP23S08 and MCP23S017 which are SPI versions of the MCP23008 and MCP23017, respectively.
Chip Addressing
The I2C address of the chip is configurable via the address pins and is in the binary form of 0100[A2][A1][A0]
, where A2
, A1
, and A0
refer to the three address pins on the chip:
For example, if all address pins were tied to ground, then the address of the chip would be 0100000
in binary, or 0x20
in hex, and 32
in decimal.
The I2C addresses can then be as follows, where 0
represents an address pin connected to ground, and 1
represents an address pin connected to 3.3V
:
Address Header | A2 | A1 | A0 | Resulting Hex Address | Resulting Decimal Address |
---|---|---|---|---|---|
0100 |
0 |
0 |
0 |
0x20 |
32 |
0100 |
0 |
0 |
1 |
0x21 |
33 |
0100 |
0 |
1 |
0 |
0x22 |
34 |
0100 |
0 |
1 |
1 |
0x23 |
35 |
0100 |
1 |
0 |
0 |
0x24 |
36 |
0100 |
1 |
0 |
1 |
0x25 |
37 |
0100 |
1 |
1 |
0 |
0x26 |
38 |
0100 |
1 |
1 |
1 |
0x27 |
39 |
Because there are 8 address possibilities, it's possible to put 8 MCP23XXX chips on a single I2C bus.
To make this simpler, when instantiating one of the MCP23XXX family of chip objects, there is a constructor overload that takes the address pin configurations instead of an address, so that Meadow.Foundation uses the appropriate address based on the pins, instead of requiring a pre-computed address.
Other Pins
In addition to the address pins, there are a number of other pins that must be connected up:
- Not Reset - The
RESET
pin is actually a "Not Reset." The line above "Reset" means "not." So unless that pin is pulled high (3.3V
), the chip will reset itself at random times and you'll get connection errors. - SCL and SDA - The
SCL
andSDA
pins are the I2C clock and data pins and go to theSC
andSD
pins on the Meadow, respectively. Each of these should also generally be pulled high (3.3V
) via a4.7kΩ
resistor. See the I2C guide for more information. - INT - The
INT
pin is for interrupt notifications, and is only necessary when using the GPIO pins in input mode and you want an event raised when the input value changes. - VSS and VDD - These go to ground and 3.3V power, respectively, and power the chip.
Code Examples
You can find code examples and links to sample projects for each of the MCP23XXX families and specific chips.
Characteristic | Locus |
---|---|
Inheritance | object > Mcp23xxx > Mcp23x0x > Mcp23x1x |
Implements | IDigitalInputOutputController IDigitalInputController IDigitalOutputController ISpiPeripheral II2cPeripheral IDigitalInterruptController IPinController |
Inherited Members | object.Equals(object) object.Equals(object, object) object.GetHashCode() object.GetType() object.MemberwiseClone() object.ReferenceEquals(object, object) object.ToString() |
Namespace | Meadow.Foundation.ICs.IOExpanders |
Assembly | Mcp23xxx.dll |
Syntax
public abstract class Mcp23xxx : IDigitalInputOutputController, IDigitalInputController, IDigitalOutputController, ISpiPeripheral, II2cPeripheral, IDigitalInterruptController, IPinController
Constructors
Mcp23xxx(II2cBus, byte, IDigitalInterruptPort?, IDigitalOutputPort?)
Mcp23xxx base class constructor using I2C
Declaration
protected Mcp23xxx(II2cBus i2cBus, byte address, IDigitalInterruptPort? interruptPort = null, IDigitalOutputPort? resetPort = null)
Parameters
Type | Name | Description |
---|---|---|
II2cBus | i2cBus | The I2C bus |
byte | address | The I2C address |
IDigitalInterruptPort | interruptPort | Optional interrupt port, needed for input interrupts (pins 1-8) |
IDigitalOutputPort | resetPort | Optional Meadow output port used to reset the mcp expander |
Remarks
Mcp23xxxx | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
The MCP chip family, referred to as MCP23XXX to represent the variations, is a digital I/O expander chip that uses I2C to communicate. It can be used to add additional digital input and output ports to Meadow and can be combined with up to eight MCP23xxx chips in total, providing 64 additional ports.
MCP23XXX chips are ubiquitous in the hardware world and is the typical interface chip for common I2C LCD backpacks, with the 74595 chip being the typical interface chip for SPI LCD backpacks.
MCP Chip Family
The MCP23XXX family includes the 8-bit MCP23008 and also includes the MCP23017, which is a 16-bit version of the MCP23008, offering 16 digital ports in total, and the MCP23S08 and MCP23S017 which are SPI versions of the MCP23008 and MCP23017, respectively.
Chip Addressing
The I2C address of the chip is configurable via the address pins and is in the binary form of 0100[A2][A1][A0]
, where A2
, A1
, and A0
refer to the three address pins on the chip:
For example, if all address pins were tied to ground, then the address of the chip would be 0100000
in binary, or 0x20
in hex, and 32
in decimal.
The I2C addresses can then be as follows, where 0
represents an address pin connected to ground, and 1
represents an address pin connected to 3.3V
:
Address Header | A2 | A1 | A0 | Resulting Hex Address | Resulting Decimal Address |
---|---|---|---|---|---|
0100 |
0 |
0 |
0 |
0x20 |
32 |
0100 |
0 |
0 |
1 |
0x21 |
33 |
0100 |
0 |
1 |
0 |
0x22 |
34 |
0100 |
0 |
1 |
1 |
0x23 |
35 |
0100 |
1 |
0 |
0 |
0x24 |
36 |
0100 |
1 |
0 |
1 |
0x25 |
37 |
0100 |
1 |
1 |
0 |
0x26 |
38 |
0100 |
1 |
1 |
1 |
0x27 |
39 |
Because there are 8 address possibilities, it's possible to put 8 MCP23XXX chips on a single I2C bus.
To make this simpler, when instantiating one of the MCP23XXX family of chip objects, there is a constructor overload that takes the address pin configurations instead of an address, so that Meadow.Foundation uses the appropriate address based on the pins, instead of requiring a pre-computed address.
Other Pins
In addition to the address pins, there are a number of other pins that must be connected up:
- Not Reset - The
RESET
pin is actually a "Not Reset." The line above "Reset" means "not." So unless that pin is pulled high (3.3V
), the chip will reset itself at random times and you'll get connection errors. - SCL and SDA - The
SCL
andSDA
pins are the I2C clock and data pins and go to theSC
andSD
pins on the Meadow, respectively. Each of these should also generally be pulled high (3.3V
) via a4.7kΩ
resistor. See the I2C guide for more information. - INT - The
INT
pin is for interrupt notifications, and is only necessary when using the GPIO pins in input mode and you want an event raised when the input value changes. - VSS and VDD - These go to ground and 3.3V power, respectively, and power the chip.
Code Examples
You can find code examples and links to sample projects for each of the MCP23XXX families and specific chips.
Mcp23xxx(ISpiBus, IDigitalOutputPort, IDigitalInterruptPort?, IDigitalOutputPort?)
Mcp23xxx base class constructor using SPI
Declaration
protected Mcp23xxx(ISpiBus spiBus, IDigitalOutputPort chipSelectPort, IDigitalInterruptPort? interruptPort = null, IDigitalOutputPort? resetPort = null)
Parameters
Type | Name | Description |
---|---|---|
ISpiBus | spiBus | The SPI bus |
IDigitalOutputPort | chipSelectPort | Chip select port |
IDigitalInterruptPort | interruptPort | Optional interrupt port, needed for input interrupts (pins 1-8) |
IDigitalOutputPort | resetPort | Optional Meadow output port used to reset the mcp expander |
Remarks
Mcp23xxxx | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
The MCP chip family, referred to as MCP23XXX to represent the variations, is a digital I/O expander chip that uses I2C to communicate. It can be used to add additional digital input and output ports to Meadow and can be combined with up to eight MCP23xxx chips in total, providing 64 additional ports.
MCP23XXX chips are ubiquitous in the hardware world and is the typical interface chip for common I2C LCD backpacks, with the 74595 chip being the typical interface chip for SPI LCD backpacks.
MCP Chip Family
The MCP23XXX family includes the 8-bit MCP23008 and also includes the MCP23017, which is a 16-bit version of the MCP23008, offering 16 digital ports in total, and the MCP23S08 and MCP23S017 which are SPI versions of the MCP23008 and MCP23017, respectively.
Chip Addressing
The I2C address of the chip is configurable via the address pins and is in the binary form of 0100[A2][A1][A0]
, where A2
, A1
, and A0
refer to the three address pins on the chip:
For example, if all address pins were tied to ground, then the address of the chip would be 0100000
in binary, or 0x20
in hex, and 32
in decimal.
The I2C addresses can then be as follows, where 0
represents an address pin connected to ground, and 1
represents an address pin connected to 3.3V
:
Address Header | A2 | A1 | A0 | Resulting Hex Address | Resulting Decimal Address |
---|---|---|---|---|---|
0100 |
0 |
0 |
0 |
0x20 |
32 |
0100 |
0 |
0 |
1 |
0x21 |
33 |
0100 |
0 |
1 |
0 |
0x22 |
34 |
0100 |
0 |
1 |
1 |
0x23 |
35 |
0100 |
1 |
0 |
0 |
0x24 |
36 |
0100 |
1 |
0 |
1 |
0x25 |
37 |
0100 |
1 |
1 |
0 |
0x26 |
38 |
0100 |
1 |
1 |
1 |
0x27 |
39 |
Because there are 8 address possibilities, it's possible to put 8 MCP23XXX chips on a single I2C bus.
To make this simpler, when instantiating one of the MCP23XXX family of chip objects, there is a constructor overload that takes the address pin configurations instead of an address, so that Meadow.Foundation uses the appropriate address based on the pins, instead of requiring a pre-computed address.
Other Pins
In addition to the address pins, there are a number of other pins that must be connected up:
- Not Reset - The
RESET
pin is actually a "Not Reset." The line above "Reset" means "not." So unless that pin is pulled high (3.3V
), the chip will reset itself at random times and you'll get connection errors. - SCL and SDA - The
SCL
andSDA
pins are the I2C clock and data pins and go to theSC
andSD
pins on the Meadow, respectively. Each of these should also generally be pulled high (3.3V
) via a4.7kΩ
resistor. See the I2C guide for more information. - INT - The
INT
pin is for interrupt notifications, and is only necessary when using the GPIO pins in input mode and you want an event raised when the input value changes. - VSS and VDD - These go to ground and 3.3V power, respectively, and power the chip.
Code Examples
You can find code examples and links to sample projects for each of the MCP23XXX families and specific chips.
Fields
_lock
object for using lock() to do thread sync
Declaration
protected object _lock
Field Value
Type | Description |
---|---|
object |
Remarks
Mcp23xxxx | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
The MCP chip family, referred to as MCP23XXX to represent the variations, is a digital I/O expander chip that uses I2C to communicate. It can be used to add additional digital input and output ports to Meadow and can be combined with up to eight MCP23xxx chips in total, providing 64 additional ports.
MCP23XXX chips are ubiquitous in the hardware world and is the typical interface chip for common I2C LCD backpacks, with the 74595 chip being the typical interface chip for SPI LCD backpacks.
MCP Chip Family
The MCP23XXX family includes the 8-bit MCP23008 and also includes the MCP23017, which is a 16-bit version of the MCP23008, offering 16 digital ports in total, and the MCP23S08 and MCP23S017 which are SPI versions of the MCP23008 and MCP23017, respectively.
Chip Addressing
The I2C address of the chip is configurable via the address pins and is in the binary form of 0100[A2][A1][A0]
, where A2
, A1
, and A0
refer to the three address pins on the chip:
For example, if all address pins were tied to ground, then the address of the chip would be 0100000
in binary, or 0x20
in hex, and 32
in decimal.
The I2C addresses can then be as follows, where 0
represents an address pin connected to ground, and 1
represents an address pin connected to 3.3V
:
Address Header | A2 | A1 | A0 | Resulting Hex Address | Resulting Decimal Address |
---|---|---|---|---|---|
0100 |
0 |
0 |
0 |
0x20 |
32 |
0100 |
0 |
0 |
1 |
0x21 |
33 |
0100 |
0 |
1 |
0 |
0x22 |
34 |
0100 |
0 |
1 |
1 |
0x23 |
35 |
0100 |
1 |
0 |
0 |
0x24 |
36 |
0100 |
1 |
0 |
1 |
0x25 |
37 |
0100 |
1 |
1 |
0 |
0x26 |
38 |
0100 |
1 |
1 |
1 |
0x27 |
39 |
Because there are 8 address possibilities, it's possible to put 8 MCP23XXX chips on a single I2C bus.
To make this simpler, when instantiating one of the MCP23XXX family of chip objects, there is a constructor overload that takes the address pin configurations instead of an address, so that Meadow.Foundation uses the appropriate address based on the pins, instead of requiring a pre-computed address.
Other Pins
In addition to the address pins, there are a number of other pins that must be connected up:
- Not Reset - The
RESET
pin is actually a "Not Reset." The line above "Reset" means "not." So unless that pin is pulled high (3.3V
), the chip will reset itself at random times and you'll get connection errors. - SCL and SDA - The
SCL
andSDA
pins are the I2C clock and data pins and go to theSC
andSD
pins on the Meadow, respectively. Each of these should also generally be pulled high (3.3V
) via a4.7kΩ
resistor. See the I2C guide for more information. - INT - The
INT
pin is for interrupt notifications, and is only necessary when using the GPIO pins in input mode and you want an event raised when the input value changes. - VSS and VDD - These go to ground and 3.3V power, respectively, and power the chip.
Code Examples
You can find code examples and links to sample projects for each of the MCP23XXX families and specific chips.
Properties
DefaultI2cAddress
The default I2C address for the peripheral
Declaration
public byte DefaultI2cAddress { get; }
Property Value
Type | Description |
---|---|
byte |
Remarks
Mcp23xxxx | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
The MCP chip family, referred to as MCP23XXX to represent the variations, is a digital I/O expander chip that uses I2C to communicate. It can be used to add additional digital input and output ports to Meadow and can be combined with up to eight MCP23xxx chips in total, providing 64 additional ports.
MCP23XXX chips are ubiquitous in the hardware world and is the typical interface chip for common I2C LCD backpacks, with the 74595 chip being the typical interface chip for SPI LCD backpacks.
MCP Chip Family
The MCP23XXX family includes the 8-bit MCP23008 and also includes the MCP23017, which is a 16-bit version of the MCP23008, offering 16 digital ports in total, and the MCP23S08 and MCP23S017 which are SPI versions of the MCP23008 and MCP23017, respectively.
Chip Addressing
The I2C address of the chip is configurable via the address pins and is in the binary form of 0100[A2][A1][A0]
, where A2
, A1
, and A0
refer to the three address pins on the chip:
For example, if all address pins were tied to ground, then the address of the chip would be 0100000
in binary, or 0x20
in hex, and 32
in decimal.
The I2C addresses can then be as follows, where 0
represents an address pin connected to ground, and 1
represents an address pin connected to 3.3V
:
Address Header | A2 | A1 | A0 | Resulting Hex Address | Resulting Decimal Address |
---|---|---|---|---|---|
0100 |
0 |
0 |
0 |
0x20 |
32 |
0100 |
0 |
0 |
1 |
0x21 |
33 |
0100 |
0 |
1 |
0 |
0x22 |
34 |
0100 |
0 |
1 |
1 |
0x23 |
35 |
0100 |
1 |
0 |
0 |
0x24 |
36 |
0100 |
1 |
0 |
1 |
0x25 |
37 |
0100 |
1 |
1 |
0 |
0x26 |
38 |
0100 |
1 |
1 |
1 |
0x27 |
39 |
Because there are 8 address possibilities, it's possible to put 8 MCP23XXX chips on a single I2C bus.
To make this simpler, when instantiating one of the MCP23XXX family of chip objects, there is a constructor overload that takes the address pin configurations instead of an address, so that Meadow.Foundation uses the appropriate address based on the pins, instead of requiring a pre-computed address.
Other Pins
In addition to the address pins, there are a number of other pins that must be connected up:
- Not Reset - The
RESET
pin is actually a "Not Reset." The line above "Reset" means "not." So unless that pin is pulled high (3.3V
), the chip will reset itself at random times and you'll get connection errors. - SCL and SDA - The
SCL
andSDA
pins are the I2C clock and data pins and go to theSC
andSD
pins on the Meadow, respectively. Each of these should also generally be pulled high (3.3V
) via a4.7kΩ
resistor. See the I2C guide for more information. - INT - The
INT
pin is for interrupt notifications, and is only necessary when using the GPIO pins in input mode and you want an event raised when the input value changes. - VSS and VDD - These go to ground and 3.3V power, respectively, and power the chip.
Code Examples
You can find code examples and links to sample projects for each of the MCP23XXX families and specific chips.
DefaultSpiBusMode
The default SPI bus mode for the device
Declaration
public SpiClockConfiguration.Mode DefaultSpiBusMode { get; }
Property Value
Type | Description |
---|---|
SpiClockConfiguration.Mode |
Remarks
Mcp23xxxx | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
The MCP chip family, referred to as MCP23XXX to represent the variations, is a digital I/O expander chip that uses I2C to communicate. It can be used to add additional digital input and output ports to Meadow and can be combined with up to eight MCP23xxx chips in total, providing 64 additional ports.
MCP23XXX chips are ubiquitous in the hardware world and is the typical interface chip for common I2C LCD backpacks, with the 74595 chip being the typical interface chip for SPI LCD backpacks.
MCP Chip Family
The MCP23XXX family includes the 8-bit MCP23008 and also includes the MCP23017, which is a 16-bit version of the MCP23008, offering 16 digital ports in total, and the MCP23S08 and MCP23S017 which are SPI versions of the MCP23008 and MCP23017, respectively.
Chip Addressing
The I2C address of the chip is configurable via the address pins and is in the binary form of 0100[A2][A1][A0]
, where A2
, A1
, and A0
refer to the three address pins on the chip:
For example, if all address pins were tied to ground, then the address of the chip would be 0100000
in binary, or 0x20
in hex, and 32
in decimal.
The I2C addresses can then be as follows, where 0
represents an address pin connected to ground, and 1
represents an address pin connected to 3.3V
:
Address Header | A2 | A1 | A0 | Resulting Hex Address | Resulting Decimal Address |
---|---|---|---|---|---|
0100 |
0 |
0 |
0 |
0x20 |
32 |
0100 |
0 |
0 |
1 |
0x21 |
33 |
0100 |
0 |
1 |
0 |
0x22 |
34 |
0100 |
0 |
1 |
1 |
0x23 |
35 |
0100 |
1 |
0 |
0 |
0x24 |
36 |
0100 |
1 |
0 |
1 |
0x25 |
37 |
0100 |
1 |
1 |
0 |
0x26 |
38 |
0100 |
1 |
1 |
1 |
0x27 |
39 |
Because there are 8 address possibilities, it's possible to put 8 MCP23XXX chips on a single I2C bus.
To make this simpler, when instantiating one of the MCP23XXX family of chip objects, there is a constructor overload that takes the address pin configurations instead of an address, so that Meadow.Foundation uses the appropriate address based on the pins, instead of requiring a pre-computed address.
Other Pins
In addition to the address pins, there are a number of other pins that must be connected up:
- Not Reset - The
RESET
pin is actually a "Not Reset." The line above "Reset" means "not." So unless that pin is pulled high (3.3V
), the chip will reset itself at random times and you'll get connection errors. - SCL and SDA - The
SCL
andSDA
pins are the I2C clock and data pins and go to theSC
andSD
pins on the Meadow, respectively. Each of these should also generally be pulled high (3.3V
) via a4.7kΩ
resistor. See the I2C guide for more information. - INT - The
INT
pin is for interrupt notifications, and is only necessary when using the GPIO pins in input mode and you want an event raised when the input value changes. - VSS and VDD - These go to ground and 3.3V power, respectively, and power the chip.
Code Examples
You can find code examples and links to sample projects for each of the MCP23XXX families and specific chips.
DefaultSpiBusSpeed
The default SPI bus speed for the device
Declaration
public Frequency DefaultSpiBusSpeed { get; }
Property Value
Type | Description |
---|---|
Frequency |
Remarks
Mcp23xxxx | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
The MCP chip family, referred to as MCP23XXX to represent the variations, is a digital I/O expander chip that uses I2C to communicate. It can be used to add additional digital input and output ports to Meadow and can be combined with up to eight MCP23xxx chips in total, providing 64 additional ports.
MCP23XXX chips are ubiquitous in the hardware world and is the typical interface chip for common I2C LCD backpacks, with the 74595 chip being the typical interface chip for SPI LCD backpacks.
MCP Chip Family
The MCP23XXX family includes the 8-bit MCP23008 and also includes the MCP23017, which is a 16-bit version of the MCP23008, offering 16 digital ports in total, and the MCP23S08 and MCP23S017 which are SPI versions of the MCP23008 and MCP23017, respectively.
Chip Addressing
The I2C address of the chip is configurable via the address pins and is in the binary form of 0100[A2][A1][A0]
, where A2
, A1
, and A0
refer to the three address pins on the chip:
For example, if all address pins were tied to ground, then the address of the chip would be 0100000
in binary, or 0x20
in hex, and 32
in decimal.
The I2C addresses can then be as follows, where 0
represents an address pin connected to ground, and 1
represents an address pin connected to 3.3V
:
Address Header | A2 | A1 | A0 | Resulting Hex Address | Resulting Decimal Address |
---|---|---|---|---|---|
0100 |
0 |
0 |
0 |
0x20 |
32 |
0100 |
0 |
0 |
1 |
0x21 |
33 |
0100 |
0 |
1 |
0 |
0x22 |
34 |
0100 |
0 |
1 |
1 |
0x23 |
35 |
0100 |
1 |
0 |
0 |
0x24 |
36 |
0100 |
1 |
0 |
1 |
0x25 |
37 |
0100 |
1 |
1 |
0 |
0x26 |
38 |
0100 |
1 |
1 |
1 |
0x27 |
39 |
Because there are 8 address possibilities, it's possible to put 8 MCP23XXX chips on a single I2C bus.
To make this simpler, when instantiating one of the MCP23XXX family of chip objects, there is a constructor overload that takes the address pin configurations instead of an address, so that Meadow.Foundation uses the appropriate address based on the pins, instead of requiring a pre-computed address.
Other Pins
In addition to the address pins, there are a number of other pins that must be connected up:
- Not Reset - The
RESET
pin is actually a "Not Reset." The line above "Reset" means "not." So unless that pin is pulled high (3.3V
), the chip will reset itself at random times and you'll get connection errors. - SCL and SDA - The
SCL
andSDA
pins are the I2C clock and data pins and go to theSC
andSD
pins on the Meadow, respectively. Each of these should also generally be pulled high (3.3V
) via a4.7kΩ
resistor. See the I2C guide for more information. - INT - The
INT
pin is for interrupt notifications, and is only necessary when using the GPIO pins in input mode and you want an event raised when the input value changes. - VSS and VDD - These go to ground and 3.3V power, respectively, and power the chip.
Code Examples
You can find code examples and links to sample projects for each of the MCP23XXX families and specific chips.
NumberOfPins
The number of IO pins available on the device
Declaration
public abstract int NumberOfPins { get; }
Property Value
Type | Description |
---|---|
int |
Remarks
Mcp23xxxx | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
The MCP chip family, referred to as MCP23XXX to represent the variations, is a digital I/O expander chip that uses I2C to communicate. It can be used to add additional digital input and output ports to Meadow and can be combined with up to eight MCP23xxx chips in total, providing 64 additional ports.
MCP23XXX chips are ubiquitous in the hardware world and is the typical interface chip for common I2C LCD backpacks, with the 74595 chip being the typical interface chip for SPI LCD backpacks.
MCP Chip Family
The MCP23XXX family includes the 8-bit MCP23008 and also includes the MCP23017, which is a 16-bit version of the MCP23008, offering 16 digital ports in total, and the MCP23S08 and MCP23S017 which are SPI versions of the MCP23008 and MCP23017, respectively.
Chip Addressing
The I2C address of the chip is configurable via the address pins and is in the binary form of 0100[A2][A1][A0]
, where A2
, A1
, and A0
refer to the three address pins on the chip:
For example, if all address pins were tied to ground, then the address of the chip would be 0100000
in binary, or 0x20
in hex, and 32
in decimal.
The I2C addresses can then be as follows, where 0
represents an address pin connected to ground, and 1
represents an address pin connected to 3.3V
:
Address Header | A2 | A1 | A0 | Resulting Hex Address | Resulting Decimal Address |
---|---|---|---|---|---|
0100 |
0 |
0 |
0 |
0x20 |
32 |
0100 |
0 |
0 |
1 |
0x21 |
33 |
0100 |
0 |
1 |
0 |
0x22 |
34 |
0100 |
0 |
1 |
1 |
0x23 |
35 |
0100 |
1 |
0 |
0 |
0x24 |
36 |
0100 |
1 |
0 |
1 |
0x25 |
37 |
0100 |
1 |
1 |
0 |
0x26 |
38 |
0100 |
1 |
1 |
1 |
0x27 |
39 |
Because there are 8 address possibilities, it's possible to put 8 MCP23XXX chips on a single I2C bus.
To make this simpler, when instantiating one of the MCP23XXX family of chip objects, there is a constructor overload that takes the address pin configurations instead of an address, so that Meadow.Foundation uses the appropriate address based on the pins, instead of requiring a pre-computed address.
Other Pins
In addition to the address pins, there are a number of other pins that must be connected up:
- Not Reset - The
RESET
pin is actually a "Not Reset." The line above "Reset" means "not." So unless that pin is pulled high (3.3V
), the chip will reset itself at random times and you'll get connection errors. - SCL and SDA - The
SCL
andSDA
pins are the I2C clock and data pins and go to theSC
andSD
pins on the Meadow, respectively. Each of these should also generally be pulled high (3.3V
) via a4.7kΩ
resistor. See the I2C guide for more information. - INT - The
INT
pin is for interrupt notifications, and is only necessary when using the GPIO pins in input mode and you want an event raised when the input value changes. - VSS and VDD - These go to ground and 3.3V power, respectively, and power the chip.
Code Examples
You can find code examples and links to sample projects for each of the MCP23XXX families and specific chips.
SpiBusMode
The SPI bus mode for the device
Declaration
public SpiClockConfiguration.Mode SpiBusMode { get; set; }
Property Value
Type | Description |
---|---|
SpiClockConfiguration.Mode |
Remarks
Mcp23xxxx | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
The MCP chip family, referred to as MCP23XXX to represent the variations, is a digital I/O expander chip that uses I2C to communicate. It can be used to add additional digital input and output ports to Meadow and can be combined with up to eight MCP23xxx chips in total, providing 64 additional ports.
MCP23XXX chips are ubiquitous in the hardware world and is the typical interface chip for common I2C LCD backpacks, with the 74595 chip being the typical interface chip for SPI LCD backpacks.
MCP Chip Family
The MCP23XXX family includes the 8-bit MCP23008 and also includes the MCP23017, which is a 16-bit version of the MCP23008, offering 16 digital ports in total, and the MCP23S08 and MCP23S017 which are SPI versions of the MCP23008 and MCP23017, respectively.
Chip Addressing
The I2C address of the chip is configurable via the address pins and is in the binary form of 0100[A2][A1][A0]
, where A2
, A1
, and A0
refer to the three address pins on the chip:
For example, if all address pins were tied to ground, then the address of the chip would be 0100000
in binary, or 0x20
in hex, and 32
in decimal.
The I2C addresses can then be as follows, where 0
represents an address pin connected to ground, and 1
represents an address pin connected to 3.3V
:
Address Header | A2 | A1 | A0 | Resulting Hex Address | Resulting Decimal Address |
---|---|---|---|---|---|
0100 |
0 |
0 |
0 |
0x20 |
32 |
0100 |
0 |
0 |
1 |
0x21 |
33 |
0100 |
0 |
1 |
0 |
0x22 |
34 |
0100 |
0 |
1 |
1 |
0x23 |
35 |
0100 |
1 |
0 |
0 |
0x24 |
36 |
0100 |
1 |
0 |
1 |
0x25 |
37 |
0100 |
1 |
1 |
0 |
0x26 |
38 |
0100 |
1 |
1 |
1 |
0x27 |
39 |
Because there are 8 address possibilities, it's possible to put 8 MCP23XXX chips on a single I2C bus.
To make this simpler, when instantiating one of the MCP23XXX family of chip objects, there is a constructor overload that takes the address pin configurations instead of an address, so that Meadow.Foundation uses the appropriate address based on the pins, instead of requiring a pre-computed address.
Other Pins
In addition to the address pins, there are a number of other pins that must be connected up:
- Not Reset - The
RESET
pin is actually a "Not Reset." The line above "Reset" means "not." So unless that pin is pulled high (3.3V
), the chip will reset itself at random times and you'll get connection errors. - SCL and SDA - The
SCL
andSDA
pins are the I2C clock and data pins and go to theSC
andSD
pins on the Meadow, respectively. Each of these should also generally be pulled high (3.3V
) via a4.7kΩ
resistor. See the I2C guide for more information. - INT - The
INT
pin is for interrupt notifications, and is only necessary when using the GPIO pins in input mode and you want an event raised when the input value changes. - VSS and VDD - These go to ground and 3.3V power, respectively, and power the chip.
Code Examples
You can find code examples and links to sample projects for each of the MCP23XXX families and specific chips.
SpiBusSpeed
The SPI bus speed for the device
Declaration
public Frequency SpiBusSpeed { get; set; }
Property Value
Type | Description |
---|---|
Frequency |
Remarks
Mcp23xxxx | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
The MCP chip family, referred to as MCP23XXX to represent the variations, is a digital I/O expander chip that uses I2C to communicate. It can be used to add additional digital input and output ports to Meadow and can be combined with up to eight MCP23xxx chips in total, providing 64 additional ports.
MCP23XXX chips are ubiquitous in the hardware world and is the typical interface chip for common I2C LCD backpacks, with the 74595 chip being the typical interface chip for SPI LCD backpacks.
MCP Chip Family
The MCP23XXX family includes the 8-bit MCP23008 and also includes the MCP23017, which is a 16-bit version of the MCP23008, offering 16 digital ports in total, and the MCP23S08 and MCP23S017 which are SPI versions of the MCP23008 and MCP23017, respectively.
Chip Addressing
The I2C address of the chip is configurable via the address pins and is in the binary form of 0100[A2][A1][A0]
, where A2
, A1
, and A0
refer to the three address pins on the chip:
For example, if all address pins were tied to ground, then the address of the chip would be 0100000
in binary, or 0x20
in hex, and 32
in decimal.
The I2C addresses can then be as follows, where 0
represents an address pin connected to ground, and 1
represents an address pin connected to 3.3V
:
Address Header | A2 | A1 | A0 | Resulting Hex Address | Resulting Decimal Address |
---|---|---|---|---|---|
0100 |
0 |
0 |
0 |
0x20 |
32 |
0100 |
0 |
0 |
1 |
0x21 |
33 |
0100 |
0 |
1 |
0 |
0x22 |
34 |
0100 |
0 |
1 |
1 |
0x23 |
35 |
0100 |
1 |
0 |
0 |
0x24 |
36 |
0100 |
1 |
0 |
1 |
0x25 |
37 |
0100 |
1 |
1 |
0 |
0x26 |
38 |
0100 |
1 |
1 |
1 |
0x27 |
39 |
Because there are 8 address possibilities, it's possible to put 8 MCP23XXX chips on a single I2C bus.
To make this simpler, when instantiating one of the MCP23XXX family of chip objects, there is a constructor overload that takes the address pin configurations instead of an address, so that Meadow.Foundation uses the appropriate address based on the pins, instead of requiring a pre-computed address.
Other Pins
In addition to the address pins, there are a number of other pins that must be connected up:
- Not Reset - The
RESET
pin is actually a "Not Reset." The line above "Reset" means "not." So unless that pin is pulled high (3.3V
), the chip will reset itself at random times and you'll get connection errors. - SCL and SDA - The
SCL
andSDA
pins are the I2C clock and data pins and go to theSC
andSD
pins on the Meadow, respectively. Each of these should also generally be pulled high (3.3V
) via a4.7kΩ
resistor. See the I2C guide for more information. - INT - The
INT
pin is for interrupt notifications, and is only necessary when using the GPIO pins in input mode and you want an event raised when the input value changes. - VSS and VDD - These go to ground and 3.3V power, respectively, and power the chip.
Code Examples
You can find code examples and links to sample projects for each of the MCP23XXX families and specific chips.
Methods
CreateDigitalInputPort(IPin, ResistorMode)
Creates a new DigitalInputPort using the specified pin
Declaration
public IDigitalInputPort CreateDigitalInputPort(IPin pin, ResistorMode resistorMode = ResistorMode.Disabled)
Parameters
Type | Name | Description |
---|---|---|
IPin | pin | The pin representing the port |
ResistorMode | resistorMode | The port resistor mode |
Returns
Type | Description |
---|---|
IDigitalInputPort | IDigitalInputPort |
Remarks
Mcp23xxxx | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
The MCP chip family, referred to as MCP23XXX to represent the variations, is a digital I/O expander chip that uses I2C to communicate. It can be used to add additional digital input and output ports to Meadow and can be combined with up to eight MCP23xxx chips in total, providing 64 additional ports.
MCP23XXX chips are ubiquitous in the hardware world and is the typical interface chip for common I2C LCD backpacks, with the 74595 chip being the typical interface chip for SPI LCD backpacks.
MCP Chip Family
The MCP23XXX family includes the 8-bit MCP23008 and also includes the MCP23017, which is a 16-bit version of the MCP23008, offering 16 digital ports in total, and the MCP23S08 and MCP23S017 which are SPI versions of the MCP23008 and MCP23017, respectively.
Chip Addressing
The I2C address of the chip is configurable via the address pins and is in the binary form of 0100[A2][A1][A0]
, where A2
, A1
, and A0
refer to the three address pins on the chip:
For example, if all address pins were tied to ground, then the address of the chip would be 0100000
in binary, or 0x20
in hex, and 32
in decimal.
The I2C addresses can then be as follows, where 0
represents an address pin connected to ground, and 1
represents an address pin connected to 3.3V
:
Address Header | A2 | A1 | A0 | Resulting Hex Address | Resulting Decimal Address |
---|---|---|---|---|---|
0100 |
0 |
0 |
0 |
0x20 |
32 |
0100 |
0 |
0 |
1 |
0x21 |
33 |
0100 |
0 |
1 |
0 |
0x22 |
34 |
0100 |
0 |
1 |
1 |
0x23 |
35 |
0100 |
1 |
0 |
0 |
0x24 |
36 |
0100 |
1 |
0 |
1 |
0x25 |
37 |
0100 |
1 |
1 |
0 |
0x26 |
38 |
0100 |
1 |
1 |
1 |
0x27 |
39 |
Because there are 8 address possibilities, it's possible to put 8 MCP23XXX chips on a single I2C bus.
To make this simpler, when instantiating one of the MCP23XXX family of chip objects, there is a constructor overload that takes the address pin configurations instead of an address, so that Meadow.Foundation uses the appropriate address based on the pins, instead of requiring a pre-computed address.
Other Pins
In addition to the address pins, there are a number of other pins that must be connected up:
- Not Reset - The
RESET
pin is actually a "Not Reset." The line above "Reset" means "not." So unless that pin is pulled high (3.3V
), the chip will reset itself at random times and you'll get connection errors. - SCL and SDA - The
SCL
andSDA
pins are the I2C clock and data pins and go to theSC
andSD
pins on the Meadow, respectively. Each of these should also generally be pulled high (3.3V
) via a4.7kΩ
resistor. See the I2C guide for more information. - INT - The
INT
pin is for interrupt notifications, and is only necessary when using the GPIO pins in input mode and you want an event raised when the input value changes. - VSS and VDD - These go to ground and 3.3V power, respectively, and power the chip.
Code Examples
You can find code examples and links to sample projects for each of the MCP23XXX families and specific chips.
CreateDigitalInterruptPort(IPin, InterruptMode, ResistorMode)
Creates a new DigitalInputPort using the specified pin
Declaration
public IDigitalInterruptPort CreateDigitalInterruptPort(IPin pin, InterruptMode interruptMode = InterruptMode.None, ResistorMode resistorMode = ResistorMode.Disabled)
Parameters
Type | Name | Description |
---|---|---|
IPin | pin | The pin representing the port |
InterruptMode | interruptMode | The port interrupt mode |
ResistorMode | resistorMode | The port resistor mode |
Returns
Type | Description |
---|---|
IDigitalInterruptPort | IDigitalInterruptPort |
Remarks
Mcp23xxxx | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
The MCP chip family, referred to as MCP23XXX to represent the variations, is a digital I/O expander chip that uses I2C to communicate. It can be used to add additional digital input and output ports to Meadow and can be combined with up to eight MCP23xxx chips in total, providing 64 additional ports.
MCP23XXX chips are ubiquitous in the hardware world and is the typical interface chip for common I2C LCD backpacks, with the 74595 chip being the typical interface chip for SPI LCD backpacks.
MCP Chip Family
The MCP23XXX family includes the 8-bit MCP23008 and also includes the MCP23017, which is a 16-bit version of the MCP23008, offering 16 digital ports in total, and the MCP23S08 and MCP23S017 which are SPI versions of the MCP23008 and MCP23017, respectively.
Chip Addressing
The I2C address of the chip is configurable via the address pins and is in the binary form of 0100[A2][A1][A0]
, where A2
, A1
, and A0
refer to the three address pins on the chip:
For example, if all address pins were tied to ground, then the address of the chip would be 0100000
in binary, or 0x20
in hex, and 32
in decimal.
The I2C addresses can then be as follows, where 0
represents an address pin connected to ground, and 1
represents an address pin connected to 3.3V
:
Address Header | A2 | A1 | A0 | Resulting Hex Address | Resulting Decimal Address |
---|---|---|---|---|---|
0100 |
0 |
0 |
0 |
0x20 |
32 |
0100 |
0 |
0 |
1 |
0x21 |
33 |
0100 |
0 |
1 |
0 |
0x22 |
34 |
0100 |
0 |
1 |
1 |
0x23 |
35 |
0100 |
1 |
0 |
0 |
0x24 |
36 |
0100 |
1 |
0 |
1 |
0x25 |
37 |
0100 |
1 |
1 |
0 |
0x26 |
38 |
0100 |
1 |
1 |
1 |
0x27 |
39 |
Because there are 8 address possibilities, it's possible to put 8 MCP23XXX chips on a single I2C bus.
To make this simpler, when instantiating one of the MCP23XXX family of chip objects, there is a constructor overload that takes the address pin configurations instead of an address, so that Meadow.Foundation uses the appropriate address based on the pins, instead of requiring a pre-computed address.
Other Pins
In addition to the address pins, there are a number of other pins that must be connected up:
- Not Reset - The
RESET
pin is actually a "Not Reset." The line above "Reset" means "not." So unless that pin is pulled high (3.3V
), the chip will reset itself at random times and you'll get connection errors. - SCL and SDA - The
SCL
andSDA
pins are the I2C clock and data pins and go to theSC
andSD
pins on the Meadow, respectively. Each of these should also generally be pulled high (3.3V
) via a4.7kΩ
resistor. See the I2C guide for more information. - INT - The
INT
pin is for interrupt notifications, and is only necessary when using the GPIO pins in input mode and you want an event raised when the input value changes. - VSS and VDD - These go to ground and 3.3V power, respectively, and power the chip.
Code Examples
You can find code examples and links to sample projects for each of the MCP23XXX families and specific chips.
CreateDigitalInterruptPort(IPin, InterruptMode, ResistorMode, TimeSpan)
Creates a new DigitalInputPort using the specified pin
Declaration
public IDigitalInterruptPort CreateDigitalInterruptPort(IPin pin, InterruptMode interruptMode, ResistorMode resistorMode, TimeSpan debounceDuration)
Parameters
Type | Name | Description |
---|---|---|
IPin | pin | The pin representing the port |
InterruptMode | interruptMode | The port interrupt mode |
ResistorMode | resistorMode | The port resistor mode |
TimeSpan | debounceDuration | The debounce duration |
Returns
Type | Description |
---|---|
IDigitalInterruptPort | IDigitalInterruptPort |
Remarks
Mcp23xxxx | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
The MCP chip family, referred to as MCP23XXX to represent the variations, is a digital I/O expander chip that uses I2C to communicate. It can be used to add additional digital input and output ports to Meadow and can be combined with up to eight MCP23xxx chips in total, providing 64 additional ports.
MCP23XXX chips are ubiquitous in the hardware world and is the typical interface chip for common I2C LCD backpacks, with the 74595 chip being the typical interface chip for SPI LCD backpacks.
MCP Chip Family
The MCP23XXX family includes the 8-bit MCP23008 and also includes the MCP23017, which is a 16-bit version of the MCP23008, offering 16 digital ports in total, and the MCP23S08 and MCP23S017 which are SPI versions of the MCP23008 and MCP23017, respectively.
Chip Addressing
The I2C address of the chip is configurable via the address pins and is in the binary form of 0100[A2][A1][A0]
, where A2
, A1
, and A0
refer to the three address pins on the chip:
For example, if all address pins were tied to ground, then the address of the chip would be 0100000
in binary, or 0x20
in hex, and 32
in decimal.
The I2C addresses can then be as follows, where 0
represents an address pin connected to ground, and 1
represents an address pin connected to 3.3V
:
Address Header | A2 | A1 | A0 | Resulting Hex Address | Resulting Decimal Address |
---|---|---|---|---|---|
0100 |
0 |
0 |
0 |
0x20 |
32 |
0100 |
0 |
0 |
1 |
0x21 |
33 |
0100 |
0 |
1 |
0 |
0x22 |
34 |
0100 |
0 |
1 |
1 |
0x23 |
35 |
0100 |
1 |
0 |
0 |
0x24 |
36 |
0100 |
1 |
0 |
1 |
0x25 |
37 |
0100 |
1 |
1 |
0 |
0x26 |
38 |
0100 |
1 |
1 |
1 |
0x27 |
39 |
Because there are 8 address possibilities, it's possible to put 8 MCP23XXX chips on a single I2C bus.
To make this simpler, when instantiating one of the MCP23XXX family of chip objects, there is a constructor overload that takes the address pin configurations instead of an address, so that Meadow.Foundation uses the appropriate address based on the pins, instead of requiring a pre-computed address.
Other Pins
In addition to the address pins, there are a number of other pins that must be connected up:
- Not Reset - The
RESET
pin is actually a "Not Reset." The line above "Reset" means "not." So unless that pin is pulled high (3.3V
), the chip will reset itself at random times and you'll get connection errors. - SCL and SDA - The
SCL
andSDA
pins are the I2C clock and data pins and go to theSC
andSD
pins on the Meadow, respectively. Each of these should also generally be pulled high (3.3V
) via a4.7kΩ
resistor. See the I2C guide for more information. - INT - The
INT
pin is for interrupt notifications, and is only necessary when using the GPIO pins in input mode and you want an event raised when the input value changes. - VSS and VDD - These go to ground and 3.3V power, respectively, and power the chip.
Code Examples
You can find code examples and links to sample projects for each of the MCP23XXX families and specific chips.
CreateDigitalInterruptPort(IPin, InterruptMode, ResistorMode, TimeSpan, TimeSpan)
Creates a new DigitalInputPort using the specified pin
Declaration
public IDigitalInterruptPort CreateDigitalInterruptPort(IPin pin, InterruptMode interruptMode, ResistorMode resistorMode, TimeSpan debounceDuration, TimeSpan glitchDuration)
Parameters
Type | Name | Description |
---|---|---|
IPin | pin | The pin representing the port |
InterruptMode | interruptMode | The port interrupt mode |
ResistorMode | resistorMode | The port resistor mode |
TimeSpan | debounceDuration | The debounce duration |
TimeSpan | glitchDuration | The glitch duration - not configurable on Mcp23xxx |
Returns
Type | Description |
---|---|
IDigitalInterruptPort | IDigitalInterruptPort |
Remarks
Mcp23xxxx | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
The MCP chip family, referred to as MCP23XXX to represent the variations, is a digital I/O expander chip that uses I2C to communicate. It can be used to add additional digital input and output ports to Meadow and can be combined with up to eight MCP23xxx chips in total, providing 64 additional ports.
MCP23XXX chips are ubiquitous in the hardware world and is the typical interface chip for common I2C LCD backpacks, with the 74595 chip being the typical interface chip for SPI LCD backpacks.
MCP Chip Family
The MCP23XXX family includes the 8-bit MCP23008 and also includes the MCP23017, which is a 16-bit version of the MCP23008, offering 16 digital ports in total, and the MCP23S08 and MCP23S017 which are SPI versions of the MCP23008 and MCP23017, respectively.
Chip Addressing
The I2C address of the chip is configurable via the address pins and is in the binary form of 0100[A2][A1][A0]
, where A2
, A1
, and A0
refer to the three address pins on the chip:
For example, if all address pins were tied to ground, then the address of the chip would be 0100000
in binary, or 0x20
in hex, and 32
in decimal.
The I2C addresses can then be as follows, where 0
represents an address pin connected to ground, and 1
represents an address pin connected to 3.3V
:
Address Header | A2 | A1 | A0 | Resulting Hex Address | Resulting Decimal Address |
---|---|---|---|---|---|
0100 |
0 |
0 |
0 |
0x20 |
32 |
0100 |
0 |
0 |
1 |
0x21 |
33 |
0100 |
0 |
1 |
0 |
0x22 |
34 |
0100 |
0 |
1 |
1 |
0x23 |
35 |
0100 |
1 |
0 |
0 |
0x24 |
36 |
0100 |
1 |
0 |
1 |
0x25 |
37 |
0100 |
1 |
1 |
0 |
0x26 |
38 |
0100 |
1 |
1 |
1 |
0x27 |
39 |
Because there are 8 address possibilities, it's possible to put 8 MCP23XXX chips on a single I2C bus.
To make this simpler, when instantiating one of the MCP23XXX family of chip objects, there is a constructor overload that takes the address pin configurations instead of an address, so that Meadow.Foundation uses the appropriate address based on the pins, instead of requiring a pre-computed address.
Other Pins
In addition to the address pins, there are a number of other pins that must be connected up:
- Not Reset - The
RESET
pin is actually a "Not Reset." The line above "Reset" means "not." So unless that pin is pulled high (3.3V
), the chip will reset itself at random times and you'll get connection errors. - SCL and SDA - The
SCL
andSDA
pins are the I2C clock and data pins and go to theSC
andSD
pins on the Meadow, respectively. Each of these should also generally be pulled high (3.3V
) via a4.7kΩ
resistor. See the I2C guide for more information. - INT - The
INT
pin is for interrupt notifications, and is only necessary when using the GPIO pins in input mode and you want an event raised when the input value changes. - VSS and VDD - These go to ground and 3.3V power, respectively, and power the chip.
Code Examples
You can find code examples and links to sample projects for each of the MCP23XXX families and specific chips.
CreateDigitalOutputPort(IPin, bool, OutputType)
Creates a new DigitalOutputPort using the specified pin and initial state
Declaration
public virtual IDigitalOutputPort CreateDigitalOutputPort(IPin pin, bool initialState = false, OutputType outputType = OutputType.OpenDrain)
Parameters
Type | Name | Description |
---|---|---|
IPin | pin | The pin representing the port |
bool | initialState | Whether the pin is initially high or low |
OutputType | outputType | The output type |
Returns
Type | Description |
---|---|
IDigitalOutputPort | IDigitalOutputPort |
Remarks
Mcp23xxxx | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
The MCP chip family, referred to as MCP23XXX to represent the variations, is a digital I/O expander chip that uses I2C to communicate. It can be used to add additional digital input and output ports to Meadow and can be combined with up to eight MCP23xxx chips in total, providing 64 additional ports.
MCP23XXX chips are ubiquitous in the hardware world and is the typical interface chip for common I2C LCD backpacks, with the 74595 chip being the typical interface chip for SPI LCD backpacks.
MCP Chip Family
The MCP23XXX family includes the 8-bit MCP23008 and also includes the MCP23017, which is a 16-bit version of the MCP23008, offering 16 digital ports in total, and the MCP23S08 and MCP23S017 which are SPI versions of the MCP23008 and MCP23017, respectively.
Chip Addressing
The I2C address of the chip is configurable via the address pins and is in the binary form of 0100[A2][A1][A0]
, where A2
, A1
, and A0
refer to the three address pins on the chip:
For example, if all address pins were tied to ground, then the address of the chip would be 0100000
in binary, or 0x20
in hex, and 32
in decimal.
The I2C addresses can then be as follows, where 0
represents an address pin connected to ground, and 1
represents an address pin connected to 3.3V
:
Address Header | A2 | A1 | A0 | Resulting Hex Address | Resulting Decimal Address |
---|---|---|---|---|---|
0100 |
0 |
0 |
0 |
0x20 |
32 |
0100 |
0 |
0 |
1 |
0x21 |
33 |
0100 |
0 |
1 |
0 |
0x22 |
34 |
0100 |
0 |
1 |
1 |
0x23 |
35 |
0100 |
1 |
0 |
0 |
0x24 |
36 |
0100 |
1 |
0 |
1 |
0x25 |
37 |
0100 |
1 |
1 |
0 |
0x26 |
38 |
0100 |
1 |
1 |
1 |
0x27 |
39 |
Because there are 8 address possibilities, it's possible to put 8 MCP23XXX chips on a single I2C bus.
To make this simpler, when instantiating one of the MCP23XXX family of chip objects, there is a constructor overload that takes the address pin configurations instead of an address, so that Meadow.Foundation uses the appropriate address based on the pins, instead of requiring a pre-computed address.
Other Pins
In addition to the address pins, there are a number of other pins that must be connected up:
- Not Reset - The
RESET
pin is actually a "Not Reset." The line above "Reset" means "not." So unless that pin is pulled high (3.3V
), the chip will reset itself at random times and you'll get connection errors. - SCL and SDA - The
SCL
andSDA
pins are the I2C clock and data pins and go to theSC
andSD
pins on the Meadow, respectively. Each of these should also generally be pulled high (3.3V
) via a4.7kΩ
resistor. See the I2C guide for more information. - INT - The
INT
pin is for interrupt notifications, and is only necessary when using the GPIO pins in input mode and you want an event raised when the input value changes. - VSS and VDD - These go to ground and 3.3V power, respectively, and power the chip.
Code Examples
You can find code examples and links to sample projects for each of the MCP23XXX families and specific chips.
GetAddressFromPins(bool, bool, bool)
Help method to get address from address pin configuration
Declaration
public static byte GetAddressFromPins(bool pinA0, bool pinA1, bool pinA2)
Parameters
Type | Name | Description |
---|---|---|
bool | pinA0 | State of A0 address pin - true if high |
bool | pinA1 | State of A1 address pin - true if high |
bool | pinA2 | State of A2 address pin - true if high |
Returns
Type | Description |
---|---|
byte | The device address |
Remarks
Mcp23xxxx | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
The MCP chip family, referred to as MCP23XXX to represent the variations, is a digital I/O expander chip that uses I2C to communicate. It can be used to add additional digital input and output ports to Meadow and can be combined with up to eight MCP23xxx chips in total, providing 64 additional ports.
MCP23XXX chips are ubiquitous in the hardware world and is the typical interface chip for common I2C LCD backpacks, with the 74595 chip being the typical interface chip for SPI LCD backpacks.
MCP Chip Family
The MCP23XXX family includes the 8-bit MCP23008 and also includes the MCP23017, which is a 16-bit version of the MCP23008, offering 16 digital ports in total, and the MCP23S08 and MCP23S017 which are SPI versions of the MCP23008 and MCP23017, respectively.
Chip Addressing
The I2C address of the chip is configurable via the address pins and is in the binary form of 0100[A2][A1][A0]
, where A2
, A1
, and A0
refer to the three address pins on the chip:
For example, if all address pins were tied to ground, then the address of the chip would be 0100000
in binary, or 0x20
in hex, and 32
in decimal.
The I2C addresses can then be as follows, where 0
represents an address pin connected to ground, and 1
represents an address pin connected to 3.3V
:
Address Header | A2 | A1 | A0 | Resulting Hex Address | Resulting Decimal Address |
---|---|---|---|---|---|
0100 |
0 |
0 |
0 |
0x20 |
32 |
0100 |
0 |
0 |
1 |
0x21 |
33 |
0100 |
0 |
1 |
0 |
0x22 |
34 |
0100 |
0 |
1 |
1 |
0x23 |
35 |
0100 |
1 |
0 |
0 |
0x24 |
36 |
0100 |
1 |
0 |
1 |
0x25 |
37 |
0100 |
1 |
1 |
0 |
0x26 |
38 |
0100 |
1 |
1 |
1 |
0x27 |
39 |
Because there are 8 address possibilities, it's possible to put 8 MCP23XXX chips on a single I2C bus.
To make this simpler, when instantiating one of the MCP23XXX family of chip objects, there is a constructor overload that takes the address pin configurations instead of an address, so that Meadow.Foundation uses the appropriate address based on the pins, instead of requiring a pre-computed address.
Other Pins
In addition to the address pins, there are a number of other pins that must be connected up:
- Not Reset - The
RESET
pin is actually a "Not Reset." The line above "Reset" means "not." So unless that pin is pulled high (3.3V
), the chip will reset itself at random times and you'll get connection errors. - SCL and SDA - The
SCL
andSDA
pins are the I2C clock and data pins and go to theSC
andSD
pins on the Meadow, respectively. Each of these should also generally be pulled high (3.3V
) via a4.7kΩ
resistor. See the I2C guide for more information. - INT - The
INT
pin is for interrupt notifications, and is only necessary when using the GPIO pins in input mode and you want an event raised when the input value changes. - VSS and VDD - These go to ground and 3.3V power, respectively, and power the chip.
Code Examples
You can find code examples and links to sample projects for each of the MCP23XXX families and specific chips.
GetPin(string)
Get Pin by name
Declaration
public abstract IPin GetPin(string pinName)
Parameters
Type | Name | Description |
---|---|---|
string | pinName | The pin name |
Returns
Type | Description |
---|---|
IPin | IPin object if found |
Remarks
Mcp23xxxx | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
The MCP chip family, referred to as MCP23XXX to represent the variations, is a digital I/O expander chip that uses I2C to communicate. It can be used to add additional digital input and output ports to Meadow and can be combined with up to eight MCP23xxx chips in total, providing 64 additional ports.
MCP23XXX chips are ubiquitous in the hardware world and is the typical interface chip for common I2C LCD backpacks, with the 74595 chip being the typical interface chip for SPI LCD backpacks.
MCP Chip Family
The MCP23XXX family includes the 8-bit MCP23008 and also includes the MCP23017, which is a 16-bit version of the MCP23008, offering 16 digital ports in total, and the MCP23S08 and MCP23S017 which are SPI versions of the MCP23008 and MCP23017, respectively.
Chip Addressing
The I2C address of the chip is configurable via the address pins and is in the binary form of 0100[A2][A1][A0]
, where A2
, A1
, and A0
refer to the three address pins on the chip:
For example, if all address pins were tied to ground, then the address of the chip would be 0100000
in binary, or 0x20
in hex, and 32
in decimal.
The I2C addresses can then be as follows, where 0
represents an address pin connected to ground, and 1
represents an address pin connected to 3.3V
:
Address Header | A2 | A1 | A0 | Resulting Hex Address | Resulting Decimal Address |
---|---|---|---|---|---|
0100 |
0 |
0 |
0 |
0x20 |
32 |
0100 |
0 |
0 |
1 |
0x21 |
33 |
0100 |
0 |
1 |
0 |
0x22 |
34 |
0100 |
0 |
1 |
1 |
0x23 |
35 |
0100 |
1 |
0 |
0 |
0x24 |
36 |
0100 |
1 |
0 |
1 |
0x25 |
37 |
0100 |
1 |
1 |
0 |
0x26 |
38 |
0100 |
1 |
1 |
1 |
0x27 |
39 |
Because there are 8 address possibilities, it's possible to put 8 MCP23XXX chips on a single I2C bus.
To make this simpler, when instantiating one of the MCP23XXX family of chip objects, there is a constructor overload that takes the address pin configurations instead of an address, so that Meadow.Foundation uses the appropriate address based on the pins, instead of requiring a pre-computed address.
Other Pins
In addition to the address pins, there are a number of other pins that must be connected up:
- Not Reset - The
RESET
pin is actually a "Not Reset." The line above "Reset" means "not." So unless that pin is pulled high (3.3V
), the chip will reset itself at random times and you'll get connection errors. - SCL and SDA - The
SCL
andSDA
pins are the I2C clock and data pins and go to theSC
andSD
pins on the Meadow, respectively. Each of these should also generally be pulled high (3.3V
) via a4.7kΩ
resistor. See the I2C guide for more information. - INT - The
INT
pin is for interrupt notifications, and is only necessary when using the GPIO pins in input mode and you want an event raised when the input value changes. - VSS and VDD - These go to ground and 3.3V power, respectively, and power the chip.
Code Examples
You can find code examples and links to sample projects for each of the MCP23XXX families and specific chips.
IsValidPin(IPin)
Checks if a pin exists on the Mcp23xxx
Declaration
protected abstract bool IsValidPin(IPin pin)
Parameters
Type | Name | Description |
---|---|---|
IPin | pin |
Returns
Type | Description |
---|---|
bool |
Remarks
Mcp23xxxx | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
The MCP chip family, referred to as MCP23XXX to represent the variations, is a digital I/O expander chip that uses I2C to communicate. It can be used to add additional digital input and output ports to Meadow and can be combined with up to eight MCP23xxx chips in total, providing 64 additional ports.
MCP23XXX chips are ubiquitous in the hardware world and is the typical interface chip for common I2C LCD backpacks, with the 74595 chip being the typical interface chip for SPI LCD backpacks.
MCP Chip Family
The MCP23XXX family includes the 8-bit MCP23008 and also includes the MCP23017, which is a 16-bit version of the MCP23008, offering 16 digital ports in total, and the MCP23S08 and MCP23S017 which are SPI versions of the MCP23008 and MCP23017, respectively.
Chip Addressing
The I2C address of the chip is configurable via the address pins and is in the binary form of 0100[A2][A1][A0]
, where A2
, A1
, and A0
refer to the three address pins on the chip:
For example, if all address pins were tied to ground, then the address of the chip would be 0100000
in binary, or 0x20
in hex, and 32
in decimal.
The I2C addresses can then be as follows, where 0
represents an address pin connected to ground, and 1
represents an address pin connected to 3.3V
:
Address Header | A2 | A1 | A0 | Resulting Hex Address | Resulting Decimal Address |
---|---|---|---|---|---|
0100 |
0 |
0 |
0 |
0x20 |
32 |
0100 |
0 |
0 |
1 |
0x21 |
33 |
0100 |
0 |
1 |
0 |
0x22 |
34 |
0100 |
0 |
1 |
1 |
0x23 |
35 |
0100 |
1 |
0 |
0 |
0x24 |
36 |
0100 |
1 |
0 |
1 |
0x25 |
37 |
0100 |
1 |
1 |
0 |
0x26 |
38 |
0100 |
1 |
1 |
1 |
0x27 |
39 |
Because there are 8 address possibilities, it's possible to put 8 MCP23XXX chips on a single I2C bus.
To make this simpler, when instantiating one of the MCP23XXX family of chip objects, there is a constructor overload that takes the address pin configurations instead of an address, so that Meadow.Foundation uses the appropriate address based on the pins, instead of requiring a pre-computed address.
Other Pins
In addition to the address pins, there are a number of other pins that must be connected up:
- Not Reset - The
RESET
pin is actually a "Not Reset." The line above "Reset" means "not." So unless that pin is pulled high (3.3V
), the chip will reset itself at random times and you'll get connection errors. - SCL and SDA - The
SCL
andSDA
pins are the I2C clock and data pins and go to theSC
andSD
pins on the Meadow, respectively. Each of these should also generally be pulled high (3.3V
) via a4.7kΩ
resistor. See the I2C guide for more information. - INT - The
INT
pin is for interrupt notifications, and is only necessary when using the GPIO pins in input mode and you want an event raised when the input value changes. - VSS and VDD - These go to ground and 3.3V power, respectively, and power the chip.
Code Examples
You can find code examples and links to sample projects for each of the MCP23XXX families and specific chips.
ReadFromPorts(PortBank)
Reads a byte value from all of the pins. little-endian; the least significant bit is the value of GP0. So a byte value of 0x60, or 0110 0000, means that pins GP5 and GP6 are high.
Declaration
public byte ReadFromPorts(Mcp23xxx.PortBank bank = PortBank.A)
Parameters
Type | Name | Description |
---|---|---|
Mcp23xxx.PortBank | bank |
Returns
Type | Description |
---|---|
byte | A little-endian byte mask of the pin values. |
Remarks
Mcp23xxxx | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
The MCP chip family, referred to as MCP23XXX to represent the variations, is a digital I/O expander chip that uses I2C to communicate. It can be used to add additional digital input and output ports to Meadow and can be combined with up to eight MCP23xxx chips in total, providing 64 additional ports.
MCP23XXX chips are ubiquitous in the hardware world and is the typical interface chip for common I2C LCD backpacks, with the 74595 chip being the typical interface chip for SPI LCD backpacks.
MCP Chip Family
The MCP23XXX family includes the 8-bit MCP23008 and also includes the MCP23017, which is a 16-bit version of the MCP23008, offering 16 digital ports in total, and the MCP23S08 and MCP23S017 which are SPI versions of the MCP23008 and MCP23017, respectively.
Chip Addressing
The I2C address of the chip is configurable via the address pins and is in the binary form of 0100[A2][A1][A0]
, where A2
, A1
, and A0
refer to the three address pins on the chip:
For example, if all address pins were tied to ground, then the address of the chip would be 0100000
in binary, or 0x20
in hex, and 32
in decimal.
The I2C addresses can then be as follows, where 0
represents an address pin connected to ground, and 1
represents an address pin connected to 3.3V
:
Address Header | A2 | A1 | A0 | Resulting Hex Address | Resulting Decimal Address |
---|---|---|---|---|---|
0100 |
0 |
0 |
0 |
0x20 |
32 |
0100 |
0 |
0 |
1 |
0x21 |
33 |
0100 |
0 |
1 |
0 |
0x22 |
34 |
0100 |
0 |
1 |
1 |
0x23 |
35 |
0100 |
1 |
0 |
0 |
0x24 |
36 |
0100 |
1 |
0 |
1 |
0x25 |
37 |
0100 |
1 |
1 |
0 |
0x26 |
38 |
0100 |
1 |
1 |
1 |
0x27 |
39 |
Because there are 8 address possibilities, it's possible to put 8 MCP23XXX chips on a single I2C bus.
To make this simpler, when instantiating one of the MCP23XXX family of chip objects, there is a constructor overload that takes the address pin configurations instead of an address, so that Meadow.Foundation uses the appropriate address based on the pins, instead of requiring a pre-computed address.
Other Pins
In addition to the address pins, there are a number of other pins that must be connected up:
- Not Reset - The
RESET
pin is actually a "Not Reset." The line above "Reset" means "not." So unless that pin is pulled high (3.3V
), the chip will reset itself at random times and you'll get connection errors. - SCL and SDA - The
SCL
andSDA
pins are the I2C clock and data pins and go to theSC
andSD
pins on the Meadow, respectively. Each of these should also generally be pulled high (3.3V
) via a4.7kΩ
resistor. See the I2C guide for more information. - INT - The
INT
pin is for interrupt notifications, and is only necessary when using the GPIO pins in input mode and you want an event raised when the input value changes. - VSS and VDD - These go to ground and 3.3V power, respectively, and power the chip.
Code Examples
You can find code examples and links to sample projects for each of the MCP23XXX families and specific chips.
ReadPort(IPin)
Gets the value of a particular port. If the port is currently configured as an output, this will change the configuration.
Declaration
public bool ReadPort(IPin pin)
Parameters
Type | Name | Description |
---|---|---|
IPin | pin |
Returns
Type | Description |
---|---|
bool |
Remarks
Mcp23xxxx | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
The MCP chip family, referred to as MCP23XXX to represent the variations, is a digital I/O expander chip that uses I2C to communicate. It can be used to add additional digital input and output ports to Meadow and can be combined with up to eight MCP23xxx chips in total, providing 64 additional ports.
MCP23XXX chips are ubiquitous in the hardware world and is the typical interface chip for common I2C LCD backpacks, with the 74595 chip being the typical interface chip for SPI LCD backpacks.
MCP Chip Family
The MCP23XXX family includes the 8-bit MCP23008 and also includes the MCP23017, which is a 16-bit version of the MCP23008, offering 16 digital ports in total, and the MCP23S08 and MCP23S017 which are SPI versions of the MCP23008 and MCP23017, respectively.
Chip Addressing
The I2C address of the chip is configurable via the address pins and is in the binary form of 0100[A2][A1][A0]
, where A2
, A1
, and A0
refer to the three address pins on the chip:
For example, if all address pins were tied to ground, then the address of the chip would be 0100000
in binary, or 0x20
in hex, and 32
in decimal.
The I2C addresses can then be as follows, where 0
represents an address pin connected to ground, and 1
represents an address pin connected to 3.3V
:
Address Header | A2 | A1 | A0 | Resulting Hex Address | Resulting Decimal Address |
---|---|---|---|---|---|
0100 |
0 |
0 |
0 |
0x20 |
32 |
0100 |
0 |
0 |
1 |
0x21 |
33 |
0100 |
0 |
1 |
0 |
0x22 |
34 |
0100 |
0 |
1 |
1 |
0x23 |
35 |
0100 |
1 |
0 |
0 |
0x24 |
36 |
0100 |
1 |
0 |
1 |
0x25 |
37 |
0100 |
1 |
1 |
0 |
0x26 |
38 |
0100 |
1 |
1 |
1 |
0x27 |
39 |
Because there are 8 address possibilities, it's possible to put 8 MCP23XXX chips on a single I2C bus.
To make this simpler, when instantiating one of the MCP23XXX family of chip objects, there is a constructor overload that takes the address pin configurations instead of an address, so that Meadow.Foundation uses the appropriate address based on the pins, instead of requiring a pre-computed address.
Other Pins
In addition to the address pins, there are a number of other pins that must be connected up:
- Not Reset - The
RESET
pin is actually a "Not Reset." The line above "Reset" means "not." So unless that pin is pulled high (3.3V
), the chip will reset itself at random times and you'll get connection errors. - SCL and SDA - The
SCL
andSDA
pins are the I2C clock and data pins and go to theSC
andSD
pins on the Meadow, respectively. Each of these should also generally be pulled high (3.3V
) via a4.7kΩ
resistor. See the I2C guide for more information. - INT - The
INT
pin is for interrupt notifications, and is only necessary when using the GPIO pins in input mode and you want an event raised when the input value changes. - VSS and VDD - These go to ground and 3.3V power, respectively, and power the chip.
Code Examples
You can find code examples and links to sample projects for each of the MCP23XXX families and specific chips.
ResetMcp()
Reset the MCPxxxx expander Requires using a reset port
Declaration
public void ResetMcp()
Remarks
Mcp23xxxx | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
The MCP chip family, referred to as MCP23XXX to represent the variations, is a digital I/O expander chip that uses I2C to communicate. It can be used to add additional digital input and output ports to Meadow and can be combined with up to eight MCP23xxx chips in total, providing 64 additional ports.
MCP23XXX chips are ubiquitous in the hardware world and is the typical interface chip for common I2C LCD backpacks, with the 74595 chip being the typical interface chip for SPI LCD backpacks.
MCP Chip Family
The MCP23XXX family includes the 8-bit MCP23008 and also includes the MCP23017, which is a 16-bit version of the MCP23008, offering 16 digital ports in total, and the MCP23S08 and MCP23S017 which are SPI versions of the MCP23008 and MCP23017, respectively.
Chip Addressing
The I2C address of the chip is configurable via the address pins and is in the binary form of 0100[A2][A1][A0]
, where A2
, A1
, and A0
refer to the three address pins on the chip:
For example, if all address pins were tied to ground, then the address of the chip would be 0100000
in binary, or 0x20
in hex, and 32
in decimal.
The I2C addresses can then be as follows, where 0
represents an address pin connected to ground, and 1
represents an address pin connected to 3.3V
:
Address Header | A2 | A1 | A0 | Resulting Hex Address | Resulting Decimal Address |
---|---|---|---|---|---|
0100 |
0 |
0 |
0 |
0x20 |
32 |
0100 |
0 |
0 |
1 |
0x21 |
33 |
0100 |
0 |
1 |
0 |
0x22 |
34 |
0100 |
0 |
1 |
1 |
0x23 |
35 |
0100 |
1 |
0 |
0 |
0x24 |
36 |
0100 |
1 |
0 |
1 |
0x25 |
37 |
0100 |
1 |
1 |
0 |
0x26 |
38 |
0100 |
1 |
1 |
1 |
0x27 |
39 |
Because there are 8 address possibilities, it's possible to put 8 MCP23XXX chips on a single I2C bus.
To make this simpler, when instantiating one of the MCP23XXX family of chip objects, there is a constructor overload that takes the address pin configurations instead of an address, so that Meadow.Foundation uses the appropriate address based on the pins, instead of requiring a pre-computed address.
Other Pins
In addition to the address pins, there are a number of other pins that must be connected up:
- Not Reset - The
RESET
pin is actually a "Not Reset." The line above "Reset" means "not." So unless that pin is pulled high (3.3V
), the chip will reset itself at random times and you'll get connection errors. - SCL and SDA - The
SCL
andSDA
pins are the I2C clock and data pins and go to theSC
andSD
pins on the Meadow, respectively. Each of these should also generally be pulled high (3.3V
) via a4.7kΩ
resistor. See the I2C guide for more information. - INT - The
INT
pin is for interrupt notifications, and is only necessary when using the GPIO pins in input mode and you want an event raised when the input value changes. - VSS and VDD - These go to ground and 3.3V power, respectively, and power the chip.
Code Examples
You can find code examples and links to sample projects for each of the MCP23XXX families and specific chips.
ResetPin(IPin)
Sets the pin back to an input
Declaration
protected void ResetPin(IPin pin)
Parameters
Type | Name | Description |
---|---|---|
IPin | pin |
Remarks
Mcp23xxxx | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
The MCP chip family, referred to as MCP23XXX to represent the variations, is a digital I/O expander chip that uses I2C to communicate. It can be used to add additional digital input and output ports to Meadow and can be combined with up to eight MCP23xxx chips in total, providing 64 additional ports.
MCP23XXX chips are ubiquitous in the hardware world and is the typical interface chip for common I2C LCD backpacks, with the 74595 chip being the typical interface chip for SPI LCD backpacks.
MCP Chip Family
The MCP23XXX family includes the 8-bit MCP23008 and also includes the MCP23017, which is a 16-bit version of the MCP23008, offering 16 digital ports in total, and the MCP23S08 and MCP23S017 which are SPI versions of the MCP23008 and MCP23017, respectively.
Chip Addressing
The I2C address of the chip is configurable via the address pins and is in the binary form of 0100[A2][A1][A0]
, where A2
, A1
, and A0
refer to the three address pins on the chip:
For example, if all address pins were tied to ground, then the address of the chip would be 0100000
in binary, or 0x20
in hex, and 32
in decimal.
The I2C addresses can then be as follows, where 0
represents an address pin connected to ground, and 1
represents an address pin connected to 3.3V
:
Address Header | A2 | A1 | A0 | Resulting Hex Address | Resulting Decimal Address |
---|---|---|---|---|---|
0100 |
0 |
0 |
0 |
0x20 |
32 |
0100 |
0 |
0 |
1 |
0x21 |
33 |
0100 |
0 |
1 |
0 |
0x22 |
34 |
0100 |
0 |
1 |
1 |
0x23 |
35 |
0100 |
1 |
0 |
0 |
0x24 |
36 |
0100 |
1 |
0 |
1 |
0x25 |
37 |
0100 |
1 |
1 |
0 |
0x26 |
38 |
0100 |
1 |
1 |
1 |
0x27 |
39 |
Because there are 8 address possibilities, it's possible to put 8 MCP23XXX chips on a single I2C bus.
To make this simpler, when instantiating one of the MCP23XXX family of chip objects, there is a constructor overload that takes the address pin configurations instead of an address, so that Meadow.Foundation uses the appropriate address based on the pins, instead of requiring a pre-computed address.
Other Pins
In addition to the address pins, there are a number of other pins that must be connected up:
- Not Reset - The
RESET
pin is actually a "Not Reset." The line above "Reset" means "not." So unless that pin is pulled high (3.3V
), the chip will reset itself at random times and you'll get connection errors. - SCL and SDA - The
SCL
andSDA
pins are the I2C clock and data pins and go to theSC
andSD
pins on the Meadow, respectively. Each of these should also generally be pulled high (3.3V
) via a4.7kΩ
resistor. See the I2C guide for more information. - INT - The
INT
pin is for interrupt notifications, and is only necessary when using the GPIO pins in input mode and you want an event raised when the input value changes. - VSS and VDD - These go to ground and 3.3V power, respectively, and power the chip.
Code Examples
You can find code examples and links to sample projects for each of the MCP23XXX families and specific chips.
SetPortDirection(IPin, PortDirectionType)
Sets the direction of a port
Declaration
public void SetPortDirection(IPin pin, PortDirectionType direction)
Parameters
Type | Name | Description |
---|---|---|
IPin | pin | The pin representing the port |
PortDirectionType | direction | The port direction (input or output) |
Remarks
Mcp23xxxx | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
The MCP chip family, referred to as MCP23XXX to represent the variations, is a digital I/O expander chip that uses I2C to communicate. It can be used to add additional digital input and output ports to Meadow and can be combined with up to eight MCP23xxx chips in total, providing 64 additional ports.
MCP23XXX chips are ubiquitous in the hardware world and is the typical interface chip for common I2C LCD backpacks, with the 74595 chip being the typical interface chip for SPI LCD backpacks.
MCP Chip Family
The MCP23XXX family includes the 8-bit MCP23008 and also includes the MCP23017, which is a 16-bit version of the MCP23008, offering 16 digital ports in total, and the MCP23S08 and MCP23S017 which are SPI versions of the MCP23008 and MCP23017, respectively.
Chip Addressing
The I2C address of the chip is configurable via the address pins and is in the binary form of 0100[A2][A1][A0]
, where A2
, A1
, and A0
refer to the three address pins on the chip:
For example, if all address pins were tied to ground, then the address of the chip would be 0100000
in binary, or 0x20
in hex, and 32
in decimal.
The I2C addresses can then be as follows, where 0
represents an address pin connected to ground, and 1
represents an address pin connected to 3.3V
:
Address Header | A2 | A1 | A0 | Resulting Hex Address | Resulting Decimal Address |
---|---|---|---|---|---|
0100 |
0 |
0 |
0 |
0x20 |
32 |
0100 |
0 |
0 |
1 |
0x21 |
33 |
0100 |
0 |
1 |
0 |
0x22 |
34 |
0100 |
0 |
1 |
1 |
0x23 |
35 |
0100 |
1 |
0 |
0 |
0x24 |
36 |
0100 |
1 |
0 |
1 |
0x25 |
37 |
0100 |
1 |
1 |
0 |
0x26 |
38 |
0100 |
1 |
1 |
1 |
0x27 |
39 |
Because there are 8 address possibilities, it's possible to put 8 MCP23XXX chips on a single I2C bus.
To make this simpler, when instantiating one of the MCP23XXX family of chip objects, there is a constructor overload that takes the address pin configurations instead of an address, so that Meadow.Foundation uses the appropriate address based on the pins, instead of requiring a pre-computed address.
Other Pins
In addition to the address pins, there are a number of other pins that must be connected up:
- Not Reset - The
RESET
pin is actually a "Not Reset." The line above "Reset" means "not." So unless that pin is pulled high (3.3V
), the chip will reset itself at random times and you'll get connection errors. - SCL and SDA - The
SCL
andSDA
pins are the I2C clock and data pins and go to theSC
andSD
pins on the Meadow, respectively. Each of these should also generally be pulled high (3.3V
) via a4.7kΩ
resistor. See the I2C guide for more information. - INT - The
INT
pin is for interrupt notifications, and is only necessary when using the GPIO pins in input mode and you want an event raised when the input value changes. - VSS and VDD - These go to ground and 3.3V power, respectively, and power the chip.
Code Examples
You can find code examples and links to sample projects for each of the MCP23XXX families and specific chips.
WriteToPort(IPin, bool)
Sets a particular pin's value. If that pin is not in output mode, this method will first set its mode to output.
Declaration
public void WriteToPort(IPin pin, bool value)
Parameters
Type | Name | Description |
---|---|---|
IPin | pin | The pin to write to. |
bool | value | The value to write. True for high, false for low. |
Remarks
Mcp23xxxx | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
The MCP chip family, referred to as MCP23XXX to represent the variations, is a digital I/O expander chip that uses I2C to communicate. It can be used to add additional digital input and output ports to Meadow and can be combined with up to eight MCP23xxx chips in total, providing 64 additional ports.
MCP23XXX chips are ubiquitous in the hardware world and is the typical interface chip for common I2C LCD backpacks, with the 74595 chip being the typical interface chip for SPI LCD backpacks.
MCP Chip Family
The MCP23XXX family includes the 8-bit MCP23008 and also includes the MCP23017, which is a 16-bit version of the MCP23008, offering 16 digital ports in total, and the MCP23S08 and MCP23S017 which are SPI versions of the MCP23008 and MCP23017, respectively.
Chip Addressing
The I2C address of the chip is configurable via the address pins and is in the binary form of 0100[A2][A1][A0]
, where A2
, A1
, and A0
refer to the three address pins on the chip:
For example, if all address pins were tied to ground, then the address of the chip would be 0100000
in binary, or 0x20
in hex, and 32
in decimal.
The I2C addresses can then be as follows, where 0
represents an address pin connected to ground, and 1
represents an address pin connected to 3.3V
:
Address Header | A2 | A1 | A0 | Resulting Hex Address | Resulting Decimal Address |
---|---|---|---|---|---|
0100 |
0 |
0 |
0 |
0x20 |
32 |
0100 |
0 |
0 |
1 |
0x21 |
33 |
0100 |
0 |
1 |
0 |
0x22 |
34 |
0100 |
0 |
1 |
1 |
0x23 |
35 |
0100 |
1 |
0 |
0 |
0x24 |
36 |
0100 |
1 |
0 |
1 |
0x25 |
37 |
0100 |
1 |
1 |
0 |
0x26 |
38 |
0100 |
1 |
1 |
1 |
0x27 |
39 |
Because there are 8 address possibilities, it's possible to put 8 MCP23XXX chips on a single I2C bus.
To make this simpler, when instantiating one of the MCP23XXX family of chip objects, there is a constructor overload that takes the address pin configurations instead of an address, so that Meadow.Foundation uses the appropriate address based on the pins, instead of requiring a pre-computed address.
Other Pins
In addition to the address pins, there are a number of other pins that must be connected up:
- Not Reset - The
RESET
pin is actually a "Not Reset." The line above "Reset" means "not." So unless that pin is pulled high (3.3V
), the chip will reset itself at random times and you'll get connection errors. - SCL and SDA - The
SCL
andSDA
pins are the I2C clock and data pins and go to theSC
andSD
pins on the Meadow, respectively. Each of these should also generally be pulled high (3.3V
) via a4.7kΩ
resistor. See the I2C guide for more information. - INT - The
INT
pin is for interrupt notifications, and is only necessary when using the GPIO pins in input mode and you want an event raised when the input value changes. - VSS and VDD - These go to ground and 3.3V power, respectively, and power the chip.
Code Examples
You can find code examples and links to sample projects for each of the MCP23XXX families and specific chips.
WriteToPorts(byte)
Outputs a byte value across all of the pins by writing directly to the output latch (OLAT) register
Declaration
public void WriteToPorts(byte mask)
Parameters
Type | Name | Description |
---|---|---|
byte | mask |
Remarks
Mcp23xxxx | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
The MCP chip family, referred to as MCP23XXX to represent the variations, is a digital I/O expander chip that uses I2C to communicate. It can be used to add additional digital input and output ports to Meadow and can be combined with up to eight MCP23xxx chips in total, providing 64 additional ports.
MCP23XXX chips are ubiquitous in the hardware world and is the typical interface chip for common I2C LCD backpacks, with the 74595 chip being the typical interface chip for SPI LCD backpacks.
MCP Chip Family
The MCP23XXX family includes the 8-bit MCP23008 and also includes the MCP23017, which is a 16-bit version of the MCP23008, offering 16 digital ports in total, and the MCP23S08 and MCP23S017 which are SPI versions of the MCP23008 and MCP23017, respectively.
Chip Addressing
The I2C address of the chip is configurable via the address pins and is in the binary form of 0100[A2][A1][A0]
, where A2
, A1
, and A0
refer to the three address pins on the chip:
For example, if all address pins were tied to ground, then the address of the chip would be 0100000
in binary, or 0x20
in hex, and 32
in decimal.
The I2C addresses can then be as follows, where 0
represents an address pin connected to ground, and 1
represents an address pin connected to 3.3V
:
Address Header | A2 | A1 | A0 | Resulting Hex Address | Resulting Decimal Address |
---|---|---|---|---|---|
0100 |
0 |
0 |
0 |
0x20 |
32 |
0100 |
0 |
0 |
1 |
0x21 |
33 |
0100 |
0 |
1 |
0 |
0x22 |
34 |
0100 |
0 |
1 |
1 |
0x23 |
35 |
0100 |
1 |
0 |
0 |
0x24 |
36 |
0100 |
1 |
0 |
1 |
0x25 |
37 |
0100 |
1 |
1 |
0 |
0x26 |
38 |
0100 |
1 |
1 |
1 |
0x27 |
39 |
Because there are 8 address possibilities, it's possible to put 8 MCP23XXX chips on a single I2C bus.
To make this simpler, when instantiating one of the MCP23XXX family of chip objects, there is a constructor overload that takes the address pin configurations instead of an address, so that Meadow.Foundation uses the appropriate address based on the pins, instead of requiring a pre-computed address.
Other Pins
In addition to the address pins, there are a number of other pins that must be connected up:
- Not Reset - The
RESET
pin is actually a "Not Reset." The line above "Reset" means "not." So unless that pin is pulled high (3.3V
), the chip will reset itself at random times and you'll get connection errors. - SCL and SDA - The
SCL
andSDA
pins are the I2C clock and data pins and go to theSC
andSD
pins on the Meadow, respectively. Each of these should also generally be pulled high (3.3V
) via a4.7kΩ
resistor. See the I2C guide for more information. - INT - The
INT
pin is for interrupt notifications, and is only necessary when using the GPIO pins in input mode and you want an event raised when the input value changes. - VSS and VDD - These go to ground and 3.3V power, respectively, and power the chip.
Code Examples
You can find code examples and links to sample projects for each of the MCP23XXX families and specific chips.
Events
InputChanged
Raised when the value of any pin configured for input interrupts changes This provides raw port state data from the MCP23xxx It's highly recommended to prefer using the events exposed on the digital input ports instead.
Declaration
public event EventHandler<IOExpanderInputChangedEventArgs> InputChanged
Event Type
Type | Description |
---|---|
EventHandler<IOExpanderInputChangedEventArgs> |
Remarks
Mcp23xxxx | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
The MCP chip family, referred to as MCP23XXX to represent the variations, is a digital I/O expander chip that uses I2C to communicate. It can be used to add additional digital input and output ports to Meadow and can be combined with up to eight MCP23xxx chips in total, providing 64 additional ports.
MCP23XXX chips are ubiquitous in the hardware world and is the typical interface chip for common I2C LCD backpacks, with the 74595 chip being the typical interface chip for SPI LCD backpacks.
MCP Chip Family
The MCP23XXX family includes the 8-bit MCP23008 and also includes the MCP23017, which is a 16-bit version of the MCP23008, offering 16 digital ports in total, and the MCP23S08 and MCP23S017 which are SPI versions of the MCP23008 and MCP23017, respectively.
Chip Addressing
The I2C address of the chip is configurable via the address pins and is in the binary form of 0100[A2][A1][A0]
, where A2
, A1
, and A0
refer to the three address pins on the chip:
For example, if all address pins were tied to ground, then the address of the chip would be 0100000
in binary, or 0x20
in hex, and 32
in decimal.
The I2C addresses can then be as follows, where 0
represents an address pin connected to ground, and 1
represents an address pin connected to 3.3V
:
Address Header | A2 | A1 | A0 | Resulting Hex Address | Resulting Decimal Address |
---|---|---|---|---|---|
0100 |
0 |
0 |
0 |
0x20 |
32 |
0100 |
0 |
0 |
1 |
0x21 |
33 |
0100 |
0 |
1 |
0 |
0x22 |
34 |
0100 |
0 |
1 |
1 |
0x23 |
35 |
0100 |
1 |
0 |
0 |
0x24 |
36 |
0100 |
1 |
0 |
1 |
0x25 |
37 |
0100 |
1 |
1 |
0 |
0x26 |
38 |
0100 |
1 |
1 |
1 |
0x27 |
39 |
Because there are 8 address possibilities, it's possible to put 8 MCP23XXX chips on a single I2C bus.
To make this simpler, when instantiating one of the MCP23XXX family of chip objects, there is a constructor overload that takes the address pin configurations instead of an address, so that Meadow.Foundation uses the appropriate address based on the pins, instead of requiring a pre-computed address.
Other Pins
In addition to the address pins, there are a number of other pins that must be connected up:
- Not Reset - The
RESET
pin is actually a "Not Reset." The line above "Reset" means "not." So unless that pin is pulled high (3.3V
), the chip will reset itself at random times and you'll get connection errors. - SCL and SDA - The
SCL
andSDA
pins are the I2C clock and data pins and go to theSC
andSD
pins on the Meadow, respectively. Each of these should also generally be pulled high (3.3V
) via a4.7kΩ
resistor. See the I2C guide for more information. - INT - The
INT
pin is for interrupt notifications, and is only necessary when using the GPIO pins in input mode and you want an event raised when the input value changes. - VSS and VDD - These go to ground and 3.3V power, respectively, and power the chip.
Code Examples
You can find code examples and links to sample projects for each of the MCP23XXX families and specific chips.