Arduino LCD display with libraries Adafruit_MCP23017 & LiquidTWI2.

Hi, I have mcp23017, I wanted to use pins GPA0 - GPA7 for other purposes and GPB1 - GPB 7 for LCD display. I use the Adafruit_MCP23017 and LiquidTWI2 libraries. The problem with looping when I want to write data to the display - nothing is displayed.

I found a problem. If I use lcd.begin (16,2); before mcp.begin (); , everything works but it's only in setup. It doesn't work if I want to write something after the mcp.begin () command.

My code:

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <Wire.h>
#include "Adafruit_MCP23017.h"
#include <LiquidTWI2.h>
#include <Sparkfun_APDS9301_Library.h>

LiquidTWI2 lcd(0);

void setup() {
  lcd.setMCPType(LTI_TYPE_MCP23017);
  lcd.begin(16, 2);
  lcd.print("Hello"); //this working great


  mcp.begin(); // after i use this nothing more will appear on the display, only what's left in the setup before mcp.begin
  mcp.pinMode(0, OUTPUT); //MCP GPA0 INT1
  mcp.pinMode(1, OUTPUT); //MCP GPA1 INT2
  mcp.pinMode(2, OUTPUT); //MCP GPA2 INT3
  mcp.pinMode(3, OUTPUT); //MCP GPA3 INT4 relay

}
void loop() {
  lcd.setCursor(0, 1);
  lcd.print(millis()/1000);
}

Is it somehow combined to make it work? Or how should I do it ? Thank you for answers.

The LiquidTWI2 library does not support the use of the unused mcp23017 pins and you cannot add a second library to access those pins because the libraries conflict with each other just like you discovered. You cannot have two different libraries trying to control the same device.

I only see 6 I/O needed so the easiest solution is to use esp8266 pins for your additional I/O or if you must, add a second mcp23017 with a different address on pins A0/1/2.

okay i use another mcp23017 with 0x21 address Then I'll tell you if it helped

Now works perfectly. I use another MCP23017 with 0x21 address. Using with mcp1.begin(1); (for 0x21) and LiquidTWI2 lcd(0); (for 0x20) LCD.. Thx for help :slight_smile: