Oled 128x32 i2c does not working

Hi
I am working with a MKR ZERO+oled 128x32 i2c, to display info using the sketch that come with ADAFRUIT
but i got the error listed below
looking for help
Stefano

Arduino: 1.8.15 (Windows 10), Board: "Arduino MKRZERO"

In file included from C:\Users\...\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp:1:0:

C:\Users\...\Arduino\libraries\Adafruit_BusIO/Adafruit_I2CDevice.h:9:36: error: 'TwoWire' has not been declared

   Adafruit_I2CDevice(uint8_t addr, TwoWire *theWire = &Wire);

                                    ^~~~~~~

In file included from C:\Users\...\Arduino\libraries\Adafruit_BusIO/Adafruit_BusIO_Register.h:1:0,

                 from C:\Users\...\Arduino\libraries\Adafruit_BusIO\Adafruit_BusIO_Register.cpp:1:

C:\Users\...\Arduino\libraries\Adafruit_BusIO/Adafruit_I2CDevice.h:9:36: error: 'TwoWire' has not been declared

   Adafruit_I2CDevice(uint8_t addr, TwoWire *theWire = &Wire);

                                    ^~~~~~~

C:\Users\...\Arduino\libraries\Adafruit_BusIO/Adafruit_I2CDevice.h:28:3: error: 'TwoWire' does not name a type; did you mean 'TwoWire_h'?

   TwoWire *_wire;

   ^~~~~~~

   TwoWire_h

C:\Users\...\Arduino\libraries\Adafruit_BusIO/Adafruit_I2CDevice.h:9:55: error: could not convert '& Wire' from 'arduino::TwoWire*' to 'int*'

   Adafruit_I2CDevice(uint8_t addr, TwoWire *theWire = &Wire);

                                                       ^~~~~

C:\Users\...\Arduino\libraries\Adafruit_BusIO/Adafruit_I2CDevice.h:28:3: error: 'TwoWire' does not name a type; did you mean 'TwoWire_h'?

   TwoWire *_wire;

   ^~~~~~~

   TwoWire_h

C:\Users\...\Arduino\libraries\Adafruit_BusIO/Adafruit_I2CDevice.h:9:55: error: could not convert '& Wire' from 'arduino::TwoWire*' to 'int*'

   Adafruit_I2CDevice(uint8_t addr, TwoWire *theWire = &Wire);

                                                       ^~~~~

