change tx pin to gpio ,,, i solve this problem with ota upload
void setup() {
Serial.begin(9600);
while (!Serial);
WiFi.hostname("xxxxx"); // DHCP Hostname (useful for finding device for static lease)
ArduinoOTA.setHostname("xxxx");
ArduinoOTA.setPort(8266);
ArduinoOTA.setPassword("");
ArduinoOTA.onStart([]() {
/////////////////change pin to gpio////////
//GPIO 1 (TX) swap the pin to a GPIO.
pinMode(1, FUNCTION_3);
//GPIO 3 (RX) swap the pin to a GPIO.
pinMode(3, FUNCTION_3);
///////////////////////
String type;
if (ArduinoOTA.getCommand() == U_FLASH) {
type = "sketch";
} else { // U_SPIFFS
type = "filesystem";
}
// NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end()
Serial.println("Start updating " + type);
});
ArduinoOTA.onEnd([]() {
////////////////change pin to rx tx again//////////
//GPIO 1 (TX) swap the pin to a TX.
pinMode(1, FUNCTION_0);
//GPIO 3 (RX) swap the pin to a RX.
pinMode(3, FUNCTION_0);
///////////////////////
Serial.println("\nEnd");
});
ArduinoOTA.begin();
delay(1000);
}