PlatformIO ESP32 mit ESP-IDF minimales C++-Beispiel
Standardmäßig wird beim Initialisieren eines PlatformIO-ESP-IDF-Projekts main.c generiert – keine C++-, sondern eine reine C-Datei
Dieses minimale Beispiel verwendet stattdessen main.cpp (Sie können einfach Ihre main.c umbenennen – siehe Wie man C++ main.cpp mit PlatformIO auf ESP32 / esp-idf verwendet für eine detaillierte Liste der Schritte).
main.cpp
#include <cstdio>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
extern "C" {
void app_main(void);
}
void app_main() {
while(true) {
printf("Hello PlatformIO!\n");
// Wait for one second
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}Check out similar posts by category:
C/C++, 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