0

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

  • 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) – Code Gorilla May 19 '17 at 7:37
2

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.

0

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, privacy policy and cookie policy

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