From b3061fa6fd4e6dc843eb4101540842e0a5bdd5c6 Mon Sep 17 00:00:00 2001 From: Serge NOEL Date: Thu, 29 Oct 2026 15:04:51 +0100 Subject: [PATCH] =?UTF-8?q?Initialisation=20d=C3=A9pot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 5 ++++ .vscode/extensions.json | 11 +++++++++ platformio.ini | 17 +++++++++++++ src/main.cpp | 54 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 87 insertions(+) create mode 100644 .gitignore create mode 100644 .vscode/extensions.json create mode 100644 platformio.ini create mode 100644 src/main.cpp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..89cc49c --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.pio +.vscode/.browse.c_cpp.db* +.vscode/c_cpp_properties.json +.vscode/launch.json +.vscode/ipch diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..a91ca8f --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,11 @@ +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "platformio.platformio-ide" + ], + "unwantedRecommendations": [ + "ms-vscode.cpptools-extension-pack", + "pioarduino.pioarduino-ide" + ] +} diff --git a/platformio.ini b/platformio.ini new file mode 100644 index 0000000..0853473 --- /dev/null +++ b/platformio.ini @@ -0,0 +1,17 @@ +[env:esp32-s3-devkitc-1] +platform = espressif32 +board = esp32-s3-devkitc-1 +framework = arduino + +monitor_speed = 115200 + +lib_compat_mode = strict +lib_deps = + ayushsharma82/NetWizard@2.0.0 + ayushsharma82/ESP-DASH@5.0.2 + ayushsharma82/ElegantOTA@4.0.0 + ayushsharma82/WebSerial@2.1.2 + +build_flags = + -D NETWIZARD_USE_ASYNC_WEBSERVER=1 + -D ELEGANTOTA_USE_ASYNC_WEBSERVER=1 diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..c9737ac --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,54 @@ +#include +#include +#include +#include +#include // NetWizard Pro: +#include +#include // ElegantOTA Pro: +#include + +AsyncWebServer server(80); + +// WiFi provisioning: captive portal at / for access point clients +NetWizard NW(&server); + +// Dashboard at /dashboard, so it does not conflict with the portal +ESPDash dashboard(server, "/dashboard", true); +dash::TemperatureCard temperature(dashboard, "Temperature"); + +unsigned long lastUpdate = 0; + +void setup() { + Serial.begin(115200); + + // Connect to the saved network, or start the captive portal + NW.setStrategy(NetWizardStrategy::BLOCKING); + NW.autoConnect("My Device", ""); + + // Over-the-air updates at /update + ElegantOTA.begin(&server); + + // Remote serial terminal at /webserial + WebSerial.begin(&server); + WebSerial.onMessage([](const String& msg) { + Serial.println(msg); + }); + + // Show the dashboard at / for clients on the local network + server.rewrite("/", "/dashboard").setFilter(ON_STA_FILTER); + + server.begin(); +} + +void loop() { + NW.loop(); + ElegantOTA.loop(); + WebSerial.loop(); + + if (millis() - lastUpdate > 3000) { + lastUpdate = millis(); + temperature.setValue((int)random(0, 50)); + dashboard.sendUpdates(); + WebSerial.println("Dashboard updated"); + } +} \ No newline at end of file