Arduino Uno with 1.8 TFT Module

I recently bought a 1.8 SPI 128x160 pixel TFT from China. The TFT had a plastic wrap with a Green Tab.

http://www.ebay.de/itm/1-8-Serial-128X160-SPI-TFT-LCD-Module-Display-PCB-Adapter-with-SD-Socket-/201013566537?pt=Bauteile&hash=item2ecd579c49

The picture IMG_20140216_145845.jpg shows the back of the tft display and the pins to connect the display to the arduino uno board. Compared to similar tft displays, this one has pins on two sides. I suppose the side with the larger amount of pins has to be used if the sdcard reader should be used. I assumed that I can use the 8 pins on the other side as I only want to use the tft display. After reading a couple of tutorials I first wired the pins 6 to 8 and afterwards the pins 1 to 5 of the tft display to the arduino uno board using following configuration:

TFT → Arduino Uno
1-RST → Digital 8
2-CS → Digital 10
3-D/C → Digital 9
4-DIN → Digital 11
5-CLK → Digital 13
6-VCC → 5V
7-BL → 5V
8-GND → GND

With this configuration the backlight works properly. However it is not possible to display something else with the Adafruit_GFX and Adafruit_ST7735 library. I initialized the ST7735 Chip using the Greentab flag.

tft.initR(INITR_GREENTAB);

Also within the code I am using following configuration

#define cs   10
#define dc   9
#define rst  8

and

Adafruit_ST7735 tft = Adafruit_ST7735(cs, dc, rst);

Does anybody know what I could do to turn this display into a working display. I am wondering whether I did something wrong or the display is broken due to bad quality.

Thanks a lot for your answers in advance!

Hi

I am currently working with a similar display from China: Google Code Archive - Long-term storage for Google Code Project Hosting.. I can attach the current version of that library to this thead if you are interessted.

There is one little difference: My display does not have any resistor for the LED on the PCB. For that reason i had added a 56 Ohm resistor (see discussion on the refered page). 5V without resistor will destroy the LED.
Without backlight the display is almost dark, but with some strong light from the side and if you look from above on the display, you might still see something.

Oliver

I have that same part as in the picture, and any working example code would be nice.
:slight_smile:

Cheers,
Kari

Hello
I have the same part, also.
I have tried everything.
Need help please!!!!
Very frustrating.

Here is my pin configuration.
TFT>Adruino Uno 3v

Hello
Sorry for the previous post.
I have the same display and have tried everything?
I can get a back-light to flicker with the Adafruit code.
Tried using the fast and slow wiring and the graphicstest_highspeed and graphictest code from the Adafruit website.
Code will compile and load OK so I'm guessing that I have the libraries right?
Not sure about the driver - data sheet says ST7735 - but I don't know how to confirm that I have that installed?
What is the difference between ST7735, ST7735R and ST7735S?
Also, little confused about the colored tab?
Do you just change the comment status in the code to open up your color?

Here is my pin configuration

TFT -> Arduino Uno 3v
1 GND -> GND
2 VCC ->
3 NC ->
4 BL -> 5v
5 NC ->
6 RDT - TFT -> 8
7 RS - TFT -> 9
8 SDA - TFT -> 11
9 SCK - TFT -> 13
10 CS - TFT -> 10
11 CLK - SD Card ->
12 MOSI - SD Card ->
13 MISO - SD Card ->
14 CS - SD Card ->
15 NC ->
16 NC ->

What does NC stand for?
Thank you
msstatz

These terms used are really confusing, there seems to be different ways to tell the same thing.

NC is simply Not Connected.

SCL, SCLK and SCK... ??? It must be horrible day for engineer if there's no way to find a new short for existing terms!
:slight_smile:

Cheers,
Kari

Hello Kari
I'm fairly new at this - its amazing what a day of troubleshooting will teach you.
I just noticed that I made several typos in my previous post.
They are corrected here in red

