<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.kamamilabs.com/index.php?action=history&amp;feed=atom&amp;title=KAmod_I2C-IOexp16</id>
	<title>KAmod I2C-IOexp16 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.kamamilabs.com/index.php?action=history&amp;feed=atom&amp;title=KAmod_I2C-IOexp16"/>
	<link rel="alternate" type="text/html" href="https://wiki.kamamilabs.com/index.php?title=KAmod_I2C-IOexp16&amp;action=history"/>
	<updated>2026-04-29T15:06:08Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.3</generator>
	<entry>
		<id>https://wiki.kamamilabs.com/index.php?title=KAmod_I2C-IOexp16&amp;diff=5659&amp;oldid=prev</id>
		<title>Grzegorzbecker: Created page with &quot;__jzpdf__ ===== Opis ===== &lt;b&gt;KAmod I2C-IOexp16 - Expander 16 digital I/O lines with MCP23017&lt;/b&gt;&lt;br&gt; &lt;br&gt; The KAmod I2C-IOexp16 module contains 16 digital lines that can act as inputs or outputs. Control is via the I2C bus. &lt;center&gt; center &lt;/center&gt; &lt;center&gt; center &lt;/center&gt;  ===== Basic features and parameters ===== * 16 lines that can act as inputs or outputs, with a ma...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.kamamilabs.com/index.php?title=KAmod_I2C-IOexp16&amp;diff=5659&amp;oldid=prev"/>
		<updated>2025-04-09T09:23:21Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;__jzpdf__ ===== Opis ===== &amp;lt;b&amp;gt;KAmod I2C-IOexp16 - Expander 16 digital I/O lines with MCP23017&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt; &amp;lt;br&amp;gt; The KAmod I2C-IOexp16 module contains 16 digital lines that can act as inputs or outputs. Control is via the I2C bus. &amp;lt;center&amp;gt; &lt;a href=&quot;/index.php?title=File:KAmod_I2C-IOexp16_1.jpg&quot; title=&quot;File:KAmod I2C-IOexp16 1.jpg&quot;&gt;none|850px|thumb|center&lt;/a&gt; &amp;lt;/center&amp;gt; &amp;lt;center&amp;gt; &lt;a href=&quot;/index.php?title=File:KAmod_I2C-IOexp16_2.jpg&quot; title=&quot;File:KAmod I2C-IOexp16 2.jpg&quot;&gt;none|930px|thumb|center&lt;/a&gt; &amp;lt;/center&amp;gt;  ===== Basic features and parameters ===== * 16 lines that can act as inputs or outputs, with a ma...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;__jzpdf__&lt;br /&gt;
