Adafruit Data Logger Shield - Leonardo alternatives for SDA/SCL


I would like to use a Adafruit Data Looging Shield in my Project.

The board I'm using is latest Leonardo. I wonder first why the RTC is not working, then I found on the Adafruit page following:

Do not use Analog pins 4 or 5 with your project in combination with this shield, even on Arduino boards that use different pins for I²C communication (Leonardo, Mega, Due). For compatibility with “classic” (pre-R3) Arduino boards, the shield connects SDA and SCL to Analog pins 4 and 5, respectively; communication and analog readings would mutually interfere. Leonardo users should likewise avoid Digital pins 2 and 3 when using I²C.

I need to use pin 2 & 3 for interrupts and have no alternative with my different sensors.

Unfortunatly you can't see it in their wiring diagram but it seems that D/I 2 & 3 are as well wired?

Is there a possibility to change something to the shield to use SDA and SCL pins beside the AREF pin on the Leonardo or is it a problem inside the Leonardo?

Kind regards Christoph

That logging shield seems to be outdated. It should use the extra I2C pins next to AREF and it should use the ICSP header for the SPI signals.

The Arduino shields that are 'R3' version do have that compatibility and are also for 5V as well as for 3.3V.

This is the Adafruit logging shield : Adafruit Assembled Data Logging shield for Arduino : ID 1141 : $13.95 : Adafruit Industries, Unique & fun DIY electronics and kits
This is the pinmaping for the Leonardo :
This the reference for attachInterrupt : attachInterrupt() - Arduino Reference
This is the Leonardo reference :

Are you using the (slower) SD-on-any-pin library ?

Do you need to use pin 0 and 1 ? Those are interrupts as well. Pin 0 and 1 are used with the Arduino Uno board, but they are free to use for the Leonardo.

Pin 2 and 3 are interrupts and are SDA and SCL. That's the way it is for the Leonardo (with the ATmega32U4 microcontroller). There is nothing you can do about it.

Is it possible to use the PCINT interrupts ? A library is needed for that.

Thanks for answer. I fear for that :wink:

0 and 1 are connected to a Xbee.

I'm not sure if I understand the wiring diagram of the shield correctly. Are A4 and A5 rooted to SDA and SCL pins beside the AREF? Or can I use A4 and A5 with the shield and Leonardo? If not can I mechanically isolate A4 and A5 on the shield?

Never heard PCINT interrupts – just had a quick look. Would that work with A4 and A5 in combination with the shield? Would be the only left free ports :wink:
How would the code look like for PCINT interrupts on A4 and A5?


SDA, SCL, pin A4,A5 and 2,3
The Arduino Uno uses the microcontroller ATmega328P, which has SDA and SCL at pin A4 and A5.
The Leonardo uses the ATmeg32U4, which has SDA and SCL at pin 2 and 3.
That is how those microcontrollers are made, it is not possible to assign the I2C to other pins. They are fixed to certain pins. Many pins have a number of different functions.

That is confusing of course. So Arduino decided to add two new pins 'SDA' and 'SCL' next to AREF. Now every shield can connect to the SDA and SCL without worry. Cool.

However, those new SDA and SCL pins are still connected to the same pins of the microcontroller.
For a Arduino Uno, the new SDA and SCL pins are the same as A4 and A5, they are connected.
For a Leonardo, the new SDA and SCL pins are the same as 2 and 3.

There is a SoftwareWire library (it's in the Library Manager) to create a software I2C bus on any pins. That library is still being tested. No guarantees.

If you use a library for a sensor which uses attachInterrupt(), then it is hard to change that to PCINT. If you made an interrupt in the sketch, you might change it into PCINT.
The reference for SoftwareSerial shows which pins of the Leonardo has PCINT since the SoftwareSerial uses PCINT interrupts : Arduino - SoftwareSerial
They are pin : 8, 9, 10, 11 (and three more pins on the ICSP header)

This is the old PCINT library : GitHub - GreyGnome/PinChangeInt: Pin Change Interrupt library for the Arduino
This is the new PCINT library : GitHub - GreyGnome/EnableInterrupt: New Arduino interrupt library, designed for Arduino Uno/Mega 2560/Leonardo/Due

Important note
Many Arduino users try interrupts, because they want to read buttons and so. For the Arduino, an interrupt for buttons is almost never needed.
When the loop() runs without any delay(), and millis() is used for timing/delay/sequences, there is often no need to use interrupts.

Thanks for that answer that helped a lot.

What is still not clear for me: If I would like to use A4 and A5, do I have to disconnect some circuit path on the shield? Are these connected to SDA SCL pin ?

So I can use PCINT interrupts at PIN 8,9 only? (10,11 are used by shield for SD)

I build a time keeping system for a race contest. I use interrupts to have very accurate timing. The loop is full of other stuff (split times from other devices, judges input etc) .

Luckily this is a prototype only. The main layout will be done with a Mega because I need more inputs :wink:

For the Leonardo with that shield: Yes, disconnect some circuit and yes, pin 8,9 only.
The shield has the RTC connected to A4 and A5. When A4 and A5 of the Leonardo are not used, you can solder two wires (2 to A4 and 3 to A5). However, when you already use A4 and A5, you have to disconnected the RTC on the shield from those pins. That is often done by cutting a trace with a sharp nife.

For info: The trace of A4 and A5 on the shield is very good visible connected to SDA/SCL und top. I disconnected these. But A5 is still connected to a trace at the bottom oh the shield. It's hart to disconnect this. I removed the pins A4 and A5 wich are usually connects thje shield to Leonardo.

Now everything worked fine (beside that if all of my functions are active the Leonardo come to Memory limit. PCINT interrupt worked fine. But because of memory limit I use I/o 8 and 9 as normal switch for testing - with mega I will have plenty of memory) As a data logging device with all I/O connected Leonardo becomes to it's Limit. Better to use e.g. Mega.