Adafruit Wire Library does not work with MKR 1010

I have a simple demo program that writes shapes to a 128x64 OLED based on the SSD1306 .
I also communicates to a one-wire temp sensor who's code I've commented out.
I connected the display to the I2C pins and attempted to verify the program.

I installed the Arduino SAMD Boards (32-bit ARM Cortex-M0+) library and the board is recognized. Also have installed the adafruit Bus IO library.

My program has the following include files:

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
And 
// declare an SSD1306 display object connected to I2C
Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1)

My application works on both an Uno and Mega 2650.

When I compile it I get a bunch of warnings: warning: "LITTLE_ENDIAN" redefined
And some errors:

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

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

C:\Users\jjh\Documents\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp:81:3: error: '_wire' was not declared in this scope
   _wire->beginTransmission(_addr); 

C:\Users\jjh\Documents\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);

plus a few more.

Clearly this thing is not happy with the Adafruit library, but why?
What can be done to fix the problem? Is there an alternative library?
Thanks

Try a different lib:

#define I2C_SLA = 0x078;    // http://forum.arduino.cc/index.php?topic=219419.30
#include <U8glib.h>

// See Notes for URL to full list of constructors supported for library!
// U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE|U8G_I2C_OPT_DEV_0);	              // I2C / TWI 
// U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_DEV_0|U8G_I2C_OPT_NO_ACK|U8G_I2C_OPT_FAST);  // Fast I2C / TWI 
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NO_ACK);	// Display which does not send AC


void draw(void) {
  // graphic commands to redraw the complete screen should be placed here  
  u8g.setFont(u8g_font_unifont);
  u8g.setPrintPos(0, 20); 
  // call procedure from base class, http://arduino.cc/en/Serial/Print
  u8g.print("Hello World!");
}

void setup(void) {
  // flip screen, if required
  // u8g.setRot180();
}

void loop(void) {
  // picture loop
  u8g.firstPage();  
  do {
    draw();
  } while( u8g.nextPage() );
  
  // rebuild the picture after some delay
  delay(500);
}
#define I2C_SLA = 0x078;    // http://forum.arduino.cc/index.php?topic=219419.30
#include <U8glib.h>

// See Notes for URL to full list of constructors supported for library!
// U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE|U8G_I2C_OPT_DEV_0);	              // I2C / TWI 
// U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_DEV_0|U8G_I2C_OPT_NO_ACK|U8G_I2C_OPT_FAST);  // Fast I2C / TWI 
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NO_ACK);	// Display which does not send AC


void draw(void) {
  // graphic commands to redraw the complete screen should be placed here  
  u8g.setFont(u8g_font_unifont);
  u8g.setPrintPos(0, 20); 
  // call procedure from base class, http://arduino.cc/en/Serial/Print
  u8g.print("Hello World!");
}

void setup(void) {
  // flip screen, if required
  // u8g.setRot180();
}

void loop(void) {
  // picture loop
  u8g.firstPage();  
  do {
    draw();
  } while( u8g.nextPage() );
  
  // rebuild the picture after some delay
  delay(500);
}

The notes tab .....

/*
  This sketch on the Mini 386 works with the 4-pin I2C 0x78 address OLED
  Arduino 1.6.1
    Sketch uses 9,950 bytes (34%) of program storage space. Maximum is 28,672 bytes.
    Global variables use 246 bytes (12%) of dynamic memory, leaving 1,802 bytes for local variables. Maximum is 2,048 bytes.
  
  1.8K pull-up resistors to SCL/SDA
  3.3V on ICSP pin #2
  Gnd to Gnd
  A4 SDA
  A5 SCL
  
*/

/*

  PrintTest.pde
  
  How to use the base class "Print"
  
  >>> Before compiling: Please remove comment from the constructor of the 
  >>> connected graphics display (see below).
  
  Universal 8bit Graphics Library, http://code.google.com/p/u8glib/
  OLED: http://forum.arduino.cc/index.php?topic=219419.0
  Copyright (c) 2012, olikraus@gmail.com
  All rights reserved.

  Redistribution and use in source and binary forms, with or without modification, 
  are permitted provided that the following conditions are met:

  * Redistributions of source code must retain the above copyright notice, this list 
    of conditions and the following disclaimer.
    
  * Redistributions in binary form must reproduce the above copyright notice, this 
    list of conditions and the following disclaimer in the documentation and/or other 
    materials provided with the distribution.

  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
  
*/


// devices with all constructor calls is here: http://code.google.com/p/u8glib/wiki/device

adafruit has been very busy doing library re-architecture to support their growing product offerings.

Thank you. I copied & pasted in the example you provided, and installed the u8glib and it failed to compile. I then tried u8glib2 which also failed giving me the error:

C:\Users\jjh\Documents\Arduino\libraries\U8glib\src\clib\u8g_delay.c:57:14: fatal error: delay.h: No such file or directory
 #    include <delay.h>
              ^~~~~~~~~
compilation terminated.
exit status 1
Error compiling for board Arduino MKR WiFi 1010.

Any idea why?

I also realize that the example you provided is duplicated. you repeat the hello world example - not sure why.

I think looked in they Arduino examples and found: Examples -> U8glib -> Full Buffer -> Hello World that worked.

Am really curious why the Adafruit glib doesn't work on the MKR 1010? (and why I couldn't find a reference about not using it with the MKR 1010) and also why your program doesn't work? Are there some helper libraries I that need to be installed?

BTW, the Arduino example file uses the Arduino.h lib. When I added that to your example, it still failed the same way.
J

Well, in my case, I have this library installed,
GLCD - Arduino Reference
and the missing delay.h is in that library: a quick search of my Arduino folder showed it nowhere else.
BUT...
The issue really is that many older libraries do not work correctly with non-AVR hardware; said another way, when code compilation spits out an error message similar to:

C:\Users\jjh\Documents\Arduino\libraries\U8glib\src\clib\u8g_delay.c:57:14: fatal error: delay.h: 

it typically means a file is missing, or the library did not install correctly, or the CPU architecture is incorrect, or a few other rare and strange things.

Anyway ...

I think looked in they Arduino examples and found: Examples -> U8glib -> Full Buffer -> Hello World that worked.

Sounds like the latest U8glib is working. Great news. Even oldfarts at this Arduino game still scratch our heads sometimes :upside_down_face:

Ray

Ahhhh, the missing piece of the puzzel...Yes, adding that made the compiler happy.
Understand about the 'fatal errors'...A number of potential contributors to this issue and my gripe /on soapbox
is the compiler has enough contentual information to make a more meaningful message that could potentially reduce debug time!
\off soapbox

Just a bit bumed that the work I did using the adafruit GL now has to be translated to U8GL....On the plus side, it appears to be a more portable solution + support for a wider number of displays.
Thanks for your help.
J

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