Need help resources on Arduino M0

Good day! I am having difficulties in utilizing the Arduino M0 that I bought in so many areas from I2C LCD Library up to utilizing a simple SD Card Module.

What I want to achieve:

  1. Create an SPI through pins 11, 12, 13 (just like an Uno) --> I followed the tutorial from Adafruit Creating a new SPI | Using ATSAMD21 SERCOM for more SPI, I2C and Serial ports | Adafruit Learning System

  2. Connect an RFID Module (MFRC522), I2C LCD and an SD Card Module

  3. Make a database from the SD Card.

What I have:

  1. An arduino M0, a gravity expansion shield, gravity SD Card Module, I2C LCD 20x4 (all DFRobot products)

Help I need:

  1. So since the Expansion shield I have is an UNO compatible version, the slot for the SD Card is connect Via the Uno SPI pins which are 4,11,12,13. What I did was I followed the Adafruit Tutorial to create a new SPI and the problem starts here. IT DOESN'T WORK. I just want to make a simple modular test and uploaded the CardInfo example from the default SD Library. And the output is "Initialization Failed"

Before I made this topic I made sure to test the SD Card on the default SPI of the Arduino M0 which is found on the ICSP pins. It worked normally.

  1. Are there any other available resources of Libraries for the M0? I kinda feel there is scarcity of information and libraries for this MCU. Or maybe I have bad googling skills.

My possible solution:

  1. Buy an Uno and throw this M0. I might end up in this situation but I'm still hoping that I could make something out of this EXPENSIVE board.

Thank you for your contributions.

Gravity Expansion Shield - Gravity: IO Expansion Shield for Arduino V7.1 - DFRobot
Gravity SD Card Module - Fermion: MicroSD Card Module for Arduino-DFRobot
I2C LCD 20x4 - I2C 20x4(2004) LCD Display for Arduno - DFRobot
Arduino M0 -


Im using an Arduino IDE 1.8.4, and ummm I downloaded the SAMD board of course.

This is the Code I used just to test the SD Card module

#include <SPI.h>
#include <SD.h>
#include “wiring_private.h” // pinPeripheral() function

SPIClass mySPI (&sercom1, 12, 13, 11, SPI_PAD_0_SCK_1, SERCOM_RX_PAD_3);
Sd2Card card;
SdVolume volume;
SdFile root;

// change this to match your SD shield or module;
// Arduino Ethernet shield: pin 4
// Adafruit SD shields and modules: pin 10
// Sparkfun SD shield: pin 8
const int chipSelect = 4;

void setup() {
while (!SerialUSB) {
; // wait for serial port to connect. Needed for native USB port only
// do this first, for Reasons

// Assign pins 11, 12, 13 to SERCOM functionality
pinPeripheral(11, PIO_SERCOM);
pinPeripheral(12, PIO_SERCOM);
pinPeripheral(13, PIO_SERCOM);

SerialUSB.print("\nInitializing SD card…");

// we’ll use the initialization code from the utility libraries
// since we’re just testing if the card is working!
if (!card.init(SPI_HALF_SPEED, chipSelect)) {
SerialUSB.println(“initialization failed. Things to check:”);
SerialUSB.println("* is a card inserted?");
SerialUSB.println("* is your wiring correct?");
SerialUSB.println("* did you change the chipSelect pin to match your shield or module?");
} else {
SerialUSB.println(“Wiring is correct and a card is present.”);

// print the type of card
SerialUSB.print("\nCard type: ");
switch (card.type()) {

// Now we will try to open the ‘volume’/‘partition’ - it should be FAT16 or FAT32
if (!volume.init(card)) {
SerialUSB.println(“Could not find FAT16/FAT32 partition.\nMake sure you’ve formatted the card”);

// print the type and size of the first FAT-type volume
uint32_t volumesize;
SerialUSB.print("\nVolume type is FAT");
SerialUSB.println(volume.fatType(), DEC);

volumesize = volume.blocksPerCluster(); // clusters are collections of blocks
volumesize *= volume.clusterCount(); // we’ll have a lot of clusters
volumesize *= 512; // SD card blocks are always 512 bytes
SerialUSB.print("Volume size (bytes): ");
SerialUSB.print("Volume size (Kbytes): ");
volumesize /= 1024;
SerialUSB.print("Volume size (Mbytes): ");
volumesize /= 1024;

SerialUSB.println("\nFiles found on the card (name, date and size in bytes): ");

// list all files in the card with date and size | LS_DATE | LS_SIZE);


uint8_t i=0;
void loop() {
int a = 1;
//SerialUSB.println(“Initializing SD card…”);
mySPI.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0));