Baseado em nosso Exemplo minimal de PlatformIO ESP8266 ArduinoOTA, este é um ponto de partida minimal para seu programa ESP32 executando ArduinoOTA.
minimal_platformio_esp32_arduinoota_example.cpp
#include <Arduino.h>
#include <WiFi.h>
#include <ArduinoOTA.h>
void setup() {
Serial.begin(115200);
/**
* Connect to Wifi
*/
WiFi.begin("MyWifi", "abc123abc");
uint32_t notConnectedCounter = 0;
while (WiFi.status() != WL_CONNECTED) {
delay(100);
Serial.println("Wifi connecting...");
notConnectedCounter++;
if(notConnectedCounter > 150) { // Reset board if not connected after 15s
Serial.println("Resetting due to Wifi not connecting...");
ESP.restart();
}
}
Serial.print("Wifi connected, IP address: ");
Serial.println(WiFi.localIP());
/**
* Enable OTA update
*/
ArduinoOTA.begin();
}
void loop() {
// Verificar solicitação de atualização over the air e (se presente) flashá-la
ArduinoOTA.handle();
}platformio.ini
Adicione a seguinte seção ao seu platformio.ini para habilitar flashing via OTA assim como flashing via serial:
extends = env:esp32dev
platformio.ini
[env:OTA]
extends = env:esp32dev
upload_protocol = espota
upload_port = 10.19.50.80
upload_flags = --host_port=55910
Check out similar posts by category:
ESP8266/ESP32 PlatformIO
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow