I'm having a weird problem with the Adafruit_MCP23X17 library (I have the latest installed, and latest version of BusIO), specifically when trying to set up one of these devices with a defined I2C address. For testing purposes, I have reduced my system to the following:
1x QTPY microcontroller, providing 3.3V and GND
1x mcp23017 at I2C address 0x00 (pins A0, A1, A2 connected to GND)
mcp 23017 ~reset line pulled to 3.3V via 100kΩ
0.1 uF and 10uF caps on 3.3V
2.2kΩ pull-ups to 3.3V on SCK and SCL pins from QTPY
Plus a couple of wires to pull some of the mcp23017 IO pins high so I can make sure I'm really reading them
When I run the following sketch, this device works as anticipated:
Code: Select all
#include <Adafruit_MCP23X17.h>
// Create IO expander instance
Adafruit_MCP23X17 mcp0;
void setup() {
mcp0.begin_I2C();
Serial.begin(9600);
}
void loop() {
Serial.println("Reading mcp0 port: " + String(mcp0.readGPIO()));
delay(1000);
}
Code: Select all
Reading mcp0 port: 32
Code: Select all
#include <Adafruit_MCP23X17.h>
// Create IO expander instance
Adafruit_MCP23X17 mcp0;
void setup() {
mcp0.begin_I2C(0);
Serial.begin(9600);
}
void loop() {
Serial.println("Reading mcp0 port: " + String(mcp0.readGPIO()));
delay(1000);
}
Code: Select all
Reading mcp0 port: 255