Serial Monitor only shows strange symbols [Arduino Mega with ESP8266]

Hello guys,

I have a problem, as you can see in the title and in the image below:

I believe that my Sketch has been sent to ESP correctly, this is the message that appears after uploading:

Executable segment sizes:


IROM   : 235884          - code in flash         (default or ICACHE_FLASH_ATTR) 


IRAM   : 26908   / 32768 - code in IRAM          (ICACHE_RAM_ATTR, ISRs...) 


DATA   : 1264  )         - initialized variables (global, static) in RAM/HEAP 


RODATA : 784   ) / 81920 - constants             (global, static) in RAM/HEAP 


BSS    : 24976 )         - zeroed variables      (global, static) in RAM/HEAP 


O sketch usa 264840 bytes (27%) de espaço de armazenamento para programas. O máximo são 958448 bytes.
Variáveis globais usam 27024 bytes (32%) de memória dinâmica, deixando 54896 bytes para variáveis locais. O máximo são 81920 bytes.
esptool.py v2.8
Serial port COM3
Connecting....
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: 84:f3:eb:9f:ef:75
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 4MB
Flash params set to 0x0340
Compressed 268992 bytes to 196702...

Writing at 0x00000000... (7 %)
Writing at 0x00004000... (15 %)
Writing at 0x00008000... (23 %)
Writing at 0x0000c000... (30 %)
Writing at 0x00010000... (38 %)
Writing at 0x00014000... (46 %)
Writing at 0x00018000... (53 %)
Writing at 0x0001c000... (61 %)
Writing at 0x00020000... (69 %)
Writing at 0x00024000... (76 %)
Writing at 0x00028000... (84 %)
Writing at 0x0002c000... (92 %)
Writing at 0x00030000... (100 %)
Wrote 268992 bytes (196702 compressed) at 0x00000000 in 17.5 seconds (effective 122.7 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

Here is the code:

#include <ESP8266WiFi.h>

// Network SSID
const char* ssid = "";
const char* password = "";
 
void setup() {
  
  Serial.begin(115200);
  delay(10);
 
  // Connect WiFi
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);
  WiFi.hostname("Name");
  WiFi.begin(ssid, password);
 
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
 
  // Print the IP address
  Serial.print("IP address: ");
  Serial.print(WiFi.localIP());
}
 
void loop() {
  

  }

The speeds are the same, the library is installed as well.
My arduino is this: Arduino Mega with ESP8266

My guess is that the switches are set wrong, and you are getting the startup log from the ESP instead or something...

DrAzzy:
My guess is that the switches are set wrong, and you are getting the startup log from the ESP instead or something...

I configured the Dip Switch to the following: CH340 connect to ESP8266 (connect) thus deactivating GPIO0 and now I have this result:

Apparently the code is running, but I don't have a connection

It appears your baud rate is wrong. Try different speeds or simply connect a logic analyzer and look at the signal coming from the ESP8266.

Selitto:
now I have this result:

That first line of gibberish is the output from the bootloader, which is at 74880 baud. Since your program is running, you can just ignore that if you like.

Selitto:
Apparently the code is running, but I don't have a connection

Selitto:

// Network SSID

const char* ssid = "";
const char* password = "";

If those are really blank, that would explain the problem.

pert:
That first line of gibberish is the output from the bootloader, which is at 74880 baud. Since your program is running, you can just ignore that if you like.

Got it, I think I realized that with the new code I tested

pert:
If those are really blank, that would explain the problem.

Not blank in code.

I tested this code, and it worked

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
     
// ใส่ชื่อพาสเวิดไฟไวของเรา
const char* ssid = "Setor de TI";
const char* password = "Hefestus";

ESP8266WebServer server(80);
MDNSResponder mdns;
     
String webPage = "";
     
int led_pin = 13;
     
void setup(void){
     
  // подготовка:
  pinMode(led_pin, OUTPUT);
  digitalWrite(led_pin, LOW);
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
  
  // ปริ้นค่าสถานะต่างๆ
  Serial.println("");
  Serial.println("ESP8266 board info:");
  Serial.print("\tChip ID: ");
  Serial.println(ESP.getFlashChipId());
  Serial.print("\tCore Version: ");
  Serial.println(ESP.getCoreVersion());
  Serial.print("\tChip Real Size: ");
  Serial.println(ESP.getFlashChipRealSize());
  Serial.print("\tChip Flash Size: ");
  Serial.println(ESP.getFlashChipSize());
  Serial.print("\tChip Flash Speed: ");
  Serial.println(ESP.getFlashChipSpeed());
  Serial.print("\tChip Speed: ");
  Serial.println(ESP.getCpuFreqMHz());
  Serial.print("\tChip Mode: ");
  Serial.println(ESP.getFlashChipMode());
  Serial.print("\tSketch Size: ");
  Serial.println(ESP.getSketchSize());
  Serial.print("\tSketch Free Space: ");
  Serial.println(ESP.getFreeSketchSpace());

  // แสดงบนหน้าเว็บ
  webPage += "<h1>ESP8266 Web Server</h1>";
  webPage += "<p>Chip ID: ";
  webPage += ESP.getFlashChipId();
  webPage += "</p>";
  webPage += "<p>Core Version: ";
  webPage += ESP.getCoreVersion();
  webPage += "</p>";
  webPage += "<p>Chip Real Size: ";
  webPage += ESP.getFlashChipRealSize()/1024;
  webPage += " Kbit</p>";
  webPage += "<p>Chip Size: ";
  webPage += ESP.getFlashChipSize()/1024;
  webPage += " Kbit</p>";
  webPage += "<p>Chip Flash Speed: ";
  webPage += ESP.getFlashChipSpeed()/1000000;
  webPage += " MHz</p>";
  webPage += "<p>Chip Work Speed: ";
  webPage += ESP.getCpuFreqMHz();
  webPage += " MHz</p>";
  webPage += "<p>Chip Mode: ";
  webPage += ESP.getFlashChipMode();
  webPage += "</p>";
  webPage += "<p>LED state <a href=\"LedON\"><button>ON</button></a>&nbsp;<a href=\"LedOFF\"><button>OFF</button></a></p>";

  // เริ่มการเชื่อมต่อไวไฟ
  WiFi.begin(ssid, password);
  Serial.println("");
     

  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to ");  //  "Подключились к "
  Serial.println(ssid);
  Serial.print("IP address: ");  //  "IP-адрес: "
  Serial.println(WiFi.localIP());

  if (mdns.begin("esp8266", WiFi.localIP())) {
    Serial.println("MDNS responder started");
  }
     
  server.on("/", [](){
    server.send(200, "text/html", webPage);
  });
  
  server.on("/LedON", [](){
    server.send(200, "text/html", webPage);
    digitalWrite(led_pin, HIGH);
    Serial.println("[ON]");
    delay(1000);
  });
  
  server.on("/LedOFF", [](){
    server.send(200, "text/html", webPage);
    digitalWrite(led_pin, LOW);
    Serial.println("[OFF]");
    delay(1000);
  });

    server.on("/Led?????", [](){
    server.send(200, "text/html", webPage);
    digitalWrite(led_pin, LOW);
    Serial.println("[OFF]");
    delay(1000);
  });
  
  server.begin();
  Serial.println("HTTP server started");
  
}
     
void loop(void){
  server.handleClient();
}


Now, I would like to understand how do I connect an LED to an Arduino Mega digital port, and not directly on the ESP GPIO0

How to work with the two together?