TFT -> Arduino Uno 3v
1 GND -> GND Ground
2 VCC -> Power supply in - check Wikipedia for origin
3 NC -> Not connected?
4 BL -> 5v Back light power in
5 NC -> Not connected?
6 RST - TFT -> 8 Reset - can be used to reset through software.
7 RS - TFT -> 9 ? I think this is the same as AO, DC and RS/DC. Command/Data Selection?
8 SDA - TFT -> 11 LCD data for SPI?
9 SCK - TFT -> 13 SCLK for TFT clock?
10 CS - TFT -> 10 Chipset selector for LCD?
11 CLK - SD Card -> SPI clock
12 MISO - SD Card -> SPI Master in Slave out
13 MOSI - SD Card -> SPI Master out Slave in
14 CS - SD Card -> Chipset selector for SD card?
15 NC -> Not connected?
16 NC -> Not connected?

Wikipedia has a great article on SPI - Serial Peripheral Interface Bus
But it still doesnt make my TFT work?
Sure could use some help!
I am going to order a unit from Adafruit and get it working then continue troubleshooting this one.
What can I do, myself, about the 'Crap from China' issue?
I bought this TFT because of the price.
It actually cost me quite a bit in the long run.
I also bought two Arduino Nano which are look alikes right down to the screen printing.
Woe is me but never again.

Thanks
msstatz

It seams from some research you need to put 1k resistors on all I/O pins.
See link: Cheap 1.8″ SPI 128×160 TFT Module – Arduino wiring! - Domipheus Labs


Hope this helps :smiley:

The driver for this board is a Samsung S6D02A1 and you need to download it from Git hub GitHub - zigwart/Adafruit_QDTech: 1.8" TFT LCD library for Arduino and QD Tech / Samsung S6D02A1
Using this Arduino software will make it work. Also took me two days to figure out. According to the data page the resistors shown in the previous post is needed.

I'm glad I found this post.
But I had to figure out I needed to update Arduino IDE o 1.0.6 and download GitHub - adafruit/Adafruit-GFX-Library: Adafruit GFX graphics core library, this is the 'core' class that all our other graphics libraries derive from as well :wink:
Thanks!

9 months of struggle with this LCD...
THANK YOU VERY MUCH BALTUSV !
This cheap ebay 128x160 SPI remained white with many libraries such as TFT of ST7735, only this one seems to work.
I wired up 1.2kO resistor as mentioned (no more 1kO availables) and put a 56kO between BL and VCC (also spares me a wire), leaving the 5V jumper open.
Thank you again Sir.

Hello,

I just bought this same TFT, and I simply cannot get it to work. The display refuses operation, kicking and screaming. All I get is a striped screen.

I’ve tried countless different sketches and libraries. Sketches will upload, but that’s where it ends. Stripes galore, every time.

And this is the simple test sketch that I just uploaded and which produces another permutation of these decorative stripes:

#define sclk 13  // Don't change
#define mosi 11  // Don't change
#define cs   9
#define dc   8
#define rst  7  // you can also connect this to the Arduino reset
#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_QDTech.h> // Hardware-specific library
#include <SPI.h>

Adafruit_QDTech tft = Adafruit_QDTech(cs, dc, rst);  // Invoke custom library


void setup() {

 tft.init();
 tft.fillScreen (QDTech_WHITE);
 
}

void loop() {
 tft.println ("Test");

}

I have wasted the better part of two days on this, and I am still not a single step further than I was yesterday.

I have tried all the above steps, I have quintuple checked that all the wires are connected the right way. Nothing works.

It is immensely frustrating, as I have never bought an Arduino related part that was this poorly made or documented.

I was just about to smash the display with a hammer and set the fragments on fire, but I thought maybe you guys have an idea what could be wrong.

The display is likely to have a ST7735 driver fitted so try the Adatfruit library that is compatible with that driver.

There are some settings in the sketch that you need to get right so try the different colour "tab" options.

I have a faster library that you could try on Github. See this thread here.

Well, FIN-ALL-Y!!! :slight_smile:

I really really have to thank you, it's now working perfectly.

I can now finally continue with my actual project that I bought this TFT for... :stuck_out_tongue:

@carguy

Can you confirm that swapping to a ST7735 library has helped.

