0

I'm trying to stack up Arduino UNO, Ethernet Shield and Waveshare 2.8" TFT Shield. Since I'm new to this I'm mostly doing basic stuff.

I successfully manage to get ethernet shield and TFT shield to work individually. Then since TFT shield will not be able to use the ICSP interface I connected the jumpers as it says on wiki.

Hardware configuration

  • When using the Arduino board with ICSP interface, the jumpers SB1, SB2 and SB3 on the LCD module should be kept open.
  • When using the Arduino board without ICSP interface, the jumpers SB1, SB2 and SB3 on the module should be connected with a 0R resistor, respectively.

After this I put everything together and try to get them working with the below code but for some reason I don't know, Ethernet shield stopped working. I get the error Ethernet shield was not found. Sorry, can't run without hardware. :(. Even though the error, my TFT screen lights up and runs demo. Probably I'm missing something simple. I'll appreciate any help or guidance.

#include <stdint.h>
#include <LCD.h>
#include <SPI.h>
#include <Ethernet.h>

IPAddress server(192, 168, 0, 107);
IPAddress ip(192, 168, 0, 177);
IPAddress myDns(192, 168, 0, 1);
IPAddress gateway(192, 168, 0, 1);
EthernetClient client;
byte mac[] = {0x90, 0xA2, 0xDA, 0x00, 0x23, 0x36};

void setup()
{
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  /*--------- TFT Init -------------*/
  SPI.setDataMode(SPI_MODE3);
  SPI.setBitOrder(MSBFIRST);
  SPI.setClockDivider(SPI_CLOCK_DIV4);
  SPI.begin();
  Tft.lcd_init();
  /*--------- TFT Init End -------------*/

  /*--------- Ethernet Setup -------------*/
  Serial.println("Initialize Ethernet with DHCP:");
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    if (Ethernet.hardwareStatus() == EthernetNoHardware) {
      Serial.println("Ethernet shield was not found.  Sorry, can't run without hardware. :(");
    } else if (Ethernet.linkStatus() == LinkOFF) {
      Serial.println("Ethernet cable is not connected.");
    }
    // no point in carrying on, so do nothing forevermore:
    // while (true) {
    //   delay(1);
    // }
  }
  // print your local IP address:
  Serial.print("My IP address: ");
  Serial.println(Ethernet.localIP());
  /*--------- Ethernet Setup End -------------*/

  /*--------- Ethernet Connection Demo Setup -------------*/
  if (client.connect(server, 3000)) {
    Serial.print("connected to ");
    Serial.println(client.remoteIP());
    // Make a HTTP request:
    client.println("GET / HTTP/1.1");
    client.println("Host: localhost");
    client.println("Connection: close");
    client.println();
  } else {
    // if you didn't get a connection to the server:
    Serial.println("connection failed");
  }
  beginMicros = micros();
  /*--------- Ethernet Connection Demo Setup End -------------*/
}

void loop()
{
  /*--------- TFT Demo -------------*/
  Tft.lcd_clear_screen(WHITE);
  for (int x = 1; x <= 240; x++) {
    for (int y = 1; y <= 320; y++) {
      Tft.lcd_draw_rect(x, y, 1, 1, RED);
      delay(1);
    }
  }
  /*--------- TFT Demo End -------------*/

  /*--------- Ethernet Check-Up ---------*/
  switch (Ethernet.maintain()) {
    case 1:
      //renewed fail
      Serial.println("Error: renewed fail");
      break;

    case 2:
      //renewed success
      Serial.println("Renewed success");
      //print your local IP address:
      Serial.print("My IP address: ");
      Serial.println(Ethernet.localIP());
      break;

    case 3:
      //rebind fail
      Serial.println("Error: rebind fail");
      break;

    case 4:
      //rebind success
      Serial.println("Rebind success");
      //print your local IP address:
      Serial.print("My IP address: ");
      Serial.println(Ethernet.localIP());
      break;

    default:
      //nothing happened
      break;
  }
  /*--------- Ethernet Check-Up End ---------*/

  /*--------- Ethernet Demo ---------*/
  int len = client.available();
  if (len > 0) {
    byte buffer[80];
    if (len > 80) len = 80;
    client.read(buffer, len);
    if (printWebData) {
      Serial.write(buffer, len); // show in the serial monitor (slows some boards)
    }
    byteCount = byteCount + len;
  }

  // if the server's disconnected, stop the client:
  if (!client.connected()) {
    endMicros = micros();
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();
    Serial.print("Received ");
    Serial.print(byteCount);
    Serial.print(" bytes in ");
    float seconds = (float)(endMicros - beginMicros) / 1000000.0;
    Serial.print(seconds, 4);
    float rate = (float)byteCount / seconds / 1000.0;
    Serial.print(", rate = ");
    Serial.print(rate);
    Serial.print(" kbytes/second");
    Serial.println();

    // do nothing forevermore:
    // while (true) {
    //   delay(1);
    // }
  }
  /*--------- Ethernet Demo End ---------*/
}
2

From examining the schematics of the Ethernet shield as well as the TFT shield, it looks like the Chip Select (CS) pin of the Ethernet shield uses the same pin (Arduino pin D4) as the Interrupt pin of the Touch Panel on your TFT shield (TP_IRQ) in the schematic.

I don’t think you can solve this without modifying any hardware. Either the TFT shield or the Ethernet shield should be modified to use a different pin, and these modifications should be reflected in the underlying library.

My guess is the Ethernet shield would be easiest to modify as its PCB can be reached from two sides. You could also cut the D4 pin from the TFT shield and connect its PCB trace to an unused digital pin via a short wire.

| improve this answer | |
1

The error message is from the ethernet library. As I do not have the sufficient hardware to test this indicates a pin conflict. So the ethernet shield v1 uses/needs one or more pins the LCD shield is using.
How to find out dig into the circuit documenation and look at the used pins.
Be aware that a lot of tuts/infos on the net are about ethernet shield v2 which is hardware differnt from v1.

  • Circuit schematics for Waveshare and Ethernet shield v1
  • Check also for shorts between USB (Arduino) / Ethernet plug and the above shields, I isolate them normaly with a piece of isolation tape (to be safe than sorry).

EDIT
Ethernet shield: Arduino communicates with both the W5100 and SD card using the SPI bus (through the ICSP header). This is on digital pins 10, 11, 12, and 13 on the Uno. Pin 10 is used to select the W5100 and pin 4 for the SD card. These pins cannot be used for general I/O

The wave share uses CS=D10, RS=D7, RST=D9 and the SD CS can be defined on eg SD_CS 5 with this library as the waveshare lib is not usable other than basic playing around.
This lib is Adafruit_GFX compatible so a wide variety of programs and other libs work.
So your chance is

  • to remap the SD CS by software if the other pins pose no conflict (you have to test it) or
  • get an other Ethernet connector (not a shield because its more flexible) or
  • remap manually with dupont wires the LCD shield (because it's the top most) and change the according pins in the libs header file.

Do not cut traces or solder around its not worth the effort and you might break things

| improve this answer | |
  • Thank you for your answer. First of all I did isolate the USB like you said when I first fit the shield. Secondly, since I can run the code above separately with no error I assume my code is good for my versions. Let's say there is a pin conflict. Do you have any idea/suggestion on how to fix that? Do you think I can set another pin for them just with code? Ethernet library has Ethernet.init(sspin) function. Does this mean I have to do some soldering? Thanks again. – bennygenel Apr 16 at 10:55
  • See my edit and test the other TFT lib first without ethernet shield – Codebreaker007 Apr 16 at 16:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.