3,5" TFT touch Screen + SD card slot MCU_friend.com... NEW Short Help topic!

Hi everybody!

I know there is few topics related to this matter, but i wanted to start a new one because im starting to loose my hair with my new toy what is not working…
I have readed many hours topics from this forum and even from russian and chinese forums with google translate, so i hope that somebody can help me with this… xD

So i got 3,5" TFT touch Screen ILI9481 + SD card slot (MCU_friend.com) from aliexpress.
ILI9481
For arduino mega2560
Please see the pictures…

First impression was good, the screen is working with =)

UTFT myGLCD(ILI9481,38,39,40,41);

But thats it… Touch screen not working and sd card is not working.

Lets start with sd card. I have tried three different sd card, please see the pictures.
And i have used the win7 basic format and the SDFormatter V4.0 to format the sd card…

I get something with SD.h example cardinfo.
what i use:
const int chipSelect = 53;
pinMode(53, OUTPUT);

Serial monitor says:

“Initializing SD card…
Card type: SD2
Could not find FAT16/FAT32 partition.
Make sure you’ve formatted the card”

With SdFAT library i dont get anything:

Only in serial monitor:

“SD initialization failed.
errorCode: 0x4, errorData: 0x2”

So what are the correct pins and setting for the sd card?
Anybody has a pin map for this shield?

Then the touch screen, it doesnt do nothing,
I have tried all compinations for it also

*I think the right setting should be:

UTouch myTouch(6,5,4,3,2);

So what are the correct pins and setting for touch screen?

An the pin map would be helpfull in future also… =)

Thank you for your support and understanding!!! =)

Moi

Stupid question but are you sure it is a touch screen? I have a similar display from Banggood which is not a touch screen. It is said so in the Banggood wep site. Look for instance

There are misleading information whether a display is touch screen or not.
This is not a touch screen
http://www.banggood.com/3_2-Inch-320-X-480-TFT-LCD-Display-Module-Support-Arduino-Mega2560-p-963574.html

Yes, it has a Touch controller.
Yes, it should work 100% fine. e.g. with UTouch library

The pcb says ILI9481. So it probably does contain an ILI9481. It might be ILI9486 or ILI9488.
The TFT should work 100%.

If it is an ILI9481, Rowboteer's new HX8357 / ILI9481 library will give you a far better performance than UTFT.
There is support for this and the other controllers with UTFT library.

No, the SD card will NEVER work (reliably).
The series resistors in the SD circuit are the wrong value.
It should really have a proper level-shifter chip for the SD.

David.

p.s. I will give you a medal if you get the SD working in a practical sketch.

Thanx for the reply....

Ok, i will give up with SD card, and buy another shield for it...

Any suggestions what is a good one?

But the Touch screen, any hints to get it working?

Is the rigth parameters?

UTouch myTouch(6,5,4,3,2);

Anything else that i have to config?

Thanx!

I am not at a PC.

Just try the UTouch examples with UTFT display with constructor for ILI9481.
The UTouch example constructor is already set for your shield wiring.

I presume that you have already discovered whether your display has got an ILI9481.

Have you tried the HX8357 library yet? #define MIRROR for the ILI9481.

David.

Yep, i assume that it can be ILI9481 chip because display is working with:

UTFT myGLCD(ILI9481,38,39,40,41);

But the touch screen wont react or dont give any feed back with Utouch examples:

I have tried all compinations what were listed in examples for parameters:

  • i think rigth parameters (or pins) should be:

UTouch myTouch(6,5,4,3,2);

Anything else that i have to config or reconize?

Thanx!

Well, I have a similar shield that is marked (ili9488). It actually contains an ILI9486.

I just tried the UTouch_ButtonTest example.
My only edit was:

UTFT    myGLCD(ILI9486,38,39,40,41);

It "worked" but since the examples are all written for 240x320 screens, nothing lines up very well.

Have you tried the HX8357 library yet?

David.

Hi!

Just tried out the HX8357 library, very nice, more fonts and other options to use...
Thank you for that...

But back to the touch screen, no help yet
With:

UTFT myGLCD(ILI9486,38,39,40,41);

I get only a white screen...
And with:

UTFT myGLCD(ILI9481,38,39,40,41);

UTouch myTouch( 6, 5, 4, 3, 2);

I get everything to the screen but touch functions are not workign at all... No react or feed back from the screen... nothing happens when i slide or touch with my fingers on the screen...

So any more ideas?
Help Please...

Obviously you have ILI9481 and I have ILI9486.

