Library conflict

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
dsc3507
 
Posts: 30
Joined: Fri Feb 06, 2015 1:51 am

Library conflict

Post by dsc3507 »

There seems to be a conflict between these two libraries -

#include <Adafruit_MCP23X17.h>
#include <Adafruit_MCP4728.h>

When compiling on the ESP8266 the MCP23017 compiles and works fine. But when adding the MCP4728 it seems to try and use the MCP23X17 library. The error is no member named "begin" for Adafruit_MCP23x17. I suspect the begin statment is wrong for that device and it is assuming the GPIO extender?

Here is my code segment. Both are from Adafruit examples. Is there a problem using two different MCP devices?

if (!mcp.begin_I2C()) {
Serial.println("Error - MPC23017");
}

ads1115.begin(0x48);

if (!mcp.begin()) {
Serial.println("Failed to find MCP4728 chip");
while (1) {
delay(10);
}
};

User avatar
adafruit_support_carter
 
Posts: 29152
Joined: Tue Nov 29, 2016 2:45 pm

Re: Library conflict

Post by adafruit_support_carter »

Please post full sketch code.

User avatar
dsc3507
 
Posts: 30
Joined: Fri Feb 06, 2015 1:51 am

Re: Library conflict

Post by dsc3507 »

You don't want my entire sketch, it is hundreds of lines long. So here is a sketch that is basically the Adafruit example which does not compile. It does show that the other libraries and the rest of my sketch are not the issue.

Code: Select all

#include <Adafruit_MCP4728.h>

void setup() {
  
if (!mcp.begin()) {
    Serial.println("Failed to find MCP4728 chip");
    while (1) {
      delay(10);
    }
  };

mcp.setChannelValue(MCP4728_CHANNEL_A, 4095);
mcp.setChannelValue(MCP4728_CHANNEL_B, 2048);
mcp.setChannelValue(MCP4728_CHANNEL_C, 1024);
mcp.setChannelValue(MCP4728_CHANNEL_D, 0);

}

void loop() {
  // put your main code here, to run repeatedly:
delay(1000);
}
The mcp.set.Channel lines are not recognized. The library is installed. I have not had any problem with compiling or using other feather boards.

Code: Select all

Arduino: 1.8.19 (Linux), Board: "Adafruit Feather HUZZAH ESP8266, 80 MHz, Flash, Disabled (new aborts on oom), Disabled, All SSL ciphers (most compatible), 32KB cache + 32KB IRAM (balanced), Use pgm_read macros for IRAM/PROGMEM, 4MB (FS:1MB OTA:~1019KB), v2 Lower Memory, Disabled, None, Only Sketch, 115200"

/home/doug/Arduino/esp8266_email_test/esp8266_email_test.ino: In function 'void setup()':
esp8266_email_test:235:12: error: 'class Adafruit_MCP23X17' has no member named 'begin'
  235 |   if (!mcp.begin()) {
      |            ^~~~~
esp8266_email_test:311:5: error: 'class Adafruit_MCP23X17' has no member named 'setChannelValue'
  311 | mcp.setChannelValue(MCP4728_CHANNEL_A, 4095);
      |     ^~~~~~~~~~~~~~~
esp8266_email_test:312:5: error: 'class Adafruit_MCP23X17' has no member named 'setChannelValue'
  312 | mcp.setChannelValue(MCP4728_CHANNEL_B, 2048);
      |     ^~~~~~~~~~~~~~~
esp8266_email_test:313:5: error: 'class Adafruit_MCP23X17' has no member named 'setChannelValue'
  313 | mcp.setChannelValue(MCP4728_CHANNEL_C, 1024);
      |     ^~~~~~~~~~~~~~~
esp8266_email_test:314:5: error: 'class Adafruit_MCP23X17' has no member named 'setChannelValue'
  314 | mcp.setChannelValue(MCP4728_CHANNEL_D, 0);
      |     ^~~~~~~~~~~~~~~
Multiple libraries were found for "SD.h"
 Used: /home/doug/.arduino15/packages/esp8266/hardware/esp8266/3.0.2/libraries/SD
 Not used: /mnt/doug-raid/doug/Downloads/arduino-1.8.19/libraries/SD
exit status 1
'class Adafruit_MCP23X17' has no member named 'begin'


This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Last edited by adafruit_support_carter on Tue Jan 24, 2023 12:43 pm, edited 1 time in total.

User avatar
dsc3507
 
Posts: 30
Joined: Fri Feb 06, 2015 1:51 am

Re: Library conflict

Post by dsc3507 »

OK found the problem, I had inadvertently left out the initializer -

Adafruit_MCP4728 mcp;

Sorry about that.

So since I had a prior MCP device I added it and renamed it as well as all of the calls.

Adafruit_BME280 bme; // I2C
Adafruit_MCP23X17 mcp;
Adafruit_ADS1115 ads1115;
Adafruit_MCP4728 mcp4728; <<<< was mcp

if (!mcp4728.begin()) {
Serial.println("Failed to find MCP4728 chip");
while (1) {
delay(10);
}
};

mcp4728.setChannelValue(MCP4728_CHANNEL_A, 4095);
mcp4728.setChannelValue(MCP4728_CHANNEL_B, 2048);
mcp4728.setChannelValue(MCP4728_CHANNEL_C, 1024);
mcp4728.setChannelValue(MCP4728_CHANNEL_D, 0);

The 4728 had been maping to the 23x17 so that is why I was getting those strange messages.

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”