ESP 8266 HTML

Utilitaire pour traduire une page HTML en variable incorporable dans le code :

http://davidjwatts.com/youtube/esp8266/esp-convertHTM.html#

Pour ajouter la fonctionnalité de serveur web :

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>

Pour lancer le serveur :

//SSID and Password of your WiFi router
const char* ssid = « xxx »;
const char* password = « xxx »;

ESP8266WebServer server(80); //Server on port 80

Pour stocker une page html, la placer dans un fichier « .h » et l’encadrer par

const char MAIN_page[] PROGMEM = R »=====(

et

)===== »;

Pour afficher la page et lancer le serveur dans Setup :

WiFi.begin(ssid, password); //Connect to your WiFi router

while (WiFi.status() != WL_CONNECTED) {
delay(500);
}

server.on(« / », handleRoot); //Which routine to handle at root location. This is display page
server.begin(); //Start server

Avec

void handleRoot() {
String s = MAIN_page; //Read HTML contents
server.send(200, « text/html », s); //Send web page
}

Puis loop :

void loop(void){
server.handleClient(); //Handle client requests
}

Références :

https://circuits4you.com/2016/12/16/esp8266-web-server-html/

https://techtutorialsx.com/2018/01/06/esp32-arduino-http-server-serving-html-and-javascript/

https://techtutorialsx.com/2018/01/06/esp32-arduino-http-server-serving-html-and-javascript/

Articles récents
Commentaires récents
fatima dans Bienvenue !
AdminDroid dans Bienvenue !
fatima dans Bienvenue !
Archives
Catégories
%d blogueurs aiment cette page :