求助:连接热点后无法在Arduino IDE串口监视器查看ESP8266的IP地址
Hey there! Let’s figure out why you’re not seeing your ESP8266’s IP address in the Arduino Serial Monitor—this is a super common issue, and I’ve fixed it dozens of times. Let’s go through the steps one by one:
If your serial settings are off, you’ll either get gibberish or nothing at all. Here’s what to check:
- Match the baud rate exactly: If your code uses
Serial.begin(115200), the Serial Monitor must be set to 115200 (look at the bottom-right corner of the monitor window). Mismatched rates are the #1 culprit here. - Pick the right port: In the Arduino IDE, go to
Tools > Portand select the one assigned to your ESP8266 (it’ll look likeCOM3on Windows or/dev/ttyUSB0on Linux/macOS). - Skip unnecessary send settings: Uncheck "Newline" or "Carriage Return" unless your code explicitly expects them—these can interfere with output.
A lot of times, the issue is that the code isn’t waiting for WiFi to connect before trying to print the IP, or it’s missing the print statement entirely. Try this minimal test code (replace your current code with it):
#include <ESP8266WiFi.h> // Replace with your hotspot details const char* ssid = "YOUR_HOTSPOT_NAME"; const char* password = "YOUR_HOTSPOT_PASSWORD"; void setup() { Serial.begin(115200); delay(10); // Give serial time to initialize Serial.println("\nConnecting to " + String(ssid)); WiFi.begin(ssid, password); // Wait up to 20 seconds for WiFi to connect int waitCount = 0; while (WiFi.status() != WL_CONNECTED && waitCount < 20) { delay(1000); Serial.print("."); waitCount++; } if (WiFi.status() == WL_CONNECTED) { Serial.println("\nWiFi connected successfully!"); Serial.print("IP Address: "); Serial.println(WiFi.localIP()); // This line is critical for showing the IP } else { Serial.println("\nFailed to connect to WiFi"); Serial.print("WiFi Status Code: "); Serial.println(WiFi.status()); // Use this code to look up specific issues (e.g., wrong password = WL_CONNECT_FAILED) } } void loop() { // Nothing needed here for this test }
- Swap in your hotspot’s name and password, upload it, and open the Serial Monitor. You’ll see progress dots while connecting, and a clear IP if it works.
Sometimes the Serial Monitor says it’s connecting, but the ESP8266 isn’t actually on your network:
- Check your router’s device list: Log into your hotspot’s admin page (usually
192.168.1.1or192.168.0.1) and look for a device named something likeESP_XXXXXX. If it’s not there, the connection didn’t stick. - Stick to 2.4GHz WiFi: The ESP8266 doesn’t support 5GHz networks—if your hotspot is 5GHz only, switch to a 2.4GHz one.
- Verify encryption: The ESP8266 works best with WPA/WPA2. Avoid WEP or open networks that require web-based login (those won’t work without extra code).
If the above steps don’t work, it might be a physical or driver problem:
- Swap your USB cable: Cheap cables often only carry power, not data. Grab a known-good USB data cable and try again.
- Check power: The ESP8266 needs stable power. If you’re using a computer USB port, try a powered USB hub or an external 5V/1A power supply—low power can cause WiFi drops and serial glitches.
- Update the ESP8266 core: Outdated core files can cause weird bugs. In Arduino IDE, go to
File > Preferences, make sure the additional board URL includeshttp://arduino.esp8266.com/stable/package_esp8266com_index.json, then go toTools > Board > Board Manager, search for "ESP8266", and install the latest version. - Reboot everything: Turn off the ESP8266, close the Arduino IDE, restart your computer, and try again. Sometimes a fresh start fixes stubborn serial issues.
Give these steps a shot—chances are one of them will get that IP address showing up in your Serial Monitor!
内容的提问来源于stack exchange,提问作者Emmanuel Enna

