I can load BasicOTA over serial and the network port shows up and I can connect to it OK.
I can then upload a program OTA and it uploads and runs OK but after a few seconds the network port disappears so I can no longer do OTA uploads.
I can load BasicOTA over serial again to make the network port reappear but, so far, I can only upload OTA once.
I'm using IDE 2.3.6 on Win 11.
I have been using wireless OTA uploading on NodeMCU/esp8266 for many years and was thinking of using Nano ESP32 for future projects but I'm stuck on this issue.
Network ports disappearing has been an issue before but rebooting or clicking on "Reload Board Data" in IDE 2.x makes the port reappear for NodeMCU.
With Nano ESP32 after the first upload the port disappears. No response if I ping the port address.
Hi @jcflyer.
Is OTA functionality implemented in the sketch you uploaded?
If not, that is the expected result. You must implement OTA functionality in every sketch you upload. If it is not implemented, or if it is implemented but not working correctly (e.g., incorrect network credentials), then the board is put into a state where it can no longer be uploaded to OTA. That is just the nature of OTA.
With NodeMCU I put in 3 lines in my sketch for OTA functionality. Following the examples online there is no mention of adding those lines for Nano ESP32. I tried adding the 3 lines for NodeMCU for Nano ESP32 but all ports disappeared including the com and dfu ports so I had to reflash the firmware.
What are the lines to be added for OTA functionality for Nano ESP32?
I tried adding these OTA lines to the sketch but the same thing. Uploads OTA and runs fine but then the network port disappears.
#include <WiFi.h>
#include <ArduinoOTA.h> // Enable OTA programming 1 of 3 lines
void setup() {
WiFi.mode(WIFI_STA);
ArduinoOTA.begin(); // Enable OTA programming 2 of 3 lines
// put your setup code here, to run once:
pinMode(LED_RED, OUTPUT);
pinMode(LED_GREEN, OUTPUT);
pinMode(LED_BLUE, OUTPUT);
pinMode(LED_BUILTIN, OUTPUT);
pinMode(D4, OUTPUT);
}
void loop() {
ArduinoOTA.handle(); // Enable OTA programming 3 of 3 lines
digitalWrite(LED_BUILTIN, HIGH);
digitalWrite(LED_RED, LOW);
digitalWrite(LED_GREEN, HIGH);
digitalWrite(LED_BLUE, HIGH);
digitalWrite(D4, LOW);
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
digitalWrite(LED_RED, HIGH);
digitalWrite(LED_GREEN, LOW);
digitalWrite(LED_BLUE, HIGH);
digitalWrite(D4, HIGH);
delay(1000);
digitalWrite(LED_BUILTIN, HIGH);
digitalWrite(LED_RED, HIGH);
digitalWrite(LED_GREEN, HIGH);
digitalWrite(LED_BLUE, LOW);
digitalWrite(D4, LOW);
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
digitalWrite(D4, HIGH);
}
Solution.The following code works. BasicOTA not needed.
Upload the sketch with the OTA lines added over serial and then can upload the same sketch OTA afterward. Network port still visible.
It would be good if there was an OTA example sketch, say Blink_OTA, with these lines added.
#include <WiFi.h>
#include <ArduinoOTA.h> // Enable OTA programming 1 of 3 lines
const char* ssid = ".....";
const char* password = ".....";
void setup() {
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
ArduinoOTA.begin(); // Enable OTA programming 2 of 3 lines
// put your setup code here, to run once:
pinMode(LED_RED, OUTPUT);
pinMode(LED_GREEN, OUTPUT);
pinMode(LED_BLUE, OUTPUT);
pinMode(LED_BUILTIN, OUTPUT);
pinMode(D4, OUTPUT);
}
void loop() {
ArduinoOTA.handle(); // Enable OTA programming 3 of 3 lines
digitalWrite(LED_BUILTIN, HIGH);
digitalWrite(LED_RED, LOW);
digitalWrite(LED_GREEN, HIGH);
digitalWrite(LED_BLUE, HIGH);
digitalWrite(D4, LOW);
delay(500);
digitalWrite(LED_BUILTIN, LOW);
digitalWrite(LED_RED, HIGH);
digitalWrite(LED_GREEN, LOW);
digitalWrite(LED_BLUE, HIGH);
digitalWrite(D4, HIGH);
delay(500);
digitalWrite(LED_BUILTIN, HIGH);
digitalWrite(LED_RED, HIGH);
digitalWrite(LED_GREEN, HIGH);
digitalWrite(LED_BLUE, LOW);
digitalWrite(D4, LOW);
delay(500);
digitalWrite(LED_BUILTIN, LOW);
digitalWrite(D4, HIGH);
}