Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ESP8266WebServer.h> // Bibioteca para Servidor Web ESP8266
- #include <ESP8266mDNS.h> // Bibioteca para ..... ESP8266
- #include "FS.h"
- MDNSResponder mdns; // ......
- const char* ssid = "xxxxxxxxxx"; // Use sua credenciais de rede wifi
- const char* password = "yyyyyyyyyyyy";
- ESP8266WebServer server(80); // Instancia server
- String Part1 = "<!DOCTYPE HTML><html><head><meta http-equiv='refresh' content='1;URL=/'/></head><style>";
- String Part2 = "<img src=/data/LampOff.jpg>";
- String Part3 = "</style></head><body><h1>Controle WiFi</h1>";
- String Tela_1 = Part1 + Part2 + Part3;
- String Tela_2 = "</body><html>\r\n";
- String Telaf = Tela_1 + Tela_2;
- //---------------------------------------
- void setup(void)
- {
- Serial.begin(115200); // Inicialisa o serial port em 115200
- bool result = SPIFFS.begin(); // always use this to "mount" the filesystem
- WiFi.begin(ssid, password); // Inicialisa o wifi
- Serial.println(""); // Imprime
- while (WiFi.status() != WL_CONNECTED) // Aguarda conexão
- {
- delay(500); // Delay
- Serial.print("."); // Imprime . enquanto não conecta
- }
- Serial.println(""); // Imprime
- Serial.print("Connected to ");
- Serial.println(ssid);
- Serial.print("IP address: ");
- Serial.println(WiFi.localIP());
- if (mdns.begin("esp8266", WiFi.localIP())) // Se ......????
- {
- Serial.println("MDNS responder started"); // Imprime
- }
- server.on("/", []() // Ao requeste
- {
- server.send(200, "text/html", Telaf); // Executa o HTML Ql (Quarto ligado)
- });
- server.begin(); // Inicaliza servidor
- Serial.println("HTTP server started"); // Imprime
- }
- //--------------------------------------------------
- void loop(void)
- {
- server.handleClient(); // Executa instancia
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement