Connecting TFT screen to Arduino Pro Micro via SPI

Hi,

I have a problem with connecting the TFT screen to Pro Micro. I will thankful for any help.
I’m not any specialist in Arduino. This is one of my first projects, so please explain very simply :).

I created a program code compile and load onto Arduino Uno. Everything was fine, program worked properly. But due to problem with place I decided to buy a Pro Micro and now its a problem because the program doesn’t work and I do not have any idea whats is wrong. If somebody can help my, provide my some ideas I will thankful.

Chosen device on IDE: Arduino Leonardo (according to instruction)

Arduino ProMicro TFT screen 1.44
pin 8 —> DC
pin 10 —> TCS
pin 16 —> MOSI
pin 14 —> RESET
pin 15 —> SCK

Code of my program ( I know nothing special :slight_smile: ):

#include <dht.h>
#define DHT22PIN 2
dht DHT22;
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library for ST7735
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789
#include <SPI.h>
#if defined(SAM3X8E)
#undef __FlashStringHelper::F(string_literal)
#define F(string_literal) string_literal
#endif
#define TFT_CS 10
#define TFT_RST 14
#define TFT_DC 8
#define ST7735_ORANGE 0xFD20
#define TFT_SCLK 15
#define TFT_MOSI 16
//Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
int Bat1 = A1;
int Bat2 = A2;
int Bat3 = A3;
float vout1 = 0.0;
float vout2 = 0.0;
float vout3 = 0.0;
float napiecie = 0.0;
float napiecie1 = 0.0;
float napiecie2 = 0.0;
float napiecie3 = 0.0;
float R1 = 30000.0;
float R2 = 7500.0;
float stanbaterii = 0;
int wartosc1 = 0;
int wartosc2 = 0;
int wartosc3 = 0;

const int barW=12,nBars=8, x_axis=0, y_axis=0, x0=0, y0=0;
void setup(void) {
Serial.begin(9600);
tft.initR(INITR_144GREENTAB); // initialize a ST7735S chip, green tab
tft.fillScreen(ST7735_BLUE);
tft.drawRect(0, 2, 127, 126, ST7735_WHITE);
tft.drawRect(1, 3, 125, 124, ST7735_WHITE);
tft.setCursor(20,110);
tft.setTextColor(ST7735_ORANGE);
tft.setTextSize(1);
tft.print(“Three Wheel Fun”);
/////////////////////////////////////////////////////////
tft.drawFastHLine(0,100, 128, ST7735_WHITE);
tft.drawFastVLine(64, 0,100,ST7735_WHITE);
/////////////////////////////////////////////////////////
tft.setCursor(5, 15);
tft.setTextColor(ST7735_WHITE);
tft.setTextSize(1);
tft.print(“Napiecia:”);

pinMode(Bat1, INPUT);
tft.setCursor(5, 35);
tft.setTextColor(ST7735_WHITE);
tft.setTextSize(1);
tft.print(“Bat1:”);

tft.setCursor(55, 35);
tft.setTextColor(ST7735_WHITE);
tft.setTextSize(1);
tft.print(“V”);

pinMode(Bat2, INPUT);
tft.setCursor(5, 55);
tft.setTextColor(ST7735_WHITE);
tft.setTextSize(1);
tft.print(“Bat2:”);

tft.setCursor(55, 55);
tft.setTextColor(ST7735_WHITE);
tft.setTextSize(1);
tft.print(“V”);

pinMode(Bat3, INPUT);
tft.setCursor(5, 75);
tft.setTextColor(ST7735_WHITE);
tft.setTextSize(1);
tft.print(“Bat3:”);

tft.setCursor(55, 75);
tft.setTextColor(ST7735_WHITE);
tft.setTextSize(1);
tft.print(“V”);
//////////////////////////////////////////////////////////////////
tft.setCursor(70, 15);
tft.setTextColor(ST7735_WHITE);
tft.setTextSize(1);
tft.print(“Prad:”);

tft.setCursor(103, 30);
tft.setTextColor(ST7735_WHITE);
tft.setTextSize(2);
tft.print(“A”);
//////////////////////////////////////////////////////////////////
tft.setCursor(70, 55);
tft.setTextColor(ST7735_WHITE);
tft.setTextSize(1);
tft.print(“Stan”);
tft.setCursor(70, 65);
tft.setTextColor(ST7735_WHITE);
tft.setTextSize(1);
tft.print(“baterii:”);

tft.setCursor(109, 80);
tft.setTextColor(ST7735_WHITE);
tft.setTextSize(2);
tft.print("%");
}

void loop() {
tft.fillRect(35,30,19,55,ST7735_BLUE);//Refresh napiec
tft.fillRect(70,25,33,25,ST7735_BLUE);//Refresh pradu
tft.fillRect(70,75,33,22,ST7735_BLUE);//Refresh stanu baterii
int chk = DHT22.read(DHT22PIN);
/////////////////////////////////////////////////////////////Wartosc Napiecia 1
wartosc1 = analogRead(Bat1);
vout1 = (wartosc1 * 5.0) / 1024.0;
napiecie1 = vout1 / (R2/(R1+R2));
tft.setCursor(40, 35);
tft.setTextColor(ST7735_WHITE);
tft.setTextSize(1); //wyświetlenie temperatury
tft.print((float)napiecie1, 0);
///////////////////////////////////////////////////////////Wartosc Napiecia 2
wartosc2 = analogRead(Bat2);
vout2 = (wartosc2 * 5.0) / 1024.0;
napiecie2 = vout2 / (R2/(R1+R2));
tft.setCursor(40, 55);
tft.setTextColor(ST7735_WHITE);
tft.setTextSize(1); //wyświetlenie wartości wilgotności
tft.println((float)napiecie2, 0);
///////////////////////////////////////////////////////////Wartosc Napiecia 3
wartosc3 = analogRead(Bat3);
vout3 = (wartosc3 * 5.0) / 1024.0;
napiecie3 = vout3 / (R2/(R1+R2));
tft.setCursor(40, 75);
tft.setTextColor(ST7735_WHITE);
tft.setTextSize(1);
tft.println((float)napiecie3, 0);
///////////////////////////////////////////////////////////Wartosc Pradu
tft.setCursor(77, 30);
tft.setTextColor(ST7735_WHITE);
tft.setTextSize(2); //wyświetlenie temperatury
tft.print((float)DHT22.temperature, 0);
////////////////////////////////////////////////////////////Wartosc Stanu Baterii
tft.setCursor(70, 80);
tft.setTextColor(ST7735_WHITE);
tft.setTextSize(2); //wyświetlenie temperatury
napiecie=napiecie1+napiecie2+napiecie3;
if(napiecie>=28)
{
stanbaterii=100;
}
if(napiecie<=28)
{
stanbaterii=50;
}
if(napiecie<=25.5)
{
stanbaterii=0;
}

tft.print((float)stanbaterii, 0);
delay(10000); //opóźnienie między kolejnymi odczytami - 1 s

}

  1. Do you need both libraries:
#include <Adafruit_ST7735.h> // Hardware-specific library for ST7735
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789
  1. Maybe choose another pin for reset. This appears to be used on the Micro for SPI (MISO)
pin 14               --->     RESET

Thank you 6v6gt for reply.

You have right, I don't need a second library - I put in comment
Also I changed the reset pin but it doesn't help. If you see I don't use a ProMicro SPI outputs I just declare all SPI outputs.

I checked library and they define CLK for 16MHz, maybe It is to high value for this controller ?

If it worked on a Uno, then I don't believe 16MHz is a problem.
You mentioned Leonardo which has the same chip as the Micro (32U4) but a different pin numbering system. Post a link to the Leonardo information you have for this screen.

If the size of the Uno board was a problem, then an Arduino Nano or even a Mini (no USB) may have been a better choice because these all use the same chip (ATMEGA328P)

I'm curios about instructions advising you to use Leonardo, what's wrong with saying it is the board you have?

I have moved a TFT Uno shield to a pro micro or nano (forget) and it was painful only in exactly the way you are experiencing, finding where SPI can safely go, ensuring the library propriety &c.

a7

Thank you very much, case closed :slight_smile:

I solved the problem, just deleted a library for TFT from IDE data ( c:/documents/Arduino/library…) and upload again and finally Is working well. TFT started displaying :).

According your question alto777, I don’t know why it is like that. The board is original. I couldn’t find this board in IDE also when I’m connecting ProMicro, its showing that Leonardo board is detected.

I have a strange issue with tft connections.
I have wired a pro micro (leonardo) as the manual of the project stated. But white screen. So far, no good.

But I tried to put another screen on the same conectors (holding it with my hand) just to see if the first one was dead or faulty... and then uploaded sketch. Image supposed to apear did it, on the soldered one, not on the one I was holding with my hand with the contacts; as soon as I remove the second one, first one stopped working and went to white.
SPI connection with rst and led to the VCC (so states the manual I followed)

Any clues?

Thanks for your time