SOLVED - unable to make it work 1.8 SPI TFT 128x160

There is a 100 ohm resistor on the PCB, unless I misread the schematic. I'll check.

Its a 10 ohm resistor. But the LED is rated at 3.3V with a current rating of 30mA (two LEDs of 15mA in parallel). So at 30mA, the Resistor would drop 0.3V giving the LED a voltage drop of 3V which is well within spec.

Thanks guys all your support.
I connected the LED pins, then I've tried out again the adafruit example and everything works now!

Big thanks to all of you!!!

I'm glad it is working for you. And I am also glad the adafruit library works with the display so you don't have to use that awful sample code!! :slight_smile:

I realize this topic is months old, but I cannot get this module working. I've hooked it up as in the original posting and all I get is a white screen. I'm curious as to whether A0 on the lcd is actually the same as the D/C on the adafruit module and if MOSI and SDA are the same. From what I've found online these last two are probably interchangeable. Has anyone else gotten these to work? I've got three of them sitting here and am at a total loss. Thanks in advance for all the help.

The module works fine here with adafruit's libs and following wiring (328p Uno):
SW SPI:
#define sclk 4
#define mosi 5
#define cs 6
#define dc 7
#define rst 8

where dc=A0, mosi=SDA

HW SPI:
//#define sclk 13
//#define mosi 11
#define cs 10
#define dc 9
#define rst 8

P.
PS: my module has got a BGR color coding..

That configuration is working perfectly to handle the TFT. What about the card reader? :stuck_out_tongue:

Hello there i have just got the same TFT screen from ebay please could you tell me how you got it working and with some sample code as i'm pulling my hair out over it.

overflow:
That configuration is working perfectly to handle the TFT. What about the card reader? :stuck_out_tongue:

If using the card reader then you need to connect it to SPI. MOSI, MISO and SCK to respective lines. I used D4 for the SD Card CS. If you connect the TFT to hardware SPI too (much faster update) then what I did was connect the SD card through to hardware SPI (11, 12, 13 on UNO) and then connect the TFT SDA to the SD MOSI, TFT SCL to SD SCK, then TFT CD & AO to your defined pins.

I'll try and find time to put a more comprehensive example together of how to connect it all shortly.

tack:

overflow:
That configuration is working perfectly to handle the TFT. What about the card reader? :stuck_out_tongue:

If using the card reader then you need to connect it to SPI. MOSI, MISO and SCK to respective lines. I used D4 for the SD Card CS. If you connect the TFT to hardware SPI too (much faster update) then what I did was connect the SD card through to hardware SPI (11, 12, 13 on UNO) and then connect the TFT SDA to the SD MOSI, TFT SCL to SD SCK, then TFT CD & AO to your defined pins.

I'll try and find time to put a more comprehensive example together of how to connect it all shortly.

Please do it because I'm having alot of trouble to get it to work.

#include <SD.h>
File myFile;
int cspin = 10;