===== Opis =====&lt;br /&gt;
&amp;lt;b&amp;gt;KAmod I2C-IOexp16 - Expander 16 digital I/O lines with MCP23017&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
The KAmod I2C-IOexp16 module contains 16 digital lines that can act as inputs or outputs. Control is via the I2C bus.&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
[[File:KAmod_I2C-IOexp16_1.jpg|none|850px|thumb|center]]&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
[[File:KAmod_I2C-IOexp16_2.jpg|none|930px|thumb|center]]&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Basic features and parameters =====&lt;br /&gt;
* 16 lines that can act as inputs or outputs, with a maximum current of 20 mA&lt;br /&gt;
* Contains an expander type MCP23017&lt;br /&gt;
* Control via I2C interface with a clock speed of max. 1 MHz&lt;br /&gt;
* 3 address lines allow you to connect 8 modules to one I2C bus&lt;br /&gt;
* Interrupt output that can be assigned to the port A line&lt;br /&gt;
* ​​Power supply 2...5 V&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
===== Standard Equipment =====&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 800px;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;text-align: center;&amp;quot;|Code&lt;br /&gt;
! style=&amp;quot;text-align: center;&amp;quot;|Description&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: center;&amp;quot;|&amp;lt;b&amp;gt;KAmod I2C-IOexp16&amp;lt;/b&amp;gt;&lt;br /&gt;
| style=&amp;quot;text-align: left;&amp;quot;|&lt;br /&gt;
* Assembled and started module&lt;br /&gt;
* 1 x goldpin header 10-pin raster 2.54 mm&lt;br /&gt;
* 1 x goldpin header 8-pin raster 2.54 mm&lt;br /&gt;
* 2 x goldpin header 4-pin raster 2.54 mm&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
[[File:KAmod_I2C-IOexp16_3.jpg|none|900px|thumb|center]]&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Schematic =====&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
[[File:KAmod I2C IOexp16 sch.jpg|none|900px|thumb|center]]&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== I/O Line Layout =====&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 1000px;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;text-align: center;&amp;quot;|&amp;lt;b&amp;gt;Designation&amp;lt;/b&amp;gt;&lt;br /&gt;
! style=&amp;quot;text-align: center;&amp;quot;|&amp;lt;b&amp;gt;Function&amp;lt;/b&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: center;&amp;quot;|&amp;lt;b&amp;gt;PA (J2)&amp;lt;/b&amp;gt;&lt;br /&gt;
| style=&amp;quot;text-align: left;&amp;quot;|&lt;br /&gt;
*8 I/O pins belonging to port A&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: center;&amp;quot;|&amp;lt;b&amp;gt;PB (J3)&amp;lt;/b&amp;gt;&lt;br /&gt;
| style=&amp;quot;text-align: left;&amp;quot;|&lt;br /&gt;
*4 pins (0...3) I/O belonging to port B&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: center;&amp;quot;|&amp;lt;b&amp;gt;PB (J4)&amp;lt;/b&amp;gt;&lt;br /&gt;
| style=&amp;quot;text-align: left;&amp;quot;|&lt;br /&gt;
*4 pins (4...7) I/O belonging to port B&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The I/O lines were led out as solder points with holes, arranged with a standard 2.54 mm pitch, right at the edges of the board. They allow for soldering wires or goldpins. The assignment of ports and leads is described in the figure below.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Each lead can be independently configured as a digital input or output. Digital outputs can be loaded with a maximum current of 20 mA. Digital inputs have independently configurable pull-up resistors and enable the generation of interrupts. Port A lines can signal the occurrence of an interrupt on an additional lead - INTA.&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
[[File:KAmod_I2C_IOexp16_io.png|none|600px|thumb|center]]&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Control signals =====&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 1000px;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;text-align: center;&amp;quot;|&amp;lt;b&amp;gt;Designation&amp;lt;/b&amp;gt;&lt;br /&gt;
! style=&amp;quot;text-align: center;&amp;quot;|&amp;lt;b&amp;gt;Function&amp;lt;/b&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: left;&amp;quot;|&amp;lt;b&amp;gt;SD (J1)&amp;lt;/b&amp;gt;&lt;br /&gt;
| style=&amp;quot;text-align: left;&amp;quot;| SDA signal (data) of the I2C interface&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: left;&amp;quot;|&amp;lt;b&amp;gt;SC (J1)&amp;lt;/b&amp;gt;&lt;br /&gt;
| style=&amp;quot;text-align: left;&amp;quot;| SCL signal (clock) of the I2C interface&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: left;&amp;quot;|&amp;lt;b&amp;gt;RST (J1)&amp;lt;/b&amp;gt;&lt;br /&gt;
| style=&amp;quot;text-align: left;&amp;quot;| Input that resets the system&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: left;&amp;quot;|&amp;lt;b&amp;gt;INTA (J1)&amp;lt;/b&amp;gt;&lt;br /&gt;
| style=&amp;quot;text-align: left;&amp;quot;| Output signaling the occurrence of an interrupt on port A lines&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: left;&amp;quot;|&amp;lt;b&amp;gt;A0, A1 (J1)&amp;lt;/b&amp;gt;&lt;br /&gt;
| style=&amp;quot;text-align: left;&amp;quot;| Inputs allowing setting the I2C interface address (bits 1 and 0). Set to logical 0 by default.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: left;&amp;quot;|&amp;lt;b&amp;gt;A2 (jumper)&amp;lt;/b&amp;gt;&lt;br /&gt;
| style=&amp;quot;text-align: left;&amp;quot;| Installing a solder jumper allows setting bit 2 of the I2C interface address.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The KAmod I2C-IOexp16 module is controlled via the I2C interface, which can be clocked with a 100 kHz, 400 kHz or 1 MHz clock signal. The functions of the pins on the J1 connector are as follows:&lt;br /&gt;
* The I2C control interface signals are SD – SDA, and SC – SCL. They are not equipped with pull-up resistors – the control system must include the appropriate elements.&lt;br /&gt;
* Inputs A0, A1 allow you to set the address (bits 1 and 0) that the module connected to the I2C interface will have. By default, these inputs are connected to ground via resistors (pull-down) and take logical values ​​of 0. Connecting the positive power supply pole to inputs A0 and A1 sets logical 1 for the lowest address bits.&lt;br /&gt;
* Jumper A2 located on the bottom of the module board (bottom) allows you to set bit no. 2 defining the I2C address. By default, the A2 signal is connected to ground via a resistor (pull-down) and takes the logical value of 0. Installing a solder jumper allows you to set logical 1 for bit no. 2 of the I2C interface address.&lt;br /&gt;
&lt;br /&gt;
* All available I2C interface addresses are in the range 0x20...0x27.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Detailed information on communication and configuration of the MCP23017 system is available in the technical documentation of this system.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Additional signals are:&lt;br /&gt;
* The reset signal (RST) is used to reset the MCP23017 system on the KAmod I2C-IOexp16 board, which restores all settings to their initial state.&lt;br /&gt;
* The INTA output can signal an interrupt on the A port lines with an appropriate state.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
[[File:KAmod_I2C_IOexp16_ster1.png|none|600px|thumb|center]]&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
[[File:KAmod_I2C_IOexp16_ster2.png|none|500px|thumb|center]]&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Power =====&lt;br /&gt;
The KAmod I2C-IOexp16 module can be powered by a DC voltage of 2...5 V.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
[[File:KAmod_I2C_IOexp16_pwr.png|none|500px|thumb|center]]&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Dimensions =====&lt;br /&gt;
The dimensions of the KAmod I2C-IOexp16 board are 31x18 mm. There are 2 mounting holes on the board with a diameter of 3.2 mm.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
[[File:KAmod_I2C_IOexp16_wym.png|none|600px|thumb|center]]&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Test program =====&lt;br /&gt;
The test program was written in the Arduino environment for the [https://kamami.pl/esp32/1191671-kamod-esp32-powrs485-plytka-ewaluacyjna-z-modulem-wi-fi-typu-esp32-wroom-i-interfejsem-rs485-5906623488070.html KAmodESP32 POW RS485] board. The KAmod I2C-IOexp16 module was connected via the I2C interface.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;arduino&amp;quot; line&amp;gt;&lt;br /&gt;
#include &amp;lt;Wire.h&amp;gt;&lt;br /&gt;
#include &amp;lt;Adafruit_MCP23X17.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
//LED&lt;br /&gt;
#define LED_PIN         2 &lt;br /&gt;
#define MY_DELAY        2000&lt;br /&gt;
#define TEST_LED_ON     1&lt;br /&gt;
#define TEST_LED_OFF    0&lt;br /&gt;
&lt;br /&gt;
//I2C&lt;br /&gt;
#define I2C_SDA         33&lt;br /&gt;
#define I2C_SCL         32&lt;br /&gt;
#define I2C_FREQ        100000&lt;br /&gt;
#define MCP23017_ARD    0x20&lt;br /&gt;
&lt;br /&gt;
TwoWire I2Cbus = TwoWire(0);&lt;br /&gt;
Adafruit_MCP23X17 MCPIO;&lt;br /&gt;
int i;&lt;br /&gt;
&lt;br /&gt;
//-----------------------------------------------------------------&lt;br /&gt;
void setup() {&lt;br /&gt;
  Serial.begin(115200);&lt;br /&gt;
  Serial.println();&lt;br /&gt;
  Serial.println(&amp;quot;Hello. KAmod IOexp16 test&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
  pinMode(LED_PIN, OUTPUT);&lt;br /&gt;
  digitalWrite(LED_PIN, HIGH);&lt;br /&gt;
&lt;br /&gt;
  delay(500);&lt;br /&gt;
  while(!I2Cbus.begin(I2C_SDA, I2C_SCL, I2C_FREQ)){&lt;br /&gt;
    Serial.println(&amp;quot;I2C init failed...&amp;quot;);&lt;br /&gt;
    delay(500);&lt;br /&gt;
  }&lt;br /&gt;
  while (!MCPIO.begin_I2C(MCP23017_ARD, &amp;amp;I2Cbus)) {&lt;br /&gt;
    Serial.println(&amp;quot;MCP init failed...&amp;quot;);&lt;br /&gt;
    delay(500);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  Serial.println(&amp;quot;I2C init OK&amp;quot;);&lt;br /&gt;
  delay(100);&lt;br /&gt;
  MCPIO.pinMode(TEST_LED, OUTPUT);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//-----------------------------------------------------------------&lt;br /&gt;
void loop() {&lt;br /&gt;
  if (i &amp;amp; 1){&lt;br /&gt;
    digitalWrite(LED_PIN, TEST_LED_ON);&lt;br /&gt;
  } else {&lt;br /&gt;
    digitalWrite(LED_PIN, TEST_LED_OFF);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  MCPIO.pinMode(i, OUTPUT);&lt;br /&gt;
  MCPIO.digitalWrite(i, TEST_LED_ON);&lt;br /&gt;
  delay(100);&lt;br /&gt;
  MCPIO.pinMode(i, OUTPUT);&lt;br /&gt;
  MCPIO.digitalWrite(i, TEST_LED_OFF);&lt;br /&gt;
  delay(100);&lt;br /&gt;
  &lt;br /&gt;
  i++;&lt;br /&gt;
  if (i  &amp;gt;= 16){&lt;br /&gt;
    i = 0;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== External links=====&lt;br /&gt;
*[https://wiki.kamamilabs.com/images/8/89/MCP23017.pdf Data sheet MCP23017]&lt;br /&gt;
*[https://github.com/KAMAMI-Labs/KAmod-I2C-IOexp16.git Sample programs]&lt;/div&gt;</summary>
		<author><name>Grzegorzbecker</name></author>
	</entry>
</feed>