Hi there,
I'm using 2iC to communicate between an Arduino Nano and Mega 2560 v3.
The communication works great using the wire library as per the instructions here:
However, as part of my project I am putting my Arduino mega to sleep using code and methods used here:
https://playground.arduino.cc/Learning/arduinoSleepCode
The mega goes to sleep with no issues and prior to working with two arduinos linked together and 2iC, I have successfully set up an interrupt on Pin 2 of the Mega. That works fine.
However, I have noticed that pins 20 (SDA) and 21 (SCL) being used for 2iC communication using wire act as an interrupt. Whenever something is sent from the Nano, the mega wakes up every time.
This is not desired as I wish to control the interrupt only on pin 2, and not 20/21.
I have found no way to disable interrupts on 21/20 & 2ic. I can disable interrupts entirely with noInterrupts(); but if I do that then none of the interrupts will work to disable sleep.
I have searched hard but cannot find a way to disable interrupts for the 2iC pins on the mega but not have it mess with 2iC communication when the Mega is in fact awake.
Can anyone shed some light on what I might be able to do here?
I have tried detaching interrupts with:
detachInterrupt(20);
detachInterrupt(21);
and
detachInterrupt(2);
detachInterrupt(3);
(As INT.2 and INT.3 on the mega refer to pin 20 & 21)
but this doesn't change anything. The Mega always wakes up as soon as the Nano transmits 2iC data.
It should also be noted that I tried disabling the Pin 2 interrupt also incase there was some weird conflict there, and even without attaching any interrupts, 2iC still wakes up the Mega.