Initialisation dépot
This commit is contained in:
commit
b3061fa6fd
4 files changed
+87
No files matched your search
@@ -0,0 +1,5 @@
|
||||
.pio
|
||||
.vscode/.browse.c_cpp.db*
|
||||
.vscode/c_cpp_properties.json
|
||||
.vscode/launch.json
|
||||
.vscode/ipch
|
||||
Vendored
+11
@@ -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"
|
||||
]
|
||||
}
|
||||
@@ -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
|
||||
@@ -0,0 +1,54 @@
|
||||
#include <Arduino.h>
|
||||
#include <WiFi.h>
|
||||
#include <AsyncTCP.h>
|
||||
#include <ESPAsyncWebServer.h>
|
||||
#include <NetWizard.h> // NetWizard Pro: <NetWizardPro.h>
|
||||
#include <ESPDash.h>
|
||||
#include <ElegantOTA.h> // ElegantOTA Pro: <ElegantOTAPro.h>
|
||||
#include <WebSerial.h>
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user