На основе нашего Минимального примера PlatformIO ESP8266 ArduinoOTA, это минимальная отправная точка для вашей ESP32-программы, запускающей 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() {
// Check for over the air update request and (if present) flash it
ArduinoOTA.handle();
}platformio.ini
Добавьте следующую секцию в ваш platformio.ini для включения прошивки через OTA, а также через последовательный порт:
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