I am trying to use a DS1307 (from Sparkfun, BOB-12708) with an Arduino Leonardo. I have connected the SDA, SCL, GND, and 5V pins from the RTC to the Arduino. However, with a CC3000 WiFi shield on the Arduino, the I2C bus hangs. Specifically, Wire.endtransmission()
hangs, called by rtc.isrunning()
. I have confirmed that it works properly on the same Arduino without the WiFi shield. I am using the ds1307 RTClib example for testing it.
-
Which CC3000 breakout exactly? This may be related to the fact that the CC3000 employs interrupts; they could be interrupting the I2C transaction. Post the code that combines the CC3000 and the RTC.SoreDakeNoKoto– SoreDakeNoKoto2016年04月30日 00:27:17 +00:00Commented Apr 30, 2016 at 0:27
-
It's the CC3000 shield.PlasmaPower– PlasmaPower2016年04月30日 02:58:40 +00:00Commented Apr 30, 2016 at 2:58
-
Adafruit and Sparkfun both produce CC3000 shields, among others. Which one is yours?SoreDakeNoKoto– SoreDakeNoKoto2016年04月30日 03:31:22 +00:00Commented Apr 30, 2016 at 3:31
-
I have the one from Adafruit: adafruit.com/product/1491PlasmaPower– PlasmaPower2016年04月30日 15:05:31 +00:00Commented Apr 30, 2016 at 15:05
1 Answer 1
It could be that the CC3000 interrupts are affecting the Wire library's behaviour since the latter is interrupt-driven itself.
Try disabling the CC3000 IRQ before calling rtc.isrunning()
or any other RTC functions. First #include "ccspi.h"
in your sketch. Then place WlanInterruptDisable()
before any RTClib
function call, and then WlanInterruptEnable()
after the RTC function returns.
Even if this works, it may affect the functionality of the CC3000, since it increases the chances of missed interrupts. You can search for DS1307 libraries that employ SoftwareI2C instead such as this one. They should be better able to recover from the CC3000 interrupts.
-
As I've said in my OP, it doesn't work even with just the RTC example. Would CC3000 interrupts be messing with things even if the library isn't included?PlasmaPower– PlasmaPower2016年04月30日 03:00:24 +00:00Commented Apr 30, 2016 at 3:00
-
No, it wouldnt. Somehow, I thought you meant that you used the examples together with the CC3000 code. How are you powering the CC3000? Directly from the Arduino?SoreDakeNoKoto– SoreDakeNoKoto2016年04月30日 03:31:58 +00:00Commented Apr 30, 2016 at 3:31
-
The CC3000 is a shield, so yes it is directly powered from the Arduino which is powered by USB for testing.PlasmaPower– PlasmaPower2016年04月30日 15:04:35 +00:00Commented Apr 30, 2016 at 15:04
-
Powering the CC3000 via USB can cause unreliable behaviour since USB can only supply so much current. Try connecting the shield to the Arduino with jumper cables and powering the shield separately with a 1A source, while connecting all the GNDs together.SoreDakeNoKoto– SoreDakeNoKoto2016年04月30日 16:31:36 +00:00Commented Apr 30, 2016 at 16:31
-
I'm pretty sure a USB to wall adapter can supply a lot more current, correct? Might that work? I could probably also rig something up if it doesn't.PlasmaPower– PlasmaPower2016年04月30日 22:12:15 +00:00Commented Apr 30, 2016 at 22:12