However the display image in post #13 is not exactly as it should be, for example there are random pixels on two edges of the screen.

I am guessing based on the screen image that you are using my TFT_ST7735 library. In that case you need to edit the User_Setup.h file inside the library folder to change some display parameters and get the displayed image corrected. Inside that file you will find some #defines, edit the file to change the option, for example the default is:

//#define TAB_COLOUR INITB
//#define TAB_COLOUR INITR_GREENTAB
//#define TAB_COLOUR INITR_REDTAB
#define TAB_COLOUR INITR_BLACKTAB
//#define TAB_COLOUR INITR_GREENTAB2

For example, edit it to look like this to select the GREENTAB option:

//#define TAB_COLOUR INITB
#define TAB_COLOUR INITR_GREENTAB
//#define TAB_COLOUR INITR_REDTAB
//#define TAB_COLOUR INITR_BLACKTAB
//#define TAB_COLOUR INITR_GREENTAB2

One of the options should give a correct display. Only one option should be defined, the others should be commented out as in the example above.

Clearly you will need to save the file then recompile and upload the sketch to see the effect of any change in settings (yes, one person did think that editing the file on his computer would magically change the display settings on the Arduino board!)

Post back which option works to help others with the same problem.

bodmer:
@carguy

Can you confirm that swapping to a ST7735 library has helped.

Yes, I can confirm that very strongly. I am now using the library from your link above...

bodmer:
However the display image in post #13 is not exactly as it should be, for example there are random pixels on two edges of the screen.

I am guessing based on the screen image that you are using my TFT_ST7735 library. In that case you need to edit the User_Setup.h file inside the library folder to change some display parameters and get the displayed image corrected. Inside that file you will find some #defines, edit the file to change the option, for example the default is:

//#define TAB_COLOUR INITB

//#define TAB_COLOUR INITR_GREENTAB
//#define TAB_COLOUR INITR_REDTAB
#define TAB_COLOUR INITR_BLACKTAB
//#define TAB_COLOUR INITR_GREENTAB2




For example, edit it to look like this to select the GREENTAB option:



//#define TAB_COLOUR INITB
#define TAB_COLOUR INITR_GREENTAB
//#define TAB_COLOUR INITR_REDTAB
//#define TAB_COLOUR INITR_BLACKTAB
//#define TAB_COLOUR INITR_GREENTAB2




One of the options should give a correct display. Only one option should be defined, the others should be commented out as in the example above.

Yes, I think I had a red tab on the screen protector, I've changed it now and it looks ok.

Out of curiosity - does this TFT display support SDHC cards?

I have not tried SDHC cards in that display myself. You will need to connect up the SDCard pins at the other end of the card plus a new signal for the CS (chip select) line to use talk to the SD card.

Great to hear you have the display working, good luck with your project.

Hello again,

I have been trying to make use of the SD card slot as well, but so far, no luck.

As you suggested, in addition to wiring up the display via the “yellow” connectors, I have wired up the pins on the opposite side of the board to the Arduino… it’s a standalone Arduino on a breadboard that runs at 16 MHz external, if it matters… anyway, here’s my pinout:

SDCard CS - Atmega Pin 9
SDCard MOSI - Atmega Pin 11
SDCARD MISO - Atmega Pin 12
SDCARD CLK - Atmega Pin 13.

I have included this function (it’s from an example sketch taken from the Adafruit ST7735 library) in my sketch to load bitmaps from an SD card, but it only returns “File not found” via the serial monitor.

// Bitmap Drawing Function

#define BUFFPIXEL 20