You have verified that you have an ILI9481 and it is working ok.

I have a similar mcufriend MEGA2560 shield. And the Touch works fine on my shield.

The pcb traces are slightly different. But it seems to be a set of resistor packs instead of proper level-shifter chips.

Your photo shows a regular XP2046 or ADS7843 Touch Controller. These should work fine with the UTouch library.

David.

Thanx David!
Maybe i have to order new display shield... ? :frowning:

All ideas for the touch pad are welcome??
:slight_smile:

I got a new problem now with the TFT_HX8357.h

Screen is flashing / refreshing with the delay time…

Any hints to fix it?

The code i use:

#include <DHT.h>
#include <TFT_HX8357.h> // Hardware-specific library
#include "Free_Fonts.h" // Include the header file attached to this sketch


#define DHTPIN 13               //pin for DHT22
#define DHTTYPE DHT22   // DHT 22  (AM2302)

#define SensorPin A9            
#define Offset 0.40            //deviation compensate
#define samplingInterval 20
#define printInterval 800
#define ArrayLenth  40    //times of collection
int pArray[ArrayLenth];   
int pArrayIndex=0;    



DHT dht(DHTPIN, DHTTYPE);



TFT_HX8357 tft = TFT_HX8357();       // Invoke custom library

unsigned long drawTime = 0;


void setup()
{

  
  Serial.begin(9600);
  
  tft.begin();
  tft.setRotation(1);
  
  dht.begin();

  analogReference(INTERNAL1V1);
  
}

void loop() {

  pLoop();
  dthLoop();
  displayLoop();

}

void displayLoop()
{
  
  int xpos =  0;
  int ypos = 40;  
  
  tft.setTextColor(TFT_WHITE, TFT_BLACK);
  
    tft.setFreeFont(FSB18);
   tft.fillScreen(TFT_BLACK);

   
tft.drawString("VEDEN LAMPOTILA", 1, 90, GFXFF);
tft.drawString("ILMAN LAMPOTILA", 1, 150, GFXFF);
tft.drawString("C", 420, 150, GFXFF);
tft.drawString("ILMAN KOSTEUS", 1, 230, GFXFF);
tft.drawString("%", 420, 230, GFXFF);
tft.drawString(" ARVO", 1, 10, GFXFF);

}

void dthLoop()
{
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  
  
    tft.setFreeFont(FSB18);
   
 
tft.drawFloat(t, 1, 370, 150, GFXFF);
tft.drawFloat(h, 1, 370, 230, GFXFF);
  
  delay (5000);

}


 void phLoop ()
{
  static unsigned long samplingTime = millis();
  static unsigned long printTime = millis();
  static float pHValue,voltage;
  if(millis()-samplingTime > samplingInterval)
  {
      pArray[pHArrayIndex++]=analogRead(SensorPin);
      if(pArrayIndex==ArrayLenth)pHArrayIndex=0;
      voltage = avergearray(pHArray, ArrayLenth)*5.0/1024;
      pValue = 3.50*voltage+Offset;
      samplingTime=millis();
  }
  if(millis() - printTime > printInterval)   //Every 800 milliseconds, print a numerical, convert the state of the LED indicator
  {
    Serial.print("Voltage:");
        Serial.print(voltage,2);
        Serial.print("    pH value: ");
    Serial.println(pValue,2);
  }
  {
    
 tft.setFreeFont(FSB18);

  tft.drawFloat(pValue, 1, 300, 10, GFXFF);
        printTime=millis();
  }
}
double avergearray(int* arr, int number){
  int i;
  int max,min;
  double avg;
  long amount=0;
  if(number<=0){
    Serial.println("Error number for the array to avraging!/n");
    return 0;
  }
  if(number<5){   //less than 5, calculated directly statistics
    for(i=0;i<number;i++){
      amount+=arr[i];
    }
    avg = amount/number;
    return avg;
  }else{
    if(arr[0]<arr[1]){
      min = arr[0];max=arr[1];
    }
    else{
      min=arr[1];max=arr[0];
    }
    for(i=2;i<number;i++){
      if(arr[i]<min){
        amount+=min;        //arr<min
        min=arr[i];
      }else {
        if(arr[i]>max){
          amount+=max;    //arr>max
          max=arr[i];
        }else{
          amount+=arr[i]; //min<=arr<=max
        }
      }//if
    }//for
    avg = (double)amount/(number-2);
  }//if
  return avg;

}
  
 

  }

Hi!
SD card will work only without the resistor assembly (rp4).