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?
