ESP32 Serial Monitor problem

Hello. I have a problem sending data through the serial port with esp32. The incoming data is fine but when I upload the sketch no data is displayed in Serial Monitor.

#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_ST7735.h>

//TFT
#define TFT_DC 16 //A0
#define TFT_CS 13 //CS
#define TFT_MOSI 23 //SDA
#define TFT_CLK 18 //SCK
#define TFT_RST 0 // 3.3v


//OLED
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64

#define OLED_MOSI   23
#define OLED_CLK    18
#define OLED_DC     16
#define OLED_RESET  19

#define OLED1_CS 17
#define OLED2_CS 21
#define OLED3_CS 22
#define OLED4_CS 32
#define OLED5_CS 26
#define OLED6_CS 25
#define OLED7_CS 33
#define OLED8_CS 15



#define BUTT 1
#define ENCODER_L 34
#define ENCODER_R 35


Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST);
Adafruit_SSD1306 OLED1(SCREEN_WIDTH, SCREEN_HEIGHT, OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED1_CS);
Adafruit_SSD1306 OLED2(SCREEN_WIDTH, SCREEN_HEIGHT, OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED2_CS);
Adafruit_SSD1306 OLED3(SCREEN_WIDTH, SCREEN_HEIGHT, OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED3_CS);
Adafruit_SSD1306 OLED4(SCREEN_WIDTH, SCREEN_HEIGHT, OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED4_CS);
Adafruit_SSD1306 OLED5(SCREEN_WIDTH, SCREEN_HEIGHT, OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED5_CS);
Adafruit_SSD1306 OLED6(SCREEN_WIDTH, SCREEN_HEIGHT, OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED6_CS);
Adafruit_SSD1306 OLED7(SCREEN_WIDTH, SCREEN_HEIGHT, OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED7_CS);
Adafruit_SSD1306 OLED8(SCREEN_WIDTH, SCREEN_HEIGHT, OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED8_CS);


const int led = 2;
byte displaySelector;
unsigned char buffer[384];
int BUTT_State;


void setup() {

  Serial.begin(115200);

  pinMode(led, OUTPUT);
  pinMode (ENCODER_L, INPUT);
  pinMode (ENCODER_R, INPUT);
  pinMode(BUTT, INPUT_PULLUP);

  tft.initR(INITR_BLACKTAB);
  tft.fillScreen(ST77XX_BLACK);
  tft.setRotation(3);

  OLED1.begin(SSD1306_SWITCHCAPVCC, 0, true, true);
  OLED1.clearDisplay();
  OLED1.display();

  OLED2.begin(SSD1306_SWITCHCAPVCC, 0, false, true);
  OLED2.clearDisplay();
  OLED2.display();

  OLED3.begin(SSD1306_SWITCHCAPVCC, 0, false, true);
  OLED3.clearDisplay();
  OLED3.display();

  OLED4.begin(SSD1306_SWITCHCAPVCC, 0, false, true);
  OLED4.clearDisplay();
  OLED4.display();

  OLED5.begin(SSD1306_SWITCHCAPVCC, 0, false, true);
  OLED5.clearDisplay();
  OLED5.display();

  OLED6.begin(SSD1306_SWITCHCAPVCC, 0, false, true);
  OLED6.clearDisplay();
  OLED6.display();

  OLED7.begin(SSD1306_SWITCHCAPVCC, 0, false, true);
  OLED7.clearDisplay();
  OLED7.display();

  OLED8.begin(SSD1306_SWITCHCAPVCC, 0, false, true);
  OLED8.clearDisplay();
  OLED8.display();


}

void loop() {

  Serial.println("Hello world!");

  BUTT_State = digitalRead(BUTT);

  if (BUTT_State == LOW) {
    Serial.println("HIGH");
    digitalWrite(led, HIGH);
  }
  if (BUTT_State == HIGH) {
    digitalWrite(led, LOW);
    Serial.println("LOW");
  }


  if (digitalRead(ENCODER_L) == LOW) {
    Serial.print("L");
    delay(100);
  }
  if (digitalRead(ENCODER_R) == LOW) {
    Serial.print("R");
    delay(100);
  }

  if (Serial.available() > 0) {
    byte displaySelector = Serial.read();
    Serial.readBytes(buffer, 384);


    if (displaySelector == '0') {
      OLED1.clearDisplay();
      OLED1.drawBitmap(32, 16, buffer, 64, 48, SSD1306_WHITE);
      OLED1.display();
    }

    if (displaySelector == '1') {
      OLED2.clearDisplay();
      OLED2.drawBitmap(32, 16, buffer, 64, 48, SSD1306_WHITE);
      OLED2.display();
    }

    if (displaySelector == '2') {
      OLED3.clearDisplay();
      OLED3.drawBitmap(32, 16, buffer, 64, 48, SSD1306_WHITE);
      OLED3.display();
    }

    if (displaySelector == '3') {
      OLED4.clearDisplay();
      OLED4.drawBitmap(32, 16, buffer, 64, 48, SSD1306_WHITE);
      OLED4.display();
    }

    if (displaySelector == '4') {
      OLED5.clearDisplay();
      OLED5.drawBitmap(32, 16, buffer, 64, 48, SSD1306_WHITE);
      OLED5.display();
    }

    if (displaySelector == '5') {
      OLED6.clearDisplay();
      OLED6.drawBitmap(32, 16, buffer, 64, 48, SSD1306_WHITE);
      OLED6.display();
    }

    if (displaySelector == '6') {
      OLED7.clearDisplay();
      OLED7.drawBitmap(32, 16, buffer, 64, 48, SSD1306_WHITE);
      OLED7.display();
    }

    if (displaySelector == '7') {
      OLED8.clearDisplay();
      OLED8.drawBitmap(32, 16, buffer, 64, 48, SSD1306_WHITE);
      OLED8.display();
    }

    if (displaySelector == '9') {
      String receivedText = Serial.readStringUntil('\n'); 
      tft.fillScreen(ST77XX_BLACK);
      tft.setTextColor(ST77XX_WHITE);
      tft.setTextSize(1);
      tft.setCursor(10, 10);
      tft.println(receivedText);
    }

  }

}

This code works fine.

#define ENCODER_L 34
#define ENCODER_R 35
const int led = 2;

void setup() {
   Serial.begin(115200);
  
  pinMode(led, OUTPUT);
  pinMode (ENCODER_L, INPUT);
  pinMode (ENCODER_R, INPUT);

}

void loop() {
 
   if(digitalRead(ENCODER_L) == LOW){
    Serial.print("L");
    delay(100);
   }
    if(digitalRead(ENCODER_R) == LOW){
    Serial.print("R");
    delay(100);
   }
   
}

Does anyone have an idea what could be blocking data on Serial Monitor?

Yep, That is the TX pin

GPIO 36 & 39 are still available, try one of them, they are input only but that doesn't matter in this case.

1 Like

<wrong suggestion, deleted>

I check and you have right, i delete #define BUTT 1. And it start works, probably I can't use GPIO1 (TX) as input.
Thanks for help.

But they don't have an internal pull-up resistor

Its not a problem, i can add pullup resistor

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