void bmpDraw(char *filename, uint8_t x, uint8_t y) {

  File     bmpFile;
  int      bmpWidth, bmpHeight;   // W+H in pixels
  uint8_t  bmpDepth;              // Bit depth (currently must be 24)
  uint32_t bmpImageoffset;        // Start of image data in file
  uint32_t rowSize;               // Not always = bmpWidth; may have padding
  uint8_t  sdbuffer[3*BUFFPIXEL]; // pixel buffer (R+G+B per pixel)
  uint8_t  buffidx = sizeof(sdbuffer); // Current position in sdbuffer
  boolean  goodBmp = false;       // Set to true on valid header parse
  boolean  flip    = true;        // BMP is stored bottom-to-top
  int      w, h, row, col;
  uint8_t  r, g, b;
  uint32_t pos = 0, startTime = millis();

  if((x >= tft.width()) || (y >= tft.height())) return;

  Serial.println();
  Serial.print("Loading image '");
  Serial.print(filename);
  Serial.println('\'');

  // Open requested file on SD card
  if ((bmpFile = SD.open(filename)) == NULL) {
    Serial.print("File not found");
    return;
  }

  // Parse BMP header
  if(read16(bmpFile) == 0x4D42) { // BMP signature
    Serial.print("File size: "); Serial.println(read32(bmpFile));
    (void)read32(bmpFile); // Read & ignore creator bytes
    bmpImageoffset = read32(bmpFile); // Start of image data
    Serial.print("Image Offset: "); Serial.println(bmpImageoffset, DEC);
    // Read DIB header
    Serial.print("Header size: "); Serial.println(read32(bmpFile));
    bmpWidth  = read32(bmpFile);
    bmpHeight = read32(bmpFile);
    if(read16(bmpFile) == 1) { // # planes -- must be '1'
      bmpDepth = read16(bmpFile); // bits per pixel
      Serial.print("Bit Depth: "); Serial.println(bmpDepth);
      if((bmpDepth == 24) && (read32(bmpFile) == 0)) { // 0 = uncompressed

        goodBmp = true; // Supported BMP format -- proceed!
        Serial.print("Image size: ");
        Serial.print(bmpWidth);
        Serial.print('x');
        Serial.println(bmpHeight);

        // BMP rows are padded (if needed) to 4-byte boundary
        rowSize = (bmpWidth * 3 + 3) & ~3;

        // If bmpHeight is negative, image is in top-down order.
        // This is not canon but has been observed in the wild.
        if(bmpHeight < 0) {
          bmpHeight = -bmpHeight;
          flip      = false;
        }

        // Crop area to be loaded
        w = bmpWidth;
        h = bmpHeight;
        if((x+w-1) >= tft.width())  w = tft.width()  - x;
        if((y+h-1) >= tft.height()) h = tft.height() - y;

        // Set TFT address window to clipped image bounds
        tft.setAddrWindow(x, y, x+w-1, y+h-1);

        for (row=0; row<h; row++) { // For each scanline...

          // Seek to start of scan line.  It might seem labor-
          // intensive to be doing this on every line, but this
          // method covers a lot of gritty details like cropping
          // and scanline padding.  Also, the seek only takes
          // place if the file position actually needs to change
          // (avoids a lot of cluster math in SD library).
          if(flip) // Bitmap is stored bottom-to-top order (normal BMP)
            pos = bmpImageoffset + (bmpHeight - 1 - row) * rowSize;
          else     // Bitmap is stored top-to-bottom
            pos = bmpImageoffset + row * rowSize;
          if(bmpFile.position() != pos) { // Need seek?
            bmpFile.seek(pos);
            buffidx = sizeof(sdbuffer); // Force buffer reload
          }

          for (col=0; col<w; col++) { // For each pixel...
            // Time to read more pixel data?
            if (buffidx >= sizeof(sdbuffer)) { // Indeed
              bmpFile.read(sdbuffer, sizeof(sdbuffer));
              buffidx = 0; // Set index to beginning
            }

            // Convert pixel from BMP to TFT format, push to display
            b = sdbuffer[buffidx++];
            g = sdbuffer[buffidx++];
            r = sdbuffer[buffidx++];
            tft.pushColor(tft.color565(r,g,b));
          } // end pixel
        } // end scanline
        Serial.print("Loaded in ");
        Serial.print(millis() - startTime);
        Serial.println(" ms");
      } // end goodBmp
    }
  }

  bmpFile.close();
  if(!goodBmp) Serial.println("BMP format not recognized.");
}

// These read 16- and 32-bit types from the SD card file.
// BMP data is stored little-endian, Arduino is little-endian too.
// May need to reverse subscript order if porting elsewhere.

