Update 2: Noting the link from Bonet in the comments to the new example sketch customWire_DS3231onSAMD21.ino in RTClib 1.14.1 which specifically caters for multiple i2c ports. 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. ) You may change these pins before calling Wire.begin () or Wire1. (Here are the pinout diagrams for Pico and Adafruit Feather. digitalWrite (2, LOW) digitalWrite (3, LOW) Share. The default pins for Wire and Wire1 vary depending on which board you’re using. To disable the internal pull-ups: digitalWrite (A4, LOW) digitalWrite (A5, LOW) or. #define _I2C_READ receive ///< legacy I2C read Note that the internal pull-ups in the AVR pads can be enabled by setting the PORT bits corresponding to the SCL and SDA pins, as explained in the I/O Port section. Let's make a Wire device on SERCOM 1 Since we have to use pads 0 & 1, lets check the mux table: Download File Copy Code Pin Arduino 'Pin' SERCOM SERCOM alt - PA18 D10 SERCOM1.2 SERCOM3.2 PA16 D11 SERCOM1.0 SERCOM3.0 PA19 D12 SERCOM1.3 SERCOM3.3 PA17 D13 SERCOM1.1 SERCOM3. Finally, connect the pins to your Arduino. #define _I2C_WRITE send ///< Legacy I2C write #define pgm_read_byte(addr) (*(const unsigned char *)(addr)) #if defined(_AVR_) & !defined(TWCR) & defined(USICR) 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). In this case in the library, not the sketch. #define substitution works in single compilation units, so the #define needs to be in the same compilation unit as the text to be overwritten. A global change across the whole library may be a bigger hammer than might be desirable. But using substitution to achieve the same change also works. The modification of line 333 of RTClib.h which I suggested originally is I think the minimal change to get the desired behaviour. OP Turbett pointed out that adding #define Wire Wire1 to RTClib.h also works. Successful test output from the Wire1 connection is shown. 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. The unmodified RTCLib DS3231 sample code running on Arduino Due defaults to the Wire I2C connection on pins 20 SDA and 21 SCL.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |