Minimales PlatformIO ESP32 ArduinoOTA-Beispiel
English
Deutsch
Basierend auf unserem Minimalen PlatformIO ESP8266 ArduinoOTA-Beispiel ist dies ein minimaler Ausgangspunkt für Ihr ESP32-Programm, das ArduinoOTA ausführt.
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
Fügen Sie den folgenden Abschnitt zu Ihrer platformio.ini hinzu, um Flashen via OTA sowie Flashen via Serial zu aktivieren:
extends = env:esp32dev
platformio.ini
[env:OTA]
extends = env:esp32dev
upload_protocol = espota
upload_port = 10.19.50.80
upload_flags = --host_port=55910Check 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