Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Component Documentation

How to Use Adafruit GPIO Expander Bonnet - 16 Additional I/O over I2C: Examples, Pinouts, and Specs

Image of Adafruit GPIO Expander Bonnet - 16 Additional I/O over I2C
Cirkit Designer LogoDesign with Adafruit GPIO Expander Bonnet - 16 Additional I/O over I2C in Cirkit Designer

Introduction

The Adafruit GPIO Expander Bonnet (Part ID: 4132) is a compact and versatile board designed to provide 16 additional general-purpose input/output (GPIO) pins to your microcontroller or single-board computer. It communicates via the I2C interface, making it an excellent choice for projects requiring more GPIO pins than your device natively supports. This bonnet is particularly well-suited for Raspberry Pi and other I2C-compatible platforms.

Explore Projects Built with Adafruit GPIO Expander Bonnet - 16 Additional I/O over I2C

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
ESP32-Based I2C Communication Hub with Multiplexer and Expander
Image of Lights: A project utilizing Adafruit GPIO Expander Bonnet - 16 Additional I/O over I2C in a practical application
This circuit features an Olimex ESP32-EVB microcontroller unit (MCU) for processing and connectivity, interfaced with an MCP23017 I/O expander and an Adafruit TCA9548A I2C multiplexer to expand the number of I/O lines and allow multiple I2C devices to communicate with the MCU over the same bus. Pull-up resistors are connected to the I2C lines for proper bus operation, and both the MCP23017 and TCA9548A have their reset lines pulled high, likely for normal operation without external reset control.
Cirkit Designer LogoOpen Project in Cirkit Designer
MCP23017-Expanded I/O Interface with ADS1115 ADC and ESP32 Control
Image of door and window sensors: A project utilizing Adafruit GPIO Expander Bonnet - 16 Additional I/O over I2C in a practical application
This circuit features two MCP23017 I/O expanders interfaced with multiple switches, allowing for the expansion of input capabilities. The MCP23017s are connected via I2C to an Olimex ESP32-EVB microcontroller, which likely manages the input states from the switches. Additionally, an Adafruit ADS1115 16-bit ADC is included, suggesting that some analog inputs are being monitored, with the ADC also interfaced with the ESP32 via I2C.
Cirkit Designer LogoOpen Project in Cirkit Designer
ESP32-Based OLED Display Interface
Image of d: A project utilizing Adafruit GPIO Expander Bonnet - 16 Additional I/O over I2C in a practical application
This circuit features an ESP32 microcontroller connected to an OLED 1.3" display. The ESP32's GPIO pins 21 and 22 are used for I2C communication (SDA and SCL respectively) with the OLED display. The display is powered by the 5V output from the ESP32, and both devices share a common ground.
Cirkit Designer LogoOpen Project in Cirkit Designer
ESP32 and MCP23017-Based Smart Relay Control System with DHT22 Sensors
Image of Indoor Lounge: A project utilizing Adafruit GPIO Expander Bonnet - 16 Additional I/O over I2C in a practical application
This circuit is a control system that uses an ESP32 microcontroller to manage multiple relays and read data from DHT22 temperature and humidity sensors. The DFRobot Gravity MCP23017 I2C module expands the GPIO capabilities of the ESP32, allowing it to control additional relays for switching high-power devices.
Cirkit Designer LogoOpen Project in Cirkit Designer

Explore Projects Built with Adafruit GPIO Expander Bonnet - 16 Additional I/O over I2C

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of Lights: A project utilizing Adafruit GPIO Expander Bonnet - 16 Additional I/O over I2C in a practical application
ESP32-Based I2C Communication Hub with Multiplexer and Expander
This circuit features an Olimex ESP32-EVB microcontroller unit (MCU) for processing and connectivity, interfaced with an MCP23017 I/O expander and an Adafruit TCA9548A I2C multiplexer to expand the number of I/O lines and allow multiple I2C devices to communicate with the MCU over the same bus. Pull-up resistors are connected to the I2C lines for proper bus operation, and both the MCP23017 and TCA9548A have their reset lines pulled high, likely for normal operation without external reset control.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of door and window sensors: A project utilizing Adafruit GPIO Expander Bonnet - 16 Additional I/O over I2C in a practical application
MCP23017-Expanded I/O Interface with ADS1115 ADC and ESP32 Control
This circuit features two MCP23017 I/O expanders interfaced with multiple switches, allowing for the expansion of input capabilities. The MCP23017s are connected via I2C to an Olimex ESP32-EVB microcontroller, which likely manages the input states from the switches. Additionally, an Adafruit ADS1115 16-bit ADC is included, suggesting that some analog inputs are being monitored, with the ADC also interfaced with the ESP32 via I2C.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of d: A project utilizing Adafruit GPIO Expander Bonnet - 16 Additional I/O over I2C in a practical application
ESP32-Based OLED Display Interface
This circuit features an ESP32 microcontroller connected to an OLED 1.3" display. The ESP32's GPIO pins 21 and 22 are used for I2C communication (SDA and SCL respectively) with the OLED display. The display is powered by the 5V output from the ESP32, and both devices share a common ground.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of Indoor Lounge: A project utilizing Adafruit GPIO Expander Bonnet - 16 Additional I/O over I2C in a practical application
ESP32 and MCP23017-Based Smart Relay Control System with DHT22 Sensors
This circuit is a control system that uses an ESP32 microcontroller to manage multiple relays and read data from DHT22 temperature and humidity sensors. The DFRobot Gravity MCP23017 I2C module expands the GPIO capabilities of the ESP32, allowing it to control additional relays for switching high-power devices.
Cirkit Designer LogoOpen Project in Cirkit Designer

