Using SD card, Ethernet AND a TFT screen at the same time [SOLVED]

Greetings;

My pool project is taking shape, and it was time to start logging some data. Or so I thought!

I'm using an Arduino Mega 2560, an Ethernet Shield (with SD card slot) and a Kuman 3.5" TFT Screen (which also has a SD card slot), used as a shield.

I am able to read data from the various sensors, send emails and display the data on the screen.

When I try adding any code for the SD card (card inserted into the Ethernet shield slot), it initializes the SD card, but can't find the Ethernet shield. If I remove the SD card, it obviously can't find it, but the ethernet shield works.

If I remove the TFT Screen shield, it recognizes the SD card and the ethernet shield as well.

I suspect this has something to do with the various chip selects. Some posts say the ethernet CS is on pin 10, others refer to 53 for MEGA. I tried both, no luck.

I also dabbled into trying to use the tft screen's sd card, but didn't get anywhere at all...

There is a post on the forum, where SurferTim has an example working (SD + Ethernet), unfortunately the link appears to be broken.

Attached is the code in ZIP and the data sheet for the tftScreen.

Thanks for your help.

Pump_Room_Server_TIME.zip (10.2 KB)

UserManual-MAR3528.pdf (398 KB)

All the devices, SD Card, TFT display, WiFi..

A) Need their own chip select pins. (and reset if they use it)
B) Must play nice on the bus letting others use it when their chip select pins are low. (Or was it high?)

A sort out the pins
B make sure they are not assuming they are the only one on the bus.

-jim lee

We've seen several SD-readers that doen'nt hi-Z MISO when not selected.
Check the schematics for your cards.

on example: here

OK,

Moving the tft actually off the shield pins actually would help my design, in that I can install it on the front panel and keep the Mega and ethernet shield in the box.

The examples which come with the tft screen address this topic and actually recommend that the data bus D0-D7 be moved to pins 22-29 (double header) on the Mega2560.

I already used a cable harness to move the screen, using the shield-equivalent pin out to make sure it works.

Now, can someone please help me with exactly where I need to change the pin-out definitions to get this thing to run? I can't figure this out.

I'm including the sample sketch and the MCUFRIEND_kbv library. Contrary to what the comments in the sample say, the screen will not work with the standard Adafruit_TFTLCD library. you have to use MCUFRIEND.

MCUFRIEND_kbv.zip (216 KB)

phonecal.zip (3.65 KB)

jimLee:
All the devices, SD Card, TFT display, WiFi..

A) Need their own chip select pins. (and reset if they use it)
B) Must play nice on the bus letting others use it when their chip select pins are low. (Or was it high?)

A sort out the pins
B make sure they are not assuming they are the only one on the bus.

-jim lee

Indeed, the Ethernet shield had its CS (pin4) on the tftScreen's data bus! So I did do some micro surgery on the ethernet shield, severing the trace to the W5100 and soldering a wire, which now goes to pin 53. Both ethernet shield and the screen are still installed as shields. (which means I'm still looking for the solution of relocating the datapins, see previous post)

I still have some weird behaviour, where I have to remove/insert the SD and/or push the reset button in order for the SD card to be recognized... But generally speaking, it works.

Not quite [SOLVED], but close...

Cheers.

Good on ya!

-jim lee

Thanks;

I just ordered a Whitebox.ch tentacle shield, which allows me to add 4 sensors to my system. Downloaded the examples, and lo and behold, it again uses D4-D7 to multiplex the different UART channels.

I DEFINITELY need to relocate the data lines of the TFT to D22-29. If you could help me through this, it would be most appreciated. I'm guessing it's in that MCUFRIEND_kbv library (attached in post#3). But I'm too much of a newbie to figure it out.

While waiting for a solution, I'll plug away on the data logging, since we have a functional SD card now!

Thanks all.