Go Down

Topic: Which library to use for SDA1 and SCL1 (second I2C) Arduino Due (Read 9888 times) previous topic - next topic


Dear forum members,

I am trying to find a way to use a second I2C device on my Arduino Due using the SDA1 and SCL1 ports (NOT 20 and 21, the other 2). However, 20 and 21 do seem to work with the wire.h library but SDA1 and SCL1 are not working. I am also not able to find a "Wire1.h" file which should(?) support the secondary I2C ports. Can you help me out?





Someone should know this right, or does nobody use the second I2C on their Due?


Feb 11, 2014, 10:59 pm Last Edit: Feb 11, 2014, 11:03 pm by Graynomad Reason: 1
I don't have any wire1.* files on 1.5, are there supposed to be some?

The second port does rate a small mention in the reference section

Due   20 (SDA), 21 (SCL), SDA1, SCL1

so would assume it is supported but as usual the documentation is woeful.

Rob Gray aka the GRAYnomad www.robgray.com


Hello maksudkan,

Try this with a workable SDA/SCL (first I2C) project.

#include <Wire.h>
extern TwoWire Wire1;

and then, replace all the Wire.xxxx() with Wire1.xxxx()

Here how it looks using example master_reader from

Code: [Select]
#include <Wire.h>
extern TwoWire Wire1;
void setup()
  Wire1.begin();        // join i2c bus (address optional for master)
  Serial.begin(9600);  // start serial for output

void loop()
  Wire1.requestFrom(2, 6);    // request 6 bytes from slave device #2

  while(Wire1.available())    // slave may send less than requested
    char c = Wire1.read(); // receive a byte as character
    Serial.print(c);         // print the character


Remember to use pins 70 (SDA1), 71 (SCL1)


My prior recommendation (reply#3) does not work. I just tested it using two DUEs with the master_writer and slave_receiver sketches.

I made a couple extra tests that work OK.

Test A: Master SDA1/SCL1 writes on Slave SDA/SCL.
(Using Wire1.xxx() in the master code. Using Wire.xxx() in the slave code).

Test B: Master SDA/SCL writes on Slave SDA1/SCL1
(using Wire.xxx() in the master code. Using Wire1.xxx() in the slave code).

So far so good, but maksudcan's problem remains. I can't establish communication between Master and Slave both in SDA1/SCL1.

There is only one Wire library (.h,.cpp) and one class (TwoWire).
The pin definition for Wire1 is defined in Wire (.h,.cpp) and variant (.h,.cpp).
I will try to make more time soon and do more tests.



I've been trying to do the same thing, and have been getting very frustrated.  I'm using two Adafruit LSM303 accelerometers at different places in the system.  Since the slave address is the same for both, I can't have them on the same I2C bus.  I finally gave up and called a friend who's an embedded software ninja, and he had me running in no time.

Basically it's what Palliser said: you don't need any additional libraries, you just substitute "Wire1" for "Wire".

Let me know if you haven't solved your issue yet, and I'll post more details that hopefully will be helpful.



Feb 18, 2014, 03:52 pm Last Edit: Feb 18, 2014, 03:54 pm by Palliser Reason: 1
I just tested the master reader/slave sender example with two DUEs for second I2C (SDA1/SCL1) using 1K pull-up resistors and the communication is OK. Please, verify that. Regards, Palliser.

NOTE: Remember to use wire1.xxx() instead of wire.xxx() for the functions.


Dear Palliser,

I can verify that it works with your first recommendation, however, some devices wont work ond SDA1 and SCL1 and do work on SDA and SCL and vice versa, but I got my devices working:)!.

Thank you very much for your time!




Even I want to interface two I2C sensors with Arduino Due board,but I am unable to read the data from SDA1,SCK1.


Please show us your schematic. Or the schematic for the unspecified thing you've connected to SDA1 and SCK1.

The reason is that there's pullup resistors on the DUE board for the first I2C interface but not the second. You need to have pullups in your circuit.
"The problem is in the code you didn't post."


Lights, music, electronics, Action!

Go Up