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?
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.
How to choose SDA/SCL pain on due from software. wire.h has two instances of TwoWire i.e. Wire and Wire1.
#define PIN_WIRE_SDA (20u) #define PIN_WIRE_SCL (21u)
#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.