Adafruit-MCP23017-Arduino-Library
Adafruit-MCP23017-Arduino-Library copied to clipboard
If the I2C-Bus is not available for any reason 32 Bytes of free heap gets consumed each cycle..
This method needs to be changed:
bool Adafruit_MCP23XXX::begin_I2C(uint8_t i2c_addr, TwoWire *wire) { i2c_dev = new Adafruit_I2CDevice(i2c_addr, wire); return i2c_dev->begin(); }
into:
bool Adafruit_MCP23XXX::begin_I2C(uint8_t i2c_addr, TwoWire *wire) { if (i2c_dev != nullptr) { delete i2c_dev; i2c_dev = nullptr; } i2c_dev = new Adafruit_I2CDevice(i2c_addr, wire); return i2c_dev->begin(); }
Also, this seems to be a general problem of this library.. only a successful run seems to avoid free heap problems..