TFT connected = no IP from DHCP. Not connected = Get IP.

Dear readers :slight_smile:

I am tinkering around with the arduino ethernet shield and the TFT LCD.
I would like to get a IP from the DHCP and print it to the little LCD.

In order to see if I could get this to work I started with mashing together the example sketches:

It seems that its going oke, but I got the LCD working, and don’t get an IP address. (serial monitor)
When I then take the 5V off the TFT, I do nicely get an IP address assigned…
So I thought lets add the TFT back, but then it just got stuck again.

I noticed that if I add the SD card into the screen it seems to totally skip even trying to get an IP and just says:
My ip is
If I take the card out and try again it just seems to wait for ever.
Could anyone pleeeaaase tell me where I’m going wrong? :stuck_out_tongue:

#include <TFT.h>  // Arduino LCD library
#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {0x90, 0xA2, 0xDA, 0x0F, 0x47, 0x4F};

EthernetClient client;
// pin definition for the Uno
#define cs   6
#define dc   5
#define rst  2

// create an instance of the library
TFT TFTscreen = TFT(cs, dc, rst);

// char array to print to the screen
char sensorPrintout[4];

void setup() {
  Serial.println("Disable TFT SPI");
  // disable the TFT SPI
  pinMode(6, OUTPUT);

  // start the Ethernet connection:
  // print your local IP address:
  Serial.print("My IP address: ");
  for (byte thisByte = 0; thisByte < 4; thisByte++) {
    // print the value of each byte of the IP address:
    Serial.print(Ethernet.localIP()[thisByte], DEC);
  Serial.println("Enabling TFT SPI");

  // Put this line at the beginning of every sketch that uses the GLCD:
  // clear the screen with a black background
  TFTscreen.background(0, 0, 0);

  // write the static text to the screen
  // set the font color to white
  TFTscreen.stroke(255, 255, 255);
  // set the font size
  // write the text to the top left corner of the screen
  TFTscreen.text("Sensor Value :\n ", 0, 0);
  // ste the font size very large for the loop

void loop() {
  // Read the value of the sensor on A0
  String sensorVal = String(analogRead(A0));

  // convert the reading to a char array
  sensorVal.toCharArray(sensorPrintout, 4);

  // set the font color
  TFTscreen.stroke(255, 255, 255);
  // print the sensor value
  TFTscreen.text(sensorPrintout, 0, 20);
  // wait for a moment
  // erase the text you just wrote
  TFTscreen.stroke(0, 0, 0);
  TFTscreen.text(sensorPrintout, 0, 20);

I have tried connecting the SD CS to 5V but did not help.
Neither did enabling and disabling the TFT SPI (still in the code)
I hope ya’ll have some idea’s
I’m glad I got this far but now I just can’t tell whats wrong :frowning:


I got it to work after I disconnected the TFT MISO?
No idea why…
I would appreciate it if someone could tell me whats up here xD

I am tinkering around with the arduino ethernet shield and the TFT LCD.

Perhaps a peek at the Arduino product page is in order. Notice that there are LOTS of Arduinos available, with different speeds, number of pins, and amount of memory.

Which one are YOU using?

Geez I just forgot to mention it :p It's an Uno :) Would someone with multiple shield really not know there are multiple models? :p Or where you just a bit frustrated with whatever :p

SmokeySky: I got it to work after I disconnected the TFT MISO? No idea why..... I would appreciate it if someone could tell me whats up here xD

Normally that is caused by one of the device SPI slave selects (TFT or SD) being LOW. The MISO line should be in a hi-Z state if all slave selects are HIGH.

You should also post a link to the TFT screen you are using.

Thank you kindly Tim :)

I am using a in comination with a Arduino Ethernet Shield Rev3

I have the SD CS connected to 5V+. The TFT CS I disable with:

  pinMode(6, OUTPUT);

With both the selectors on high, that of the TFT and that of the SD, the only one left is that of the Ethernet shield?

Maybe it has something to do with the SD card reader in the TFT as the script also reacts differently with or without a card in it. (When MOSI is connected) it gives me a IP without card, just totaly jams with card. Might be something totaly different but eh, better to much then to little info.

Might be something totaly different but eh, better to much then to little info.

Like maybe running out of memory?

Remove the SD card from the TFT device. If you are still having trouble with the ethernet shield, it may be the TFT screen MISO line is not being released and going to a high impedance state. Did you notice my response stated “normally” and “should”. Some SPI devices do not share the SPI bus well.

Try this ethernet SPI test sketch with the TFT connected and all SD cards removed from both devices. If the serial monitor shows, the SPI line is ok. If it shows anything else, the SPI bus is failing for some reason. Check the shield is inserted firmly into the Arduino.

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

byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,2,2);

void setup() {

  // disable SD SPI

  // disable TFT SPI
  pinMode(6, OUTPUT);
  digitalWrite(6, HIGH);
 // Start ethernet
  Serial.print(F("Starting ethernet..."));
  Ethernet.begin(mac, ip);


void loop() {

And it could be you are running out of SRAM like PaulS suggested. The ethernet and SD libraries use a considerable amount of SRAM.

aaaaaawh :( dont they know sharing is caring :S

Your scetch workes fine btw :) came back with: Starting ethernet...

I will just keep the MISO disconnected for now then as the TFT does not need a output anyways. I supose this might effect my ability to load images from the SD card. ASCII art will be what i will use then.

I will look more into how the SPI works and study a bit tonight. maybe I will stumble on a work around. and if not its still good to study :P :D

Thank you both very much for you help! :D

PS: if my sketch works without the MOSI pin connected im good on memory or am I making a false assumption here? I thought so because eventhough the pin aint in, the same things will still be loaded. (the card is empty).

If that sketch works with the MISO line connected, then you don't need to disconnect it. Is it working with the MISO line connected?

deep sigh it seems 2 wires came loose in my backpack (I'm on the move). I tried it again with both connected and now I just get :( My apologies for not double checking. that's sloppy error tracing :S