2

On Arduino Due, there are two pairs of SDA/SCL pins that I can use for I2C. There is SDA0 and SCL0 at, respectively, pins 20 and 21 and another near AREF. How do I choose which one of them I use? I also read that pins 20 and 21 have built-in pull-up resistors, is that true?

1
  • The easiest/quickest way would be to experiment. Attach an I2C device and use I2CScanner to detect it, then repeat with the other pins. As to the pull-up you could use a volt metre to test that (I think) May 19, 2017 at 7:37

2 Answers 2

3

Pins 20 and 21 are the default I2C pins. A lot of libraries assume you use these, and would require some extra work to get working with SDA1/SCL1.

They also have their pullup resistors already present on the board of the Due (see schematic).

So just use pins 20 and 21, unless you have a good reason to use the other.

2

How to choose SDA/SCL pain on due from software. wire.h has two instances of TwoWire i.e. Wire and Wire1.

Wire uses

#define PIN_WIRE_SDA         (20u)
#define PIN_WIRE_SCL         (21u)

and Wire1

#define PIN_WIRE1_SDA        (70u)
#define PIN_WIRE1_SCL        (71u)

observe which instance is used by your library e.g.

#define WIRE Wire1 or #define WIRE Wire

if library is using Wire then its default i2c at pin 20 and 21.

if library is using Wire1 then its i2c at pin 70 and 71 near AREF.

make changes accordingly. if you want to use default i2c use "Wire" instance or if you want to use i2c near AREF use "Wire1".

most important don't forget to modify Wire1.begin() or Wire.begin() accordingly.

as mentioned in earlier comment second i2c (pin 70 and 71 near AREF) doesn't have pullup resistor handle it while using second i2c.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.