PlatformIO Community

Adafruit I2C Library problem

I just opened PIO after about a year. Lots of libraries needed updating.
I had trouble getting Adafruit BusIO and I2C Device and others to update. There were errors, but there are no notifications remaining.

I have a program that worked really well on ESP32. These lines are causing my build to fail:

void Adafruit_I2CDevice::end(void) {
#ifndef ESP8266
  // ESP8266 does not implement Wire::end()
  _wire->end();
#endif

Error:
“Class TwoWire has no member named ‘end’”

When I comment out the lines in Adafruit I2CDevice.cpp, it builds but still doesn’t get onto the WiFi.
There isn’t an 8266, so do I need those lines?

I want to know why it isn’t getting online, but figured I’d ask this question before uploading the code.

Hi Joe.

The error seems to indicate that ESP8266 is in fact defined. Somewhere. Otherwise it wouldn’t be trying to call TwoWire::end() one assumes.

Can you add these lines to your code somewhere after the various #includes etc:

#ifdef ESP8266
#error ESP8266 is actually defined and should not be
#endif

Assuming I’ve got the syntax correct, if ESP8266 is defined, as would appear, then this should stop compiling with an error.

All you need to do is a clean build first, then a new build. Click on the trash can/dustbin icon in VSCode with the project folder open to clean, and then build in the usual manner.

Let us know if your compilation does indeed end with the error message above. Ta.

Cheers,
Norm.

Thanks Norm,
This error came up in a program that worked last year. The 8266 is ifdef in the library. It’s nowhere in the program.

It worked last year with last year’s library version. While your code hasn’t changed, the library code might have and might have bugs.

If you add the lines I mentioned to your code, it should throw an error in a clean compile, if the library has defined the macro.

Try it and see what happens.

Cheers,
Norm.

I’ll try it.
I updated all the libraries when I opened PIO, sometimes several times. This is one of the libraries that updated several times.

Is the last-year library still in the folder after all of those updates?

Is " is actually defined and should not be" C++??
I’ll ty it.

I deleted the libraries from /pio, and it built.
I added your #ifdef lines.
I guess those lines have no effect if there’s no 8266.

Sounds like you had some rogue stuff lying around, maybe, that deleting fixed. I would advise always running a “build clean” if libraries update, just in case

Those lines have only an effect if that macro for the 8266 was defined, it will force the C++ preprocessor into an error and stop the build.

You can remove them now, and recompile, if you wish.

Cheers,
Norm.

1 Like