SparkFun Forums 

Where electronics enthusiasts find answers.

Everything ARM and LPC
By Sennert
Hello Community,

I've spent several days trying to get a second I2C Bus running on the Sparkfun SAMD21 DEV Board.
Has anybody managed to make sense of the free SERCOMs? And maybe even used it as a second I2C?

As I couldn't find that much about how to do it i was following Lady Ada's Instruction on how to use the SERCOMs on Arduino Zero or their variant.

I tried Several Combinations of Pins (4+3, 11+13) with the SERCOM1 or SERCOM2 etc.
Used an I2C Scanner Sketch and it uploaded without errors.

Unfortunately it stops working after the first printout of "Scanning...". So the Problem probably comes at line
Code: Select all
I hope somebody can point me to my the right address. Do I have to change the variant File?
Code: Select all

 Demonstrates use of the Wire library and how to instatiate another Wire
 Sends data as an I2C/TWI slave device
 Refer to the "Wire Master Reader" example for use with this

 Created 20 Jun 2016
 Arturo Guadalupi <>
 Sandeep Mistry <>

#include <Wire.h>
#include "wiring_private.h"

TwoWire myWire(&sercom1, 11, 13);   // Create the new wire instance assigning it to pin 0 and 1

void setup()
  myWire.begin(2);                // join i2c bus with address #2
  while (!SerialUSB);             // Leonardo: wait for serial monitor
  SerialUSB.println("\nI2C Scanner");
  pinPeripheral(11, PIO_SERCOM);   //Assign SDA function to pin 0
  pinPeripheral(13, PIO_SERCOM);   //Assign SCL function to pin 1

  myWire.onRequest(requestEvent); // register event

void loop()
  byte error, address;
  int nDevices;
  nDevices = 0;
  for(address = 1; address < 127; address++ )
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    error = myWire.endTransmission();
    if (error == 0)
      SerialUSB.print("I2C device found at address 0x");
      if (address<16)
      SerialUSB.println("  !");
    else if (error==4)
      SerialUSB.print("Unknown error at address 0x");
      if (address<16)
  if (nDevices == 0)
    SerialUSB.println("No I2C devices found\n");
  delay(5000);           // wait 5 seconds for next scan

// function that executes whenever data is requested by master
// this function is registered as an event, see setup()
void requestEvent()
  myWire.write("hello "); // respond with message of 6 bytes
                          // as expected by master

// Attach the interrupt handler to the SERCOM
extern "C" {
  void SERCOM1_Handler(void);

  void SERCOM1_Handler(void) {
Thanks in advance ;)
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]