Stacking Arduino Shields
Just as desktop computers have «expansion slots» into which you can add expansion cards for video, sound, networking, and many other things, Arduino boards have «headers» on top where you can fit «shields» to add more functionality. The big difference, however, is that computer expansion slots are finite and independent: if your computer has 6 slots, you can put in 6 cards. And because (with some exceptions) each card is totally independent, it doesn’t matter what you use. It could be 6 video cards, or 1 video card and 5 network cards, or whatever. The computer sees each card in isolation and they don’t conflict with each other.
With Arduino shields it’s not so clear-cut. There is no specific number of «slots», and shields can be stacked on top of each other to combine their features. Most of the time you’ll only have one shield at a time fitted to your Arduino, but some people really take it to an extreme!
Sometimes shields can be stacked together and sometimes they can’t, and it’s not always obvious if they’ll work together or not.
So how do you know if shields are compatible with each other?
Stacking Headers
All shields except the top one will need stacking headers. Many shields are fitted with regular male break-away headers that protrude down from the shield but don’t provide a place on top where another shield can be plugged in. Try to use stacking headers on your shields whenever possible because it makes life much easier for you later if you need to stack them together. You can see the stacking headers clearly on the top shield in the photo above.
Physical Clearance
Even if your shields have stacking headers they may still have parts that are physically high and can foul another shield placed on top. Ethernet shields are notorious for this because the RJ45 jack is so physically high: the stacking headers are shorter than the RJ45 jack, so if you put another shield on top it will probably not sit down flat and the jack may short out tracks on the top shield.
One handy trick to get around that problem is to keep some spare stacking headers around to use as spacers between shields.
Pin Contention
Check the pin assignments of the shields you want to use, and make sure they’re not going to fight over the same pins. Sometimes this can be quite difficult to determine so you may need to go digging through the manufacturer’s schematic to figure out which pins they use. Sharing the GND, 5V, 3V3, RESET, and AREF pins is fine, but if your shields try to use the same data pins you may be in trouble. At Freetronics we have a rule that all shields must have clear markings showing which pins they use so that you don’t have to go looking for datasheets unnecessarily.
If your shields use SPI communications to the Arduino they can all co-exist on the same SPI bus, with the exception of the «SS» («slave select») line (sometimes called «CS», or «chip select») which will need to be configured differently for each board. The «MISO», «MOSI», and «SCLK» pins can all be shared by multiple shields. If you have multiple shields that use SPI and they also use the same pin for SS you may need to modify one of the shields. A typical approach is to cut the track going to SS on one of the shields and use a jumper wire to connect it to an alternative pin, and then modify the software for that shield to use that pin when communicating with the shield.
One little catch is with Ethernet shields based on the Wiznet W5100 chipset, which includes the official Ethernet shield and many third-party shields. The W5100 has a design flaw that causes it to maintain control of the SPI bus even when another device has been selected, making it very tricky to combine the official Ethernet shield with other shields that use SPI. The Freetronics Ethernet Shield uses the W5100 chipset but includes a fix in hardware so it doesn’t have that problem and will happily share the bus with other SPI devices.
Software Interaction
Shields that come with a decent amount of software overhead (such as large driver libraries) can sometimes be a pain to combine if they use up lots of Flash, or SRAM, or have conflicting interrupts or tight timing requirements. This is something that may be difficult for you to determine at face value unless you know the internals of all the libraries involved quite intimately.
Power Requirements
The Arduino only has access to about 500mA via either the USB connection or the external power jack, and some of that is required by the Arduino itself. That leaves a fairly small amount of power available for shields to share, so if you have shields that suck a lot of power you may run into problems when they are combined.
Sometimes it’s not particularly obvious which shields have high power requirements, but common culprits are LCD shields (some backlights can consume 300mA on its own) and wireless shields.
Be particularly careful with any shields that rely on the 3.3V supply, because it has a very low current limit of just 50mA. Shields that require a large amount of current at 3.3V (such as ZigBee shields) should implement their own on-board voltage regulator rather than relying on the 3.3V supply from the Arduino, but many times they don’t. Be super-careful if you have two shields that both use 3.3V from the Arduino.
Radio / Electrical Interference
If your shields use any form of RF communication it’s possible that they can interfere with each other. For example, WiFi shields contain a transceiver to communicate at about 2.4GHz, so if you have another 2.4GHz device jammed right up against it on an adjacent shield you are likely to have problems.
Electrical noise may also be an issue. A worst-case situation would be to combine a shield that needs an extremely clean electrical environment (such as a high-speed, high-resolution analog to digital converter) with a shield that causes lots of electrical noise such as a motor driver shield. Fitting extra power supply decoupling capacitors to each board can often help if electrical noise is a problem.
Feedback?
Got a comment or suggestion about this tutorial? Shoot us an email!
Adafruit Motor Shield V2
Stacking Shields
New Subscription
Please sign in to subscribe to this guide.
You will be redirected back to this guide once you sign in, and can then subscribe to this guide.
One of the cool things about this shield design is that it is possible to stack shields. Every shield you stack can control another 2 steppers or 4 DC motors (or a mix of the two)
You can stack up to 32 shields for a total of 64 steppers or 128 DC motors! Most people will probably just stack two or maybe three but hey, you never know. (PS if you drive 64 steppers from one of these shields send us a photo, OK?)
Note that stacking shields does not increase the servo connections — those are hard-wired to the Arduino digital 9 & 10 pins. If you need to control a lot of servos, you can use our 16-channel servo shield and stack it with this shield to add a crazy large # of servos.
Stacking shields is very easy. Each shield you want to stack on top of must have stacking headers installed. Check our instructions for how to do so. The top shield does not have to have stacking headers unless you eventually want to put something on top of it.
The only thing to watch for when stacking shields is every shield must have a unique I2C address. The default address is 0x60. You can adjust the address of the shields to range from 0x60 to 0x7F for a total of 32 unique addresses.
Each board in the chain must be assigned a unique address. This is done with the address jumpers on the lower edge of the board. The I2C base address for each board is 0x60. The binary address that you program with the address jumpers is added to the base I2C address.
To program the address offset, use a drop of solder to bridge the corresponding address jumper for each binary ‘1’ in the address.
The right-most jumper is address bit #0, then to the left of that is address bit #1, etc up to address bit #4
Board 0: Address = 0x60 Offset = binary 0000 (no jumpers required)
Board 1: Address = 0x61 Offset = binary 0001 (bridge A0 as in the photo above)
Board 2: Address = 0x62 Offset = binary 0010 (bridge A1, to the left of A0)
Board 3: Address = 0x63 Offset = binary 0011 (bridge A0 & A1, two rightmost jumpers)
Board 4: Address = 0x64 Offset = binary 0100 (bridge A2, middle jumper)
Adafruit_MotorShield AFMSbot(0x61); // Rightmost jumper closed
Adafruit_MotorShield AFMStop(0x60); // Default address, no jumpers
One motor shield is going to be called AFMSbot (bottom shield, so we remember) and one is AFMStop (top shield) so we can keep them apart. When you create the shield object, specify the address you set for it above.
Then we can request the motors connected to each one
// On the top shield, connect two steppers, each with 200 steps
Adafruit_StepperMotor *myStepper2 = AFMStop.getStepper(200, 1);
Adafruit_StepperMotor *myStepper3 = AFMStop.getStepper(200, 2);
// On the bottom shield connect a stepper to port M3/M4 with 200 steps
Adafruit_StepperMotor *myStepper1 = AFMSbot.getStepper(200, 2);
// And a DC Motor to port M1
Adafruit_DCMotor *myMotor1 = AFMSbot.getMotor(1);
You can request a stepper or DC motor from any port, just be sure to use the right AFMS controller object when you call getMotor or getStepper!
Then, both shields must have begin called, before you use the motors connected
AFMSbot.begin(); // Start the bottom shield
AFMStop.begin(); // Start the top shield
This guide was first published on Jul 09, 2013. It was last updated on Jul 09, 2013.
This page (Stacking Shields) was last updated on Oct 06, 2022.
Can I Stack these two Arduino Shields?
I am using an Arduino uno currently with the Si4735. I can not currently get the audio from this shield to the Arduino or other sources without using the 1/8 jack. To fix this I am thinking about adding another shield with the functionality I need that has an audio in and audio out. I need the ability to play audio from an SD card or some other source. For example this shield: Audio Shield. I known that a lot of the same pins are used, but do I need to use all of the pins from the Audio Shield? Thanks for any help.
tl;dr: Is there any way to stack these two shields?
2 Answers 2
Yes, yes you can. And the beauty is that I can tell without even looking at the Si4735 shield you are using.
How is this possible you ask? The only pins that the AudioShield use are the SPI lines (MOSI,MISO,CLK), a SPI chip select line, and an analog pin for reading the potentiometer. Obviously, the A3 analog pin for the potentiometer can be moved around and put on any other analog pin. The chip select is just an active low digital signal used to determine which SPI device should currently be using the data on the SPI lines (the SPI protocol was designed for a shared bus).
So all in all what that means is for the AudioShield, all of the pins it uses were either designed to be shared, or are not really pin specific and through some super-simple hacks can be moved around. The link you provided actually explains how to move the chip select signal that I talked about to a different pin and the potentiometer hack is basically the same but you have to move it to an analog pin. Of course any code samples you use will have to be adjusted for the new pins you use.
For more information on the arduino pins see here.
For more information on sharing the SPI bus between two devices see here.
Arduino shield stacking
I have an Arduino GSM Shield mounted on an Arduino Uno. Can I stack this GPS shield above Arduino GSM shield? Will there be any pin configuration problem?
In GSM Shield hardware pin’s configuraton are as below:
If there is any problem, how can it be solved? I would be happy if there are any alternatives for the GPS shield.
Addendum
The schematic of the Arduino GSM shield:
The schematic of the SparkFun GPS shield:
3 Answers 3
Photo by John Boxall
Which pins do they use?
To determine if two shields are compatible, you have to read the specifications of both shields.
The best source for this information is the data sheets supplied with the shields. However there is also this Shield List
Can you reassign pins?
Some shields provide a means to alter which pins are used for communications. This can take the form of a switch or a jumper — either pull-off or solder-bridge type. (the GPS shield in the question has jumpers).
Where the shields do not support pin-reassignment or provides insufficient flexibility, to work-around incompatibilities you can use an in-between shield designed for the purpose.
You hear it all the time in the Arduino community, “will this shield work with my other shield?.” I think we’ve all been disappointed to find that two of our favorite shields compete for control of a digital pin here or a serial pin there. While there are sometimes some clever workarounds from elegant code modifications to aggressive ‘greenwiring,’ Mayhew Labs may have come up with the simplest solution thus far: The Go-Between Shield.
Are any alternatives for the foo shield
I notice that Arduino.cc now point people to the list referenced above. They used to have their own list.
Product recommendations are off-topic here but, obviously, you can search
Adafruit Motor Shield V2
Overview
New Subscription
Please sign in to subscribe to this guide.
You will be redirected back to this guide once you sign in, and can then subscribe to this guide.
The original Adafruit Motorshield kit is one of our most beloved kits, which is why we decided to make something even better. We have upgraded the shield kit to make the bestest, easiest way to drive DC and Stepper motors. This shield will make quick work of your next robotics project! We kept the ability to drive up to 4 DC motors or 2 stepper motors, but added many improvements:
Instead of a L293D darlington driver, we now have the TB6612 MOSFET drivers with 1.2A per channel current capability (you can draw up to 3A peak for approx 20ms at a time). It also has much lower voltage drops across the motor so you get more torque out of your batteries, and there are built-in flyback diodes as well.
Instead of using a latch and the Arduino’s PWM pins, we have a fully-dedicated PWM driver chip onboard. This chip handles all the motor and speed controls over I2C. Only two GPIO pins (SDA & SCL) plus 5v and GND. are required to drive the multiple motors, and since it’s I2C you can also connect any other I2C devices or shields to the same pins. This also makes it drop-in compatible with any Arduino, such as the Uno, Leonardo, Due and Mega R3.
Completely stackable design: 5 address-select pins means up to 32 stackable shields: that’s 64 steppers or 128 DC motors! What on earth could you do with that many steppers? I have no idea but if you come up with something send us a photo because that would be a pretty glorious project.
Lots of other little improvements such as a polarity protection FET on the power pins and a big prototyping area. And the shield is assembled and tested here at Adafruit so all you have to do is solder on straight or stacking headers and the terminal blocks.
Lets check out these specs again:
- 2 connections for 5V ‘hobby’ servos connected to the Arduino’s high-resolution dedicated timer — no jitter!
- 4 H-Bridges: TB6612 chipset provides 1.2A per bridge (3A for brief 20ms peaks) with thermal shutdown protection, internal kickback protection diodes. Can run motors on 4.5VDC to 13.5VDC.
- Up to 4 bi-directional DC motors with individual 8-bit speed selection (so, about 0.5% resolution)
- Up to 2 stepper motors (unipolar or bipolar) with single coil, double coil, interleaved or micro-stepping.
- Motors automatically disabled on power-up
- Big terminal block connectors to easily hook up wires (18-26AWG) and power
- Arduino reset button brought up top
- Polarity protected 2-pin terminal block and jumper to connect external power, for separate logic/motor supplies
- Tested compatible with Arduino UNO, Leonardo, ADK/Mega R3, Diecimila & Duemilanove. Works with Due with 3.3v logic jumper. Works with Mega/ADK R2 and earlier with 2 wire jumpers.
- Download the easy-to-use Arduino software library, check out the examples and you’re ready to go!
- 5v or 3.3v compatible logic levels — jumper configurable.