C:\Users\...\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp:11:1: error: prototype for 'Adafruit_I2CDevice::Adafruit_I2CDevice(uint8_t, arduino::TwoWire*)' does not match any in class 'Adafruit_I2CDevice'

 Adafruit_I2CDevice::Adafruit_I2CDevice(uint8_t addr, TwoWire *theWire) {

 ^~~~~~~~~~~~~~~~~~

In file included from C:\Users\...\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp:1:0:

C:\Users\...\Arduino\libraries\Adafruit_BusIO/Adafruit_I2CDevice.h:7:7: error: candidates are: constexpr Adafruit_I2CDevice::Adafruit_I2CDevice(Adafruit_I2CDevice&&)

 class Adafruit_I2CDevice {

       ^~~~~~~~~~~~~~~~~~

C:\Users\...\Arduino\libraries\Adafruit_BusIO/Adafruit_I2CDevice.h:7:7: error:                 constexpr Adafruit_I2CDevice::Adafruit_I2CDevice(const Adafruit_I2CDevice&)

C:\Users\...\Arduino\libraries\Adafruit_BusIO/Adafruit_I2CDevice.h:9:3: error:                 Adafruit_I2CDevice::Adafruit_I2CDevice(uint8_t, int*)

   Adafruit_I2CDevice(uint8_t addr, TwoWire *theWire = &Wire);

   ^~~~~~~~~~~~~~~~~~

C:\Users\...\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp: In member function 'bool Adafruit_I2CDevice::begin(bool)':

C:\Users\...\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp:30:3: error: '_wire' was not declared in this scope

   _wire->begin();

   ^~~~~

C:\Users\...\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp:30:3: note: suggested alternative: 'Wire'

   _wire->begin();

   ^~~~~

   Wire

C:\Users\...\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp: In member function 'bool Adafruit_I2CDevice::detected()':

C:\Users\...\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp:51:3: error: '_wire' was not declared in this scope

   _wire->beginTransmission(_addr);

   ^~~~~

C:\Users\...\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp:51:3: note: suggested alternative: 'Wire'

   _wire->beginTransmission(_addr);

   ^~~~~

   Wire

C:\Users\...\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp: In member function 'bool Adafruit_I2CDevice::write(const uint8_t*, size_t, bool, const uint8_t*, size_t)':

C:\Users\...\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp:90:3: error: '_wire' was not declared in this scope

   _wire->beginTransmission(_addr);

   ^~~~~

C:\Users\...\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp:90:3: note: suggested alternative: 'Wire'

   _wire->beginTransmission(_addr);

   ^~~~~

   Wire

C:\Users\...\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp: In member function 'bool Adafruit_I2CDevice::_read(uint8_t*, size_t, bool)':

C:\Users\...\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp:176:17: error: '_wire' was not declared in this scope

   size_t recv = _wire->requestFrom((uint8_t)_addr, (uint8_t)len, (uint8_t)stop);

                 ^~~~~

C:\Users\...\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp:176:17: note: suggested alternative: 'Wire'

   size_t recv = _wire->requestFrom((uint8_t)_addr, (uint8_t)len, (uint8_t)stop);

                 ^~~~~

                 Wire

C:\Users\...\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp: In member function 'bool Adafruit_I2CDevice::setSpeed(uint32_t)':

C:\Users\...\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp:246:3: error: '_wire' was not declared in this scope

   _wire->setClock(desiredclk);

   ^~~~~

C:\Users\...\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp:246:3: note: suggested alternative: 'Wire'

   _wire->setClock(desiredclk);

   ^~~~~

   Wire

exit status 1

Error compiling for board Arduino MKRZERO.



This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

/**************************************************************************
 This is an example for our Monochrome OLEDs based on SSD1306 drivers

 Pick one up today in the adafruit shop!
 ------> http://www.adafruit.com/category/63_98

 This example is for a 128x32 pixel display using I2C to communicate
 3 pins are required to interface (two I2C and one reset).

 Adafruit invests time and resources providing this open
 source code, please support Adafruit and open-source
 hardware by purchasing products from Adafruit!

 Written by Limor Fried/Ladyada for Adafruit Industries,
 with contributions from the open source community.
 BSD license, check license.txt for more information
 All text above, and the splash screen below must be
 included in any redistribution.
 **************************************************************************/

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
// The pins for I2C are defined by the Wire-library. 
// On an arduino UNO:       A4(SDA), A5(SCL)
// On an arduino MEGA 2560: 20(SDA), 21(SCL)
// On an arduino LEONARDO:   2(SDA),  3(SCL), ...
#define OLED_RESET     4 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

#define NUMFLAKES     10 // Number of snowflakes in the animation example

#define LOGO_HEIGHT   16
#define LOGO_WIDTH    16
static const unsigned char PROGMEM logo_bmp[] =
{ 0b00000000, 0b11000000,
  0b00000001, 0b11000000,
  0b00000001, 0b11000000,
  0b00000011, 0b11100000,
  0b11110011, 0b11100000,
  0b11111110, 0b11111000,
  0b01111110, 0b11111111,
  0b00110011, 0b10011111,
  0b00011111, 0b11111100,
  0b00001101, 0b01110000,
  0b00011011, 0b10100000,
  0b00111111, 0b11100000,
  0b00111111, 0b11110000,
  0b01111100, 0b11110000,
  0b01110000, 0b01110000,
  0b00000000, 0b00110000 };

void setup() {
  Serial.begin(9600);

  // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
  if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;); // Don't proceed, loop forever
  }

  // Show initial display buffer contents on the screen --
  // the library initializes this with an Adafruit splash screen.
  display.display();
  delay(2000); // Pause for 2 seconds

  // Clear the buffer
  display.clearDisplay();

  // Draw a single pixel in white
  display.drawPixel(10, 10, SSD1306_WHITE);

  // Show the display buffer on the screen. You MUST call display() after
  // drawing commands to make them visible on screen!
  display.display();
  delay(2000);
  // display.display() is NOT necessary after every single drawing command,
  // unless that's what you want...rather, you can batch up a bunch of
  // drawing operations and then update the screen all at once by calling
  // display.display(). These examples demonstrate both approaches...

  testdrawline();      // Draw many lines

  testdrawrect();      // Draw rectangles (outlines)

  testfillrect();      // Draw rectangles (filled)

  testdrawcircle();    // Draw circles (outlines)

  testfillcircle();    // Draw circles (filled)

  testdrawroundrect(); // Draw rounded rectangles (outlines)

  testfillroundrect(); // Draw rounded rectangles (filled)

  testdrawtriangle();  // Draw triangles (outlines)

  testfilltriangle();  // Draw triangles (filled)

  testdrawchar();      // Draw characters of the default font

  testdrawstyles();    // Draw 'stylized' characters

  testscrolltext();    // Draw scrolling text

  testdrawbitmap();    // Draw a small bitmap image

  // Invert and restore display, pausing in-between
  display.invertDisplay(true);
  delay(1000);
  display.invertDisplay(false);
  delay(1000);

  testanimate(logo_bmp, LOGO_WIDTH, LOGO_HEIGHT); // Animate bitmaps
}

These errors are saying that header/include files can not be found. Be sure to SKETCH >> INCLUDE LIBRARY (or maybe use Library Manager to download all the *.h files you have in the top of your sketch).

thanks
deleted the old one
dowloaded again
now is working

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.