user80470: I am using SDA1, SCL1 for my DS3232 with RTClib on Due. It works on a Mega2560 on SDA, SCL.
I ran I2c_test with success after I inserted
#define Wire Wire1
However with ds3231.ino this define doesnot work. Looking at RTClib.cpp it looks like I can pass a parameter to Wire.begin(). I have tried sda1, scl1 and Wire1. They didnot work.
Thanks for the help.

user71575: The unmodified RTCLib DS3231 sample code running on Arduino Due defaults to the Wire I2C connection on pins 20 SDA and 21 SCL.

To enable the same sketch to connect to a device connected to the Wire1 I2C connection on pins 70 SDA1 and 71 SCL1, I changed line 333 of RTClib.h to reference &Wire1 rather than &Wire.


Successful test output from the Wire1 connection is shown.

Update:
OP @Marlin Turbett pointed out that adding #define Wire Wire1 to RTClib.h also works. I agree. The modification of line 333 of RTClib.h which I suggested originally is I think the minimal change to get the desired behaviour. But using substitution to achieve the same change also works. A global change across the whole library may be a bigger hammer than might be desirable.
#define substitution works in single compilation units, so the #define needs to be in the same compilation unit as the text to be overwritten. In this case in the library, not the sketch.
The technique of using #define directives to overwrite which Wire port is referenced in RTClib is used selectively by the library depending on arduino architecture (see RTClib.cpp lines 46-73, below).
#include "RTClib.h"
#if defined(__AVR__) && !defined(TWCR) && defined(USICR)
#include <TinyWireM.h>
#define Wire TinyWireM
#else
#include <Wire.h>
#endif

#ifdef __AVR__
#include <avr/pgmspace.h>
#elif defined(ESP8266)
#include <pgmspace.h>
#elif defined(ARDUINO_ARCH_SAMD)
// nothing special needed
#elif defined(ARDUINO_SAM_DUE)
#define PROGMEM
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
#define Wire Wire1
#endif

#if (ARDUINO >= 100)
#define _I2C_WRITE write ///< Modern I2C write
#define _I2C_READ read   ///< Modern I2C read
#else
#include <WProgram.h>
#define _I2C_WRITE send   ///< Legacy I2C write
#define _I2C_READ receive ///< legacy I2C read
#endif

I don't know why the library code at lines 60 to 64 (for ARDUINO_SAM_DUE) was not effective, and I hope to do some more testing. Maybe others here can shed some light?
Update 2: Noting the link from @Edgar Bonet in the comments to the new example sketch customWire_DS3231onSAMD21.ino in RTClib 1.14.1 which specifically caters for multiple i2c ports. Nice one.

80470: <p>I am using SDA1, SCL1 for my DS3232 with RTClib on Due. It works on a Mega2560 on SDA, SCL.
I ran I2c_test with success after I inserted
#define Wire Wire1
However with ds3231.ino this define doesnot work. Looking at RTClib.cpp it looks like I can pass a parameter to Wire.begin(). I have tried sda1, scl1 and Wire1. They didnot work.
Thanks for the help.</p>
 71575: <p>The unmodified <a href="https://github.com/adafruit/RTClib" rel="nofollow noreferrer">RTCLib</a> DS3231 sample code running on Arduino Due defaults to the <em>Wire</em> I2C connection on pins 20 SDA and 21 SCL.
<a href="https://i.stack.imgur.com/dgjO5.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dgjO5.jpg" alt="Due connection via Wire I2C pins" /></a>
To enable the same sketch to connect to a device connected to the <em>Wire1</em> I2C connection on pins 70 SDA1 and 71 SCL1, I changed line 333 of RTClib.h to reference &amp;Wire1 rather than &amp;Wire.
<a href="https://i.stack.imgur.com/cwngk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cwngk.png" alt="Photo of code snippet in RTCLib.h" /></a>
<a href="https://i.stack.imgur.com/yoXqX.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yoXqX.jpg" alt="Due connection via Wire1 I2C pins" /></a>
Successful test output from the Wire1 connection is shown.
<a href="https://i.stack.imgur.com/5Zphg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5Zphg.png" alt="Serial Monitor Output" /></a></p>
<p><strong>Update:</strong>
OP @Marlin Turbett pointed out that adding <code>#define Wire Wire1</code> to RTClib.h also works. I agree. The modification of line 333 of RTClib.h which I suggested originally is I think the minimal change to get the desired behaviour. But using substitution to achieve the same change also works. A global change across the whole library may be a bigger hammer than might be desirable.</p>
<p>#define substitution works in single compilation units, so the #define needs to be in the same compilation unit as the text to be overwritten. In this case in the library, not the sketch.</p>
<p>The technique of using #define directives to overwrite which <em>Wire</em> port is referenced in RTClib is used selectively by the library depending on arduino architecture (see RTClib.cpp lines 46-73, below).</p>
<pre><code>#include &quot;RTClib.h&quot;
#if defined(__AVR__) &amp;&amp; !defined(TWCR) &amp;&amp; defined(USICR)
#include &lt;TinyWireM.h&gt;
#define Wire TinyWireM
#else
#include &lt;Wire.h&gt;
#endif

#ifdef __AVR__
#include &lt;avr/pgmspace.h&gt;
#elif defined(ESP8266)
#include &lt;pgmspace.h&gt;
#elif defined(ARDUINO_ARCH_SAMD)
// nothing special needed
#elif defined(ARDUINO_SAM_DUE)
#define PROGMEM
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
#define Wire Wire1
#endif

#if (ARDUINO &gt;= 100)
#define _I2C_WRITE write ///&lt; Modern I2C write
#define _I2C_READ read   ///&lt; Modern I2C read
#else
#include &lt;WProgram.h&gt;
#define _I2C_WRITE send   ///&lt; Legacy I2C write
#define _I2C_READ receive ///&lt; legacy I2C read
#endif
</code></pre>
<p>I don't know why the library code at lines 60 to 64 (for ARDUINO_SAM_DUE) was not effective, and I hope to do some more testing. Maybe others here can shed some light?</p>
<p><strong>Update 2:</strong> Noting the link from @Edgar Bonet in the comments to the new example sketch <code>customWire_DS3231onSAMD21.ino</code> in RTClib 1.14.1 which specifically caters for multiple i2c ports. Nice one.</p>
