Ajout README.md
This commit is contained in:
1 parent
b3061fa6fd
commit
644e2363f7
5 files changed
+160
-86
No files matched your search
+5
-5
@@ -1,5 +1,5 @@
|
||||
.pio
|
||||
.vscode/.browse.c_cpp.db*
|
||||
.vscode/c_cpp_properties.json
|
||||
.vscode/launch.json
|
||||
.vscode/ipch
|
||||
.pio
|
||||
.vscode/.browse.c_cpp.db*
|
||||
.vscode/c_cpp_properties.json
|
||||
.vscode/launch.json
|
||||
.vscode/ipch
|
||||
Vendored
+11
-11
@@ -1,11 +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"
|
||||
]
|
||||
}
|
||||
{
|
||||
// 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,74 @@
|
||||
# ESPTest
|
||||
|
||||
ESPTest est un exemple de firmware Arduino pour une carte **ESP32-S3 DevKitC-1**. Il configure le Wi-Fi, démarre un serveur web et met à disposition un tableau de bord avec une température simulée, une mise à jour du firmware par OTA et un terminal série accessible depuis le navigateur.
|
||||
|
||||
## Fonctionnalités
|
||||
|
||||
- **Configuration Wi-Fi** avec NetWizard : l'appareil se connecte au réseau mémorisé ou démarre le portail de configuration « My Device ».
|
||||
- **Tableau de bord** ESP-DASH affichant une valeur de température simulée, actualisée toutes les trois secondes.
|
||||
- **Mise à jour OTA** avec ElegantOTA.
|
||||
- **Terminal série web** avec WebSerial. Les messages reçus dans le terminal sont également écrits sur le port série USB.
|
||||
- **Serveur web asynchrone** sur le port 80.
|
||||
|
||||
## Matériel et prérequis
|
||||
|
||||
- Une carte ESP32-S3 DevKitC-1.
|
||||
- [Visual Studio Code](https://code.visualstudio.com/) avec l'extension [PlatformIO IDE](https://platformio.org/install/ide?install=vscode), ou PlatformIO Core en ligne de commande.
|
||||
- Un câble USB adapté à la carte.
|
||||
- Un navigateur sur un appareil connecté au même réseau local que l'ESP32 pour accéder au tableau de bord.
|
||||
|
||||
Les bibliothèques nécessaires sont déclarées dans [`platformio.ini`](./platformio.ini) et PlatformIO les installe lors de la compilation.
|
||||
|
||||
## Compiler et téléverser
|
||||
|
||||
### Avec Visual Studio Code
|
||||
|
||||
1. Ouvrir le dossier du projet dans VS Code.
|
||||
2. Laisser PlatformIO installer les dépendances.
|
||||
3. Connecter la carte en USB.
|
||||
4. Utiliser les actions PlatformIO **Build**, puis **Upload**.
|
||||
5. Ouvrir le moniteur série à **115200 bauds** pour suivre le démarrage.
|
||||
|
||||
### En ligne de commande
|
||||
|
||||
Depuis la racine du projet :
|
||||
|
||||
```sh
|
||||
pio run -e esp32-s3-devkitc-1
|
||||
pio run -e esp32-s3-devkitc-1 -t upload
|
||||
pio device monitor -b 115200
|
||||
```
|
||||
|
||||
Si plusieurs ports série sont disponibles, sélectionner celui de la carte dans les paramètres de PlatformIO ou préciser le port avec `--port`.
|
||||
|
||||
## Première connexion et utilisation
|
||||
|
||||
1. Après démarrage, l'ESP32 se connecte au Wi-Fi mémorisé. Si aucun réseau enregistré n'est disponible, il lance le portail de configuration NetWizard nommé **My Device**.
|
||||
2. Depuis un téléphone ou un ordinateur, rejoindre le point d'accès de configuration et suivre le portail pour fournir les identifiants du réseau Wi-Fi.
|
||||
3. Une fois l'ESP32 connecté au réseau local, repérer son adresse IP dans le moniteur série ou dans la liste des appareils du routeur.
|
||||
4. Ouvrir `http://<adresse-ip-de-l-esp32>/` dans un navigateur. La racine redirige vers le tableau de bord. Son URL directe est `http://<adresse-ip-de-l-esp32>/dashboard`.
|
||||
|
||||
Autres interfaces :
|
||||
|
||||
| Chemin | Fonction |
|
||||
| --- | --- |
|
||||
| `/dashboard` | Tableau de bord et valeur de température simulée |
|
||||
| `/update` | Interface de mise à jour du firmware par OTA |
|
||||
| `/webserial` | Terminal série dans le navigateur |
|
||||
|
||||
L'interface OTA et le terminal WebSerial sont accessibles depuis le réseau local de l'appareil. Pour les mises à jour OTA, utiliser un firmware compilé pour cette carte et suivre les indications de l'interface.
|
||||
|
||||
## Structure du projet
|
||||
|
||||
```text
|
||||
.
|
||||
├── platformio.ini # Carte, framework, dépendances et options de compilation
|
||||
└── src/
|
||||
└── main.cpp # Initialisation Wi-Fi et serveur, boucle et mise à jour du tableau de bord
|
||||
```
|
||||
|
||||
## Configuration et personnalisation
|
||||
|
||||
- La carte cible, le débit série, les bibliothèques et les options de compilation se configurent dans [`platformio.ini`](./platformio.ini).
|
||||
- Le nom du point d'accès, les routes web et la fréquence d'actualisation du tableau de bord se trouvent dans [`src/main.cpp`](./src/main.cpp).
|
||||
- La température affichée est générée aléatoirement entre 0 et 49 ; elle ne provient pas d'un capteur physique.
|
||||
+17
-17
@@ -1,17 +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
|
||||
[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
|
||||
+53
-53
@@ -1,54 +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");
|
||||
}
|
||||
#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