从 Arduino IDE 上传到 ESP8266 时出错
Error while uploading to ESP8266 from Arduino IDE
我试图从 Arduino IDE 将代码上传到我的 esp8266,它给了我这个错误:
esptool.py v2.8
Serial port COM6
Connecting........_____....._____....._____....._____....._____....._____.....____Traceback (most recent call last):
File "C:\Users\arcae_000\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266.6.3/tools/upload.py", line 65, in <module>
esptool.main(cmdline)
File "C:/Users/arcae_000/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/tools/esptool\esptool.py", line 2890, in main
esp.connect(args.before)
File "C:/Users/arcae_000/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/tools/esptool\esptool.py", line 483, in connect
raise FatalError('Failed to connect to %s: %s' % (self.CHIP_NAME, last_error))
esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header
esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header
我在 Arduino IDE 上安装了 esp8266 扩展板并设置为 'Generic ESP8266 Module'。我尝试更改上传速度,但仍然失败。这是我使用的代码:
#include <ESP8266WiFi.h>
const char* ssid = "SSID";//type your ssid
const char* password = "PASSWORD";//type your password
int ledPin = 2; // GPIO2 of ESP8266
WiFiServer server(80);
void setup() {
Serial.begin(115200);
delay(10);
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
// Connect to WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
// Start the server
server.begin();
Serial.println("Server started");
// Print the IP address
Serial.print("Use this URL to connect: ");
Serial.print("http://");
Serial.print(WiFi.localIP());
Serial.println("/");
}
void loop() {
// Check if a client has connected
WiFiClient client = server.available();
if (!client) {
return;
}
// Wait until the client sends some data
Serial.println("new client");
while(!client.available()){
delay(1);
}
// Read the first line of the request
String request = client.readStringUntil('\r');
Serial.println(request);
client.flush();
// Match the request
int value = LOW;
if (request.indexOf("/LED=ON") != -1) {
digitalWrite(ledPin, HIGH);
value = HIGH;
}
if (request.indexOf("/LED=OFF") != -1){
digitalWrite(ledPin, LOW);
value = LOW;
}
// Set ledPin according to the request
//digitalWrite(ledPin, value);
// Return the response
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println(""); // do not forget this one
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.print("Led pin is now: ");
if(value == HIGH) {
client.print("On");
} else {
client.print("Off");
}
client.println("<br><br>");
client.println("Click <a href=\"/LED=ON\">here</a> turn the LED on pin 2 ON<br>");
client.println("Click <a href=\"/LED=OFF\">here</a> turn the LED on pin 2 OFF<br>");
client.println("</html>");
delay(1);
Serial.println("Client disonnected");
Serial.println("");
}
(我已经更改了 SSID 和密码值)
我已经搜索了所有我能找到的网站,但我仍然无法修复它。 esp8266 处于闪存模式。另外,我知道 esp8266 没有坏。如果有任何帮助,我将不胜感激。
你能post你的上传设置吗?
可能出错的地方:
你可能有一个NODEMCU模块,尝试在上传设置中切换到那个板。
您是否确认在插入 ESP 时会出现一个新的 COM 端口?
您是否选择了正确的 COM 端口?
这些是我的 ESP8266 设置,
here
如果您实际上有一个 NODEMCU,如果上面没有任何效果,请尝试使用所有这些说明更新固件:https://github.com/nodemcu/nodemcu-firmware
我试图从 Arduino IDE 将代码上传到我的 esp8266,它给了我这个错误:
esptool.py v2.8
Serial port COM6
Connecting........_____....._____....._____....._____....._____....._____.....____Traceback (most recent call last):
File "C:\Users\arcae_000\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266.6.3/tools/upload.py", line 65, in <module>
esptool.main(cmdline)
File "C:/Users/arcae_000/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/tools/esptool\esptool.py", line 2890, in main
esp.connect(args.before)
File "C:/Users/arcae_000/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/tools/esptool\esptool.py", line 483, in connect
raise FatalError('Failed to connect to %s: %s' % (self.CHIP_NAME, last_error))
esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header
esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header
我在 Arduino IDE 上安装了 esp8266 扩展板并设置为 'Generic ESP8266 Module'。我尝试更改上传速度,但仍然失败。这是我使用的代码:
#include <ESP8266WiFi.h>
const char* ssid = "SSID";//type your ssid
const char* password = "PASSWORD";//type your password
int ledPin = 2; // GPIO2 of ESP8266
WiFiServer server(80);
void setup() {
Serial.begin(115200);
delay(10);
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
// Connect to WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
// Start the server
server.begin();
Serial.println("Server started");
// Print the IP address
Serial.print("Use this URL to connect: ");
Serial.print("http://");
Serial.print(WiFi.localIP());
Serial.println("/");
}
void loop() {
// Check if a client has connected
WiFiClient client = server.available();
if (!client) {
return;
}
// Wait until the client sends some data
Serial.println("new client");
while(!client.available()){
delay(1);
}
// Read the first line of the request
String request = client.readStringUntil('\r');
Serial.println(request);
client.flush();
// Match the request
int value = LOW;
if (request.indexOf("/LED=ON") != -1) {
digitalWrite(ledPin, HIGH);
value = HIGH;
}
if (request.indexOf("/LED=OFF") != -1){
digitalWrite(ledPin, LOW);
value = LOW;
}
// Set ledPin according to the request
//digitalWrite(ledPin, value);
// Return the response
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println(""); // do not forget this one
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.print("Led pin is now: ");
if(value == HIGH) {
client.print("On");
} else {
client.print("Off");
}
client.println("<br><br>");
client.println("Click <a href=\"/LED=ON\">here</a> turn the LED on pin 2 ON<br>");
client.println("Click <a href=\"/LED=OFF\">here</a> turn the LED on pin 2 OFF<br>");
client.println("</html>");
delay(1);
Serial.println("Client disonnected");
Serial.println("");
}
(我已经更改了 SSID 和密码值) 我已经搜索了所有我能找到的网站,但我仍然无法修复它。 esp8266 处于闪存模式。另外,我知道 esp8266 没有坏。如果有任何帮助,我将不胜感激。
你能post你的上传设置吗?
可能出错的地方:
你可能有一个NODEMCU模块,尝试在上传设置中切换到那个板。
您是否确认在插入 ESP 时会出现一个新的 COM 端口?
您是否选择了正确的 COM 端口?
这些是我的 ESP8266 设置, here
如果您实际上有一个 NODEMCU,如果上面没有任何效果,请尝试使用所有这些说明更新固件:https://github.com/nodemcu/nodemcu-firmware