Advertisement
RuiViana

Teste WiFI c Imagem

Feb 2nd, 2017
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.32 KB | None | 0 0
  1. #include <ESP8266WebServer.h>                                 // Bibioteca para Servidor Web ESP8266
  2. #include <ESP8266mDNS.h>                                      // Bibioteca para ..... ESP8266
  3. #include "FS.h"
  4.  
  5. MDNSResponder mdns;                                           // ......
  6. const char* ssid = "xxxxxxxxxx";                                // Use sua credenciais de rede wifi
  7. const char* password = "yyyyyyyyyyyy";
  8. ESP8266WebServer server(80);                                  // Instancia server
  9.  
  10. String Part1 = "<!DOCTYPE HTML><html><head><meta http-equiv='refresh' content='1;URL=/'/></head><style>";
  11. String Part2 = "<img src=/data/LampOff.jpg>";
  12. String Part3 = "</style></head><body><h1>Controle WiFi</h1>";
  13.  
  14. String Tela_1 = Part1 + Part2 + Part3;
  15.  
  16. String Tela_2 = "</body><html>\r\n";
  17.  
  18. String Telaf =  Tela_1 + Tela_2;
  19.  
  20. //---------------------------------------
  21. void setup(void)
  22. {
  23.   Serial.begin(115200);                                     // Inicialisa o serial port em 115200
  24.   bool result = SPIFFS.begin();             // always use this to "mount" the filesystem
  25.   WiFi.begin(ssid, password);                               // Inicialisa o wifi
  26.   Serial.println("");                                       // Imprime
  27.   while (WiFi.status() != WL_CONNECTED)                     // Aguarda conexão
  28.   {
  29.     delay(500);                                             // Delay
  30.     Serial.print(".");                                      // Imprime . enquanto não conecta
  31.   }
  32.   Serial.println("");                                       // Imprime
  33.   Serial.print("Connected to ");
  34.   Serial.println(ssid);
  35.   Serial.print("IP address: ");
  36.   Serial.println(WiFi.localIP());
  37.   if (mdns.begin("esp8266", WiFi.localIP()))                // Se ......????
  38.   {
  39.     Serial.println("MDNS responder started");               // Imprime
  40.   }
  41.   server.on("/", []()                                       // Ao requeste
  42.   {
  43.     server.send(200, "text/html", Telaf);                    // Executa o HTML Ql (Quarto ligado)
  44.   });
  45.   server.begin();                                           // Inicaliza servidor
  46.   Serial.println("HTTP server started");                    // Imprime
  47. }
  48. //--------------------------------------------------
  49. void loop(void)
  50. {
  51.   server.handleClient();                                    // Executa instancia
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement