I2C shield stacking question

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
unwin
 
Posts: 16
Joined: Tue Apr 05, 2011 12:53 pm

I2C shield stacking question

Post by unwin »

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"?

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: I2C shield stacking question

Post by adafruit_support_bill »

Yes, you can stack these shields.

User avatar
unwin
 
Posts: 16
Joined: Tue Apr 05, 2011 12:53 pm

Re: I2C shield stacking question

Post by unwin »

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.

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: I2C shield stacking question

Post by adafruit_support_bill »

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
unwin
 
Posts: 16
Joined: Tue Apr 05, 2011 12:53 pm

Re: I2C shield stacking question

Post by unwin »

Perfect, thank you!

MrTy
 
Posts: 4
Joined: Thu Nov 08, 2012 5:22 pm

Re: I2C shield stacking question

Post by MrTy »

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. :(

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: I2C shield stacking question

Post by adafruit_support_bill »

@MrTy - Can you post your sketch?

MrTy
 
Posts: 4
Joined: Thu Nov 08, 2012 5:22 pm

Re: I2C shield stacking question

Post by MrTy »

Code: Select all

#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

if (lcd.readButtons ==  BUTTON_UP){
   RTC.adjust( +1min/-1min):
}
I have been trying to figure this one out for hours

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: I2C shield stacking question

Post by adafruit_support_bill »

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

  DateTime now = RTC.now();
  DateTime future (now.unixtime() + 60);
  RTC.adjust(future);

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”