void setup()
{
  Serial.begin(9600);
  Serial.print("Initializing SD card...");
  
  if (!SD.begin(cspin)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");
  myFile = SD.open("test.txt", FILE_WRITE);

  if (myFile) {
    Serial.print("Writing to test.txt...");
    myFile.println("Demotext.");
    myFile.close();
    Serial.println("done.");
  } else {
    Serial.println("error opening test.txt");
  }
   Serial.println( "Closed!");	 
}
  

void loop()
{
//NOP
}

I can't make this simple piece of code to work. The LCD is disconnected but I can perfectly use it. This is how it is wired to the arduino:

SD Reader:
SCK -> 13
MISO -> 12
MOSI -> 11
CS -> 10

I'm using a stickduino with an atmega168. The memory card is a generic one with 1GB formatted with FAT. I'm using both power connections (5v to the LCD and the 3.3v of the backlight).

Isn't the SD card 3V3? that will require an interface to work properly. There are great tutorials and sample sketches from Adafruit, I bought mine there but I can't remember about the SD card.

Bob

Don't forget that

MOSI > MISO
MISO > MOSI

One devices OUT is another devices IN.

I'll do a full schematic reminder, when I get home tonight, showing exactly how to connect this up and the example code for respective pin assignments.

I did write all the connections out, with the intention of doing this last night, but some other stud came up.

tack:
Don't forget that

MOSI > MISO
MISO > MOSI

One devices OUT is another devices IN.

No...

MOSI -> MOSI
MISO -> MISO

MOSI = "Master OUT, Slave IN"
MISO = "Master IN, Slave OUT"

The Slave devices IN pin, connects to the Master devices OUT pin, so the Slave MOSI and Master MOSI must be connected.

This is not UART, its SPI, where data moves around in a loop containing shift registers.

Thanks for the replies but I've found out that the problem was due to the stickduino. I switched to an ardunino nano v3 and everything is working perfectly but now I have another problem.

The LCD works great and so the SD card reader. But when I try to use them at the same time the LCD becomes extremely slow. :frowning:

Pleae take a look at this sample of code:

#define cs_lcd   10
#define cs_sd    7
#define dc       9
#define rst      8

#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SPI.h>
#include <SD.h>

Adafruit_ST7735 tft = Adafruit_ST7735(cs_lcd, dc, rst);
File myFile;

void setup()
{
  tft.initR(INITR_REDTAB); 
  tft.fillScreen(ST7735_BLACK);
  tft.setTextWrap(false); 
}


void loop()
{
  tft.setTextSize(5);
  tft.setTextColor(ST7735_RED, ST7735_BLACK);
  for ( int i = 0; i < 100; i++ )
  {
    tft.setCursor(40, 50);
    tft.print( i );
    delay( 100 );
  }
  
}

This sample of code works perfectly without any problem. But if I add a simple function to open and write data to a file it will start lagging severely:

#define cs_lcd   10
#define cs_sd    7
#define dc       9
#define rst      8

#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SPI.h>
#include <SD.h>

Adafruit_ST7735 tft = Adafruit_ST7735(cs_lcd, dc, rst);
File myFile;

void setup()
{
  tft.initR(INITR_REDTAB); 
  tft.fillScreen(ST7735_BLACK);
  tft.setTextWrap(false); 
}


void loop()
{
  tft.setTextSize(5);
  tft.setTextColor(ST7735_RED, ST7735_BLACK);
  for ( int i = 0; i < 100; i++ )
  {
    tft.setCursor(40, 50);
    tft.print( i );
    delay( 100 );
  }
  writeCard();
  
}

void writeCard()
{
  if (!SD.begin(cs_sd)) {
    //Error accessing SD CARD.
    return;
  }
  
  myFile = SD.open("tmp.txt", FILE_WRITE);
   if (myFile) {
    //WRITING TO FILE
    myFile.println("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
    // close the file:
    myFile.close();
  }  
}

I though that this could have something to do with the SS, after all I'm enabling the SD pin without disabling the LCD one but still no good. :disappointed_relieved:

void writeCard()
{
  //TRY TO DISABLE THE LCD SS PIN
  digitalWrite( cs_lcd, HIGH );
  
  if (!SD.begin(cs_sd)) {
    //Error accessing SD CARD. Re-enable LCD SS pin, force the SD SS pin to be disabled and exit.
    digitalWrite( cs_lcd, LOW );
    digitalWrite( cs_sd, HIGH );
    return;
  }
  
  myFile = SD.open("tmp.txt", FILE_WRITE);
   if (myFile) {
    //WRITING TO FILE
    myFile.println("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
    // close the file:
    myFile.close();
  }
  
  //Writing finished. Lets re-enable LCD SS pin and disable the SD SS pin.
  digitalWrite( cs_lcd, LOW );  
  digitalWrite( cs_sd, HIGH );
}

I would really love not to have to hack (aka mess with) the Sd.h but right now I feel like I've hit a wall.

Any ideas? :frowning:

Hello, this display is compatible to the 1602 2004 LCD adapter plate IIC I2C, try to use it with the adapter on the I2C interface, as well as wanted in the beginning.

jafarn1:
Hello, this display is compatible to the 1602 2004 LCD adapter plate IIC I2C, try to use it with the adapter on the I2C interface, as well as wanted in the beginning.

I'm sorry, but what did you just try to say?
This display isn't I2C compatible, it is already SPI enabled, there are no adapters needed to run it.

Hi i have the same 1.8"TFT SPI LCD, well after a big search on the web and fight with my Arduino UNO, i found this A 1.8 inch TFT color display (HY-1.8 SPI) and an Arduino | simtronyx – Das Elektronik Blog

Here are the ansewer to manage the LCD. And i recommend use the 1.04 IDE for arduino, works fine; the 1.05 have a bug with the Adafruit_ST7735 driver. I hope this may help us. 8)

I am having problems with the bitmaps I wonder if anyone can assist.

The card is setup normally with the SD sharing the spi connections.

  1. The normal demos graphicstest, graphictest highspeed, rotation, rotation highspeed all work fine and show on the display.
  2. The bmp is on the SD card.
  3. The SD and bmp initialise and load correctly, here is the serial output:

Initializing SD card...OK!
Loading image 'parrot.bmp'
File size: 61494
Image Offset: 54
Header size: 40
Bit Depth: 24
Image size: 128x160
Loaded in 1089 ms

But nothing shows on the display.

As the normal demos work, and the SD works and loads the bmp the fault escapes me.

cheers
nw

Just to try to help others that find this post, I've gone ahead and documented the proper wiring for this board (which has completely incorrect silk screen):