Help with Arduino Uno Code running on SAMD51 (Adafruit Grand Central M4)

Hi Everyone,

I have been learning on Arduino for a while, and am eventually building a Complex project with alot of sensors and display items, so I switched to a Adafruit M4 Grand Central Board from my Uno.

The problem is, I am having trouble getting code that works flawlessly on the Uno to work on the M4. I spent 3 hours last night trying and searching online to see why U8Glib and Wire.h are not working on the SAMD51 board, and the few answers I found are WAYYYY over my head. Yet I see online people showing SAMD51 / M4 boards running U8Glib, etc. but they fail to explain what they did. Can anyone please help me?

Here is the compiling error I get:

WARNING: library U8glib claims to run on avr, sam architecture(s) and may be incompatible with your current board which runs on samd architecture(s).
C:\Users\Eric\Documents\Arduino\libraries\U8glib\src\clib\u8g_dev_ht1632.c:65:15: error: expected identifier or '(' before numeric constant

  • 65 | #define WIDTH 24*
  • | ^~*
    C:\Users\Eric\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/samd51/include/component/qspi.h:380:14: note: in expansion of macro 'WIDTH'
    380 | uint32_t WIDTH:3; /*!< bit: 0.. 2 Instruction Code, Address, Option Code and Data Width */
  • | ^~~~~*
    Multiple libraries were found for "U8glib.h"
    Used: C:\Users\Eric\Documents\Arduino\libraries\U8glib
    Multiple libraries were found for "Wire.h"
    Used: C:\Users\Eric\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.6.4\libraries\Wire
    exit status 1
    Error compiling for board Adafruit Grand Central M4 (SAMD51).

Below is the test code that works perfect on the Uno and Displays on the OLEDs through the Multiplexer, but won't even compile for the SAMD51:

#include <U8glib.h>

#include <Wire.h>

#define MUX_Address 0x70 // TCA9548A Encoders address

char tmp_string[8];  // Temp string to convert numeric values to string before print to OLED display
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_FAST);  // Fast I2C / TWI

// Initialize I2C buses using TCA9548A I2C Multiplexer
void tcaselect(uint8_t i2c_bus) {
   if (i2c_bus > 7) return;
   Wire.beginTransmission(MUX_Address);
   Wire.write(1 << i2c_bus);
   Wire.endTransmission(); 
}

void setup(){
 DisplayInit(); // Initialize the displays 
}

// Initialize the displays 
void DisplayInit(){
   for (int i = 0; i < 7; i++) {
     tcaselect(i);   // Loop through each connected displays on the I2C buses  
  u8g.firstPage();
  do {
  u8g.begin();  // Initialize display
  } while( u8g.nextPage() );
   }
}

void loop(){
   for (int i = 0; i < 7; i++) {
     tcaselect(i);


   u8g.firstPage();
   do {
    /******** Display Something *********/
    u8g.setFont(u8g_font_ncenB10);
       u8g.drawStr(0, 13, "Connected to:");


       itoa(i, tmp_string, 10);  
       u8g.setFont(u8g_font_ncenB18);
       u8g.drawStr(25, 50, tmp_string);
       /************************************/
   } while( u8g.nextPage() );
   delay(50);
   }
 delay(500);
}

do you read this link? here. Where did you find it is compatible?

Thanks for the link, I had not seen that in my search.

I found people online who said they got it to work, but of course they provided no explanation. The other issue is it says wire.h is not compatible, which I know that should be.

Maybe I'll just need to downgrade to a Arduino Mega? ; (

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