Common Applications and Use Cases

  • Expanding GPIO capabilities for Raspberry Pi or other microcontrollers.
  • Controlling LEDs, relays, or other digital devices.
  • Reading multiple button inputs or sensors.
  • Prototyping and testing circuits requiring additional I/O pins.

Technical Specifications

The Adafruit GPIO Expander Bonnet is based on the MCP23017 I/O expander chip, which provides robust and reliable GPIO expansion over I2C.

Key Technical Details

Parameter Value
Operating Voltage 3.3V or 5V
Communication Protocol I2C
GPIO Pins 16 (organized as two 8-bit ports)
I2C Address Range 0x20 to 0x27 (configurable)
Maximum Current per Pin 25mA
Pull-up Resistors Configurable internal pull-ups
Dimensions 65mm x 30mm x 5mm

Pin Configuration and Descriptions

The GPIO Expander Bonnet has the following key pin connections:

I2C Interface Pins

Pin Name Description
SDA I2C Data Line
SCL I2C Clock Line
GND Ground
VIN Power input (3.3V or 5V)

GPIO Pins

Pin Name Description
GPA0-GPA7 General-purpose I/O pins (Port A)
GPB0-GPB7 General-purpose I/O pins (Port B)

Address Selection Pins

Pin Name Description
A0, A1, A2 I2C address configuration pins

Usage Instructions

How to Use the Component in a Circuit

  1. Connect Power and I2C Lines:

    • Connect the VIN pin to a 3.3V or 5V power source.
    • Connect the GND pin to the ground of your microcontroller.
    • Connect the SDA and SCL pins to the corresponding I2C pins on your microcontroller.
  2. Configure the I2C Address:

    • Use the A0, A1, and A2 pins to set the I2C address. These pins can be tied to GND or VIN to select an address between 0x20 and 0x27.
  3. Connect GPIO Devices:

    • Attach your input or output devices (e.g., LEDs, buttons, sensors) to the GPIO pins (GPA0-GPA7 and GPB0-GPB7).
  4. Install Required Libraries:

    • For Raspberry Pi or Arduino, install the Adafruit MCP23017 library to simplify communication with the GPIO expander.
  5. Write Code to Control the GPIO Pins:

    • Use the library functions to configure pins as inputs or outputs and to read/write data.

Important Considerations and Best Practices

  • Ensure the I2C pull-up resistors are enabled on your microcontroller or add external pull-ups if necessary.
  • Avoid exceeding the maximum current rating of 25mA per GPIO pin.
  • Use appropriate resistors when connecting LEDs or other components to prevent damage.
  • If using multiple MCP23017 devices, ensure each has a unique I2C address.

Example Code for Arduino UNO

Below is an example of how to use the GPIO Expander Bonnet with an Arduino UNO:

#include <Wire.h>
#include "Adafruit_MCP23X17.h"

// Create an MCP23017 object
Adafruit_MCP23X17 mcp;

void setup() {
  Serial.begin(9600); // Initialize serial communication for debugging
  while (!Serial) {
    delay(10); // Wait for Serial Monitor to open
  }

  // Initialize the MCP23017
  if (!mcp.begin_I2C()) {
    Serial.println("Failed to initialize MCP23017. Check connections!");
    while (1);
  }
  Serial.println("MCP23017 initialized successfully!");

  // Set pin GPA0 as an output
  mcp.pinMode(0, OUTPUT);

  // Set pin GPA1 as an input with pull-up resistor enabled
  mcp.pinMode(1, INPUT);
  mcp.pullUp(1, HIGH);
}

void loop() {
  // Blink an LED connected to GPA0
  mcp.digitalWrite(0, HIGH); // Turn LED on
  delay(500);                // Wait 500ms
  mcp.digitalWrite(0, LOW);  // Turn LED off
  delay(500);                // Wait 500ms

  // Read the state of a button connected to GPA1
  if (mcp.digitalRead(1) == LOW) {
    Serial.println("Button pressed!");
  } else {
    Serial.println("Button not pressed.");
  }
  delay(100); // Short delay for stability
}

Troubleshooting and FAQs

Common Issues and Solutions

  1. MCP23017 Not Detected on I2C Bus:

    • Ensure the SDA and SCL lines are correctly connected.
    • Verify that the I2C address matches the configuration of the A0, A1, and A2 pins.
    • Check for proper pull-up resistors on the I2C lines.
  2. GPIO Pins Not Responding:

    • Confirm that the pins are correctly configured as inputs or outputs in your code.
    • Check for loose or incorrect wiring to the GPIO pins.
  3. Overheating or Damage:

    • Ensure the current through each GPIO pin does not exceed 25mA.
    • Use appropriate resistors when connecting LEDs or other components.

FAQs

Q: Can I use this bonnet with a 5V microcontroller?
A: Yes, the GPIO Expander Bonnet supports both 3.3V and 5V logic levels.

Q: How many MCP23017 devices can I connect to a single I2C bus?
A: You can connect up to 8 MCP23017 devices by configuring unique I2C addresses using the A0, A1, and A2 pins.

Q: Does the bonnet support PWM output?
A: The MCP23017 does not natively support PWM. However, you can implement software PWM using your microcontroller.

Q: Can I use this with a Raspberry Pi?
A: Yes, the GPIO Expander Bonnet is fully compatible with Raspberry Pi. Use the Adafruit CircuitPython library for easy integration.

This documentation provides all the essential details to get started with the Adafruit GPIO Expander Bonnet. For further assistance, refer to the official Adafruit guide or community forums.