uint16_t read16(File f) {
  uint16_t result;
  ((uint8_t *)&result)[0] = f.read(); // LSB
  ((uint8_t *)&result)[1] = f.read(); // MSB
  return result;
}

uint32_t read32(File f) {
  uint32_t result;
  ((uint8_t *)&result)[0] = f.read(); // LSB
  ((uint8_t *)&result)[1] = f.read();
  ((uint8_t *)&result)[2] = f.read();
  ((uint8_t *)&result)[3] = f.read(); // MSB
  return result;
}

And then I just (try to) call the function via bmpDraw(“mgbars.bmp”, 0, 30);

But nothing happens, the space on the screen where the logo ist supposed to be stays blank, and as I said, it says “File not found” in the serial monitor.

A library is needed to access the SD card. Have you tried just listing the files on the card with an example from either the standard Arduino "SD" library or loaded the alternative "SdFat" library?

Bear in mind that SD cards are also 3.3V logic compatible and need need logic level translators if you are using a 5V UNO etc. Also connect the SD card SPI pins to the Arduino hardware SPI pins to get best performance, you can share the SPI port with the display, you just need a different chip select pin for the SD Card.

Edit: It looks like the display has 10K series resistors on the SPI lines to the SD Card. These will permit you to use 5V logic signals on the SD card SPI and CS lines. However you may need to reduce the SPI clock rate as these series resistors have quite a high value and some SD Cards do not like the resulting slow rise and fall times. It is a case of try it and see if it works reliably.

I need help. I did everything said. bought 2 in case the first was bad. plus tried it on 3 different boards. all i get is the bc light. and this when compelling it.

C:\Users\Jason Drennen\Documents\Arduino\libraries\TFT_ST7735-master\examples\TFT_graphicstest_small\TFT_graphicstest_small.ino: In function ‘void setup()’:

C:\Users\Jason Drennen\Documents\Arduino\libraries\TFT_ST7735-master\examples\TFT_graphicstest_small\TFT_graphicstest_small.ino:69:397: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]

testdrawtext("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur adipiscing ante sed nibh tincidunt feugiat. Maecenas enim massa, fringilla sed malesuada et, malesuada sit amet turpis. Sed porttitor neque ut ante pretium vitae malesuada nunc bibendum. Nullam aliquet ultrices massa eu hendrerit. Ut sed nisi lorem. In vestibulum purus a tortor imperdiet posuere. ", ST7735_WHITE);

^

C:\Users\Jason Drennen\Documents\Arduino\libraries\TFT_ST7735-master\examples\TFT_graphicstest_small\TFT_graphicstest_small.ino: In function ‘testroundrects()’:

C:\Users\Jason Drennen\Documents\Arduino\libraries\TFT_ST7735-master\examples\TFT_graphicstest_small\TFT_graphicstest_small.ino:236:15: warning: iteration 1 invokes undefined behavior [-Waggressive-loop-optimizations]

color+=100;

^

C:\Users\Jason Drennen\Documents\Arduino\libraries\TFT_ST7735-master\examples\TFT_graphicstest_small\TFT_graphicstest_small.ino:223:3: note: containing loop

for(t = 0 ; t <= 4; t+=1) {

^

C:\Users\Jason Drennen\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.14\cores\arduino\main.cpp: In function ‘main’:

C:\Users\Jason Drennen\Documents\Arduino\libraries\TFT_ST7735-master\examples\TFT_graphicstest_small\TFT_graphicstest_small.ino:236:15: warning: iteration 1 invokes undefined behavior [-Waggressive-loop-optimizations]

color+=100;

^

C:\Users\Jason Drennen\Documents\Arduino\libraries\TFT_ST7735-master\examples\TFT_graphicstest_small\TFT_graphicstest_small.ino:223:3: note: containing loop

for(t = 0 ; t <= 4; t+=1) {

^

Sketch uses 26,936 bytes (93%) of program storage space. Maximum is 28,672 bytes.
Global variables use 680 bytes (26%) of dynamic memory, leaving 1,880 bytes for local variables. Maximum is 2,560 bytes.