I2C shield stacking question
Moderators: adafruit_support_bill, adafruit

I2C shield stacking question

by Unwin on Mon Jul 16, 2012 8:01 am

What I'm wondering about is if multiple I2C-based adafruit shields can
work together. I know in theory they should, but as I understand it
that depends on each using a different ID on the bus. I don't see the
ID listed on the product pages for the Data Logger Shield and for the
LCD Shield Kit. Can these two shields be "stacked"?
Unwin
 
Posts: 16
Joined: Tue Apr 05, 2011 11:53 am

Re: I2C shield stacking question

by adafruit_support_bill on Mon Jul 16, 2012 8:03 am

Yes, you can stack these shields.
User avatar
adafruit_support_bill
 
Posts: 29630
Joined: Sat Feb 07, 2009 9:11 am

Re: I2C shield stacking question

by Unwin on Mon Jul 16, 2012 8:07 am

Thank you for the reply! How is the I2C address set? I couldn't find information about it on the product page and I'd like to know the specifics so I can make reasonable decisions in the future about which work together without having to post about it each time. Thank you.
Unwin
 
Posts: 16
Joined: Tue Apr 05, 2011 11:53 am

Re: I2C shield stacking question

by adafruit_support_bill on Mon Jul 16, 2012 8:26 am

The 7-bit i2c address for the DS1307 is fixed at 1101000. The MCP23017 used in the RGB-LCD shield has a base address of 010000. The lower 3 address bits are configurable on the chip - but all are pulled low on the shield.

http://pdfserv.maxim-ic.com/en/ds/DS1307.pdf
http://www.adafruit.com/datasheets/mcp23017.pdf
User avatar
adafruit_support_bill
 
Posts: 29630
Joined: Sat Feb 07, 2009 9:11 am

Re: I2C shield stacking question

by Unwin on Mon Jul 16, 2012 8:44 am

Perfect, thank you!
Unwin
 
Posts: 16
Joined: Tue Apr 05, 2011 11:53 am

Re: I2C shield stacking question

by MrTy on Wed Nov 28, 2012 3:04 pm

I am having the exact same issue and was happy to find this post. I could really use some clarification or a more detailed explanation about stacking these two ic2 shields. The examples for the RGB LCD shield and the DS1307 both work perfectly when run individually but I cannot get them to work together. When compiling I get the following message:

In file included from clockRTC.cpp:8:
C:\~\arduino-1.0.1\libraries\RTClib_Master/RTClib.h:17: error: expected unqualified-id before '/' token
C:\~\arduino-1.0.1\libraries\RTClib_Master/RTClib.h:17: error: expected `)' before '/' toke


I could really use some help. :(
MrTy
 
Posts: 4
Joined: Thu Nov 08, 2012 4:22 pm

Re: I2C shield stacking question

by adafruit_support_bill on Thu Nov 29, 2012 5:52 am

@MrTy - Can you post your sketch?
User avatar
adafruit_support_bill
 
Posts: 29630
Joined: Sat Feb 07, 2009 9:11 am

Re: I2C shield stacking question

by MrTy on Thu Nov 29, 2012 2:09 pm

Code: Select all | TOGGLE FULL SIZE
#include <Time.h>
#include <TimeAlarms.h>
#include <LiquidCrystal.h>
#include <MenuBackend.h>
#include <Wire.h>
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>
#include <RTClib.h>

Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();

void setup(){
 
}

void loop(){
 
}



Even without code, there is still a compiling error.

In file included from clockRTC.cpp:8:
C:\~\arduino-1.0.1\libraries\RTClib_Master/RTClib.h:17: error: expected unqualified-id before '/' token
C:\~\arduino-1.0.1\libraries\RTClib_Master/RTClib.h:17: error: expected `)' before '/' token
C:\~\arduino-1.0.1\libraries\RTClib_Master/RTClib.h:17: error: expected `)' before '/' token
C:\~\arduino-1.0.1\libraries\RTClib_Master/RTClib.h:17: error: expected `)' before '/' token


Also while I have your attention, I'm looking how to adjust the RTC clock DS1307 using buttons on the adafruit RGBLCD shield. I think it should be something like...

Code: Select all | TOGGLE FULL SIZE
if (lcd.readButtons ==  BUTTON_UP){
   RTC.adjust( +1min/-1min):
}


I have been trying to figure this one out for hours
MrTy
 
Posts: 4
Joined: Thu Nov 08, 2012 4:22 pm

Re: I2C shield stacking question

by adafruit_support_bill on Thu Nov 29, 2012 2:29 pm

That's a lot of library includes. You probably don't need them all. I suspect you may have some conflict between Time.h and the RTC library. The RTC lib should have all the time manipulation function you need.

To adjust the time by one minute, get the current time in "unixtime" and add or subtract 60 seconds:

Code: Select all | TOGGLE FULL SIZE
  DateTime now = RTC.now();
  DateTime future (now.unixtime() + 60);
  RTC.adjust(future);
User avatar
adafruit_support_bill
 
Posts: 29630
Joined: Sat Feb 07, 2009 9:11 am