Combining Shields

I'm a part of a senior design project, in which we need to use an Arduino MEGA to process and display information on an LCD screen. We have the screen, and a shield to adapt to the screen connected to the Arduino, but also need to add another shield to access Wi-Fi, and the data to be displayed.

The two shields (Wi-fi, and LCD Screen) both use the same pins. Can you stack two shields and have them each perform their own function correctly? Or does the Arduino only allow for one shield to be used at a time if the pins are already utilized?

Thanks in advance for any insight!

Yes, but you need to know which pins the shields use and which of those are for shared functions (like I2C and SPI), just pass-through, and which have exclusive use by that shield. You also need to know where the shield gets it's power +5 or 3.3 Vdc, or external. and that the sum of the power consumed by the shields does not exceed the capacity of the arduino used.

So,,, yes, but it depends upon the shields.

bmerr24: The two shields (Wi-fi, and LCD Screen) both use the same pins.

They almost certainly don't. The WiFi shield uses the pins required for WiFi, the LCD uses pins required for LCD, and there are other pins that are just going along for the ride. That is the whole idea about shields. Even if some pins are used that are the same, those pins are common for that purpose, e.g. the SPI bus.

It is possible to have some pin conflict, such as chip select, but not that likely with storebought shields, and it is most likely fixable. You can stack several, and power or memory are more likely limitations than mechanical.

Be aware of one nasty aspect though, that has cropped up recently. You can be caught where one shield hogs a type of pin that is not required for its purpose. A case in point is where one type of GSM shield uses pins 2,3 for software serial. On a Uno, these pins are the only ones available for external interrupts, while a swag of other pins could have been used for software serial. One can only hope the career of whoever designed that shield is rather short.

It always helps to know what you are doing. I found mapping the pins on a spreadsheet very useful.

Thanks for the info!

Going to be frank, looking at the schematics for both the LCD and Wi-Fi shield, I’m not sure how to begin sorting through what can be used as common pins between the two. I understand your point, but could you help explain with an example?

I’ve attached schematics for both the Wi-Fi and LCD shield. Would you mind pointing out a pin that shares a common function?

arduino-wifi-shield-schematic.pdf (93.8 KB)

MEGA_Shield_schematic.pdf (18.5 KB)

That WiFi shield schematic is relatively normal and the LCD one can be worked out...

Look on the right side of the WiFi shield schematic. This has all the Arduino headers, labelled with the Arduino pin numbers. It uses pin 4, pin 10 and pin 9. 9 seems to be just a yellow LED, so it doesn't really clash with any other shield's use of that pin. 4 is the chip-select for the SD card. If you have no SD card installed then it won't clash with any other shield either.

This seems like a very small number of pins, until you realize that it's using the ISP header in the middle of the board. That is for the SPI bus, which can be shared on many shields. For most Arduinos, this is identical to pin 11, 12 and 13, so those pins aren't 'free'.

The unusual thing with the LCD is it's actually using the big double-row header across the bottom of the MEGA. But it doesn't label the pins with the Arduino pin numbers. It's using almost every pin there.

CN3 looks like the Arduino 'power' header, where it's connected to both 3.3V and 5V.

CN2 seems to be labelled like it is Arduino pins 0-7. So this shield is using pin 4, although it's not immeidately obvious what it uses it for. TP_DOUT, whatever that is.

On the face of it, these two shields do seem to be compatible except you shouldn't install an SD card in the WiFi shield and the WiFi shield probably doesn't pass through the additional MEGA connector, so you might need some longer pins to make it reach.

I was hoping you weren’t going to ask that, there’s too much risk of adding to the confusion.

Looking at the WiFi schematic, the right hand end is all that is relevant, and the unused pins are the pins of main interest.

  1. The 6-pin ICSP cluster for the SPI bus is employed, meaning the board may be used on Uno or Mega.

  2. There is no demand on 3.3v power

  3. Five of the six analogue pins are vacant, and they may be used as digital

  4. Of pins 0>7, six are vacant

  5. Of pins 8>13, four are vacant

That’s fifteen vacant out of twenty-four and, of those that are used, four can be shared with something else. This is more or less what you would expect, and the un-used pins just pass through for possible employment in the next shield.

I don’t know anything about WiFi shields, but it appears to run on the SPI bus and includes an SD card, which also runs on SPI. The SD uses pin 4 for CS, as is the convention, and I guess the whole thing is pretty normal.

As things are, the LCD shield mainly uses the row at the end, as explained. It appears that it has an on-board SD which uses pin 51 for CS, thereby absolving you from any worry about the pin 4 required by the WiFi’s SD. It looks rather like mine. Be aware that you may have to bridge over a couple of solder pads to us the SD on the LCD shield.

It should fit over the WiFi, and does not need the ICSP cluster. I guess you need to do what I did, and put a set of dummy headers in the 36-pin end row to make up the gap.