TFT display turns black when wifi is enabled

Hello I have following sketch:

#include "tft_setup.h"
#include"TFT_eSPI.h"
#include <WiFi.h>
#include "esp_wifi.h"

const char *wlan_ssid = "jsf-yxxxx";
const char *wlan_password = "*****";


WiFiClient espClient;
esp_err_t err;

unsigned long startTime;

const String client_id = "esp32-office";


#define ST7735_DRIVER
#define ST7735_BLACKTAB
   
#define TFT_WIDTH  128
#define TFT_HEIGHT 160

#define TFT_RGB_ORDER TFT_RGB  

// WEMOLS Lolin32 lite
#define TFT_CS    5   
#define TFT_RST   16  
#define TFT_DC    17   
#define TFT_BL    25   // LED back-light
#define TFT_BACKLIGHT_ON HIGH

TFT_eSPI tft = TFT_eSPI();

void turnInto3v(uint8_t pin) {
  pinMode(pin, OUTPUT);
  digitalWrite(pin, 1);
}


void setup(void) {
  Serial.begin(115200);

  turnInto3v(26);
  turnInto3v(33);

  //initWifi();
  initTft();

}

void initTft() {
  Serial.println("Init tft");
  tft.init();
  tft.fillScreen(TFT_BLACK);  
  tft.setRotation(1);

  tft.setCursor(15, 50, 1);  
  tft.setTextColor(TFT_WHITE, TFT_BLACK);
  tft.setTextSize(2);
  tft.println("It works");
  tft.drawRect(10, 40, 145, 40, TFT_YELLOW);  

  Serial.println("Tft ok?");
  delay(2000);


  tft.drawRect(10, 40, 145, 40, TFT_RED); 
}

void initWifi() {
  // Bring up the WiFi connection
  WiFi.setHostname(client_id.c_str());

  tft.print("Wifi connect: ");

  // Dsiplay turns black
  WiFi.begin(wlan_ssid, wlan_password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    tft.print(".");
  }
  tft.println("+");

  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

  tft.println("IP address: " + WiFi.localIP().toString(false));

  startTime = millis();

  // Give user time to read
  delay(1500);
}

void loop() { }

I have 2 scenarios:
1.) tfft before wifi

  • i run "initTft();" and the tft is displaying my expected text
  • then i run "initWifi();" as soon as "WiFi.begin" is reachted, the display is turning black but the esp32(wroom32) is reachable via wifi.

2.) wifi before tft

  • i run "initWifi();" and the esp32 is reachable via wifi as expected.
  • then i run "initTft();" and the display is turning on but stay all white. Nothing will be displayed.

I tried already:

  • using: TFT_eSPI with hardware VSPI
  • using: Adafruit_ST7735 with hardware VSPI
  • using: Adafruit_ST7735 with software SPI (and different pins)

Do some one know how to get the TFT and Wifi working at the same time?

What is powering your project? Maybe show us a photo of a hand-drawn schematic.

I wired the wrom32:
https://de.aliexpress.com/item/1005006606502197.html

to the display:
https://de.aliexpress.com/item/1005005396134138.html

like this:

  • gnd gnd
  • vcc 3v
  • sck D14 serial clock
  • sda D13 serial data aka mosi
  • res D26 lcm reset permanent 3v
  • dc D12 data command aka miso aka dc
  • cs D15 chip select
  • bl D25 back ligtht permanent 3v

I tested now:

  • same code
  • same wiring
  • different esp32 vendor

It works with:
https://de.aliexpress.com/item/1005005776600877.html?spm=a2g0o.order_list.order_list_main.75.782e5c5fMSTJW7&gatewayAdapt=glo2deu

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.