How to use DFRobot Ethernet & LCD keypad shields ?

I have received several questions on my previous post about how I did to use the DFRobot Ethernet shied with the DFRobot LCD display shield. This post will clarify that…

According DFRobot site, the Ethernet Shield use digital pins 2, 10, 11, 12 & 13; it is compatible with the Arduino Ethernet library. While the LCD shield use digital pins 5, 6, 7, 8 & 9 and works with the LCB4Bit_Mod library, a modified version of LCD4bits.

This document says that Ethernet Shield uses the 10, 11, 12 & 13 pins and the LCD shields uses the 4, 5, 6, 7, 8, 9, 10 pins. So the details on which pins are used is inconsistent at best!

Using one shield at a time on an Arduino just works but using them stacked, doesn’t! If you exclude a potential power consumption when the 2 shields are used together, the problem should be somewhere else….

To find the issue, I have actually checked in the source code of the library, which pins are actually used.

// --------- PINS -------------------------------------
//RS, RW and Enable can be set to whatever you like
int RS = 8;
int RW = 11;
int Enable = 9;
//DB should be an unseparated group of pins - because of lazy coding in pushNibble()
int DB[] = {4, 5, 6, 7}; //wire these to DB4~7 on LCD.

The LCD shield use digital pins 4, 5, 6, 7, 8, 9, 11; while the Ethernet shield use 2, 10, 11, 12 & 13. Clearly both shields are trying digital 11, that’s the problem!

To fix, just change LCD4Bit_mod.cpp (on Mac : to use another unused pin :
int RW = 3; // was int RW = 11;

You can now stack both shields, they will both work!

4 thoughts on “How to use DFRobot Ethernet & LCD keypad shields ?

  1. Hi David,
    thanks for your help. My hardware is quite similar to yours, but with some small differences I think.

    My ethernet module (DFRobot) use digital pins 2,10,11,12,13 and my LCD module (DFRobot) use digital pins 4,5,6,7,8,9,10 and analog pin 0 for keypad.

    The common pin, in my case is pin 10. In LCD this pin is used for backlit control (base of transistor Q1). If you disconnect pin 10 the backlit is always set at max light.

    Stacking this two modules was possibile bending out of connector pin 10 of LCD shield.

    Now all works like a charm.
    Thanks again

  2. Right, I forgot to mention Pin 2 but I don’t use the ethernet chip interrupts so in my setup Pin 2 is unused.

    PS: don’t bend pins, just change code, that’s softer 😉

  3. Hi David,
    I agree with you regarding code, but IMHO when you use stackable shields and change pin assignment in code you should rewire connection on the shield because of its fixed position.

    If you use “floating” hardware (not shields) with free wires than it’s easy to choose another pin.

    Do you agree?

  4. Hi David (and n.herd)

    Thanks this was really useful at pointing me in the right direction. I have a DFRobot Ethernet shield, and DFRobot LCD keypad shield that didn’t initially work when stacked. Both boards are wired to use pins 10 and 11.

    In the version of LCD4Bit_mod which I downloaded yesterday, pin 11 is assigned to RW, but if you look further into the body of the code, it always appears in a construct like this:

    if (USING_RW) { pinMode(RW,OUTPUT); }

    and at the top of the file we see:

    int USING_RW = false;

    So pin 11 is not actually conflicting.

    For me, it was pin 10 that was the problem, the way it’s wired on the LCD shield to control the backlight doesn’t allow it to serve its purpose for the Ethernet shield, and so it requires a hardware fix. So (yes I know it’s a sin, but a minor one) I bent pin 10 out on the keypad shield and this solved the problem.

    Maybe there are some different board versions in use?

    Bob Barnes

Comments are closed.