Advertisement
Ruddog

Disappearing WiFi connection

Jan 3rd, 2018
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.21 KB | None | 0 0
  1. /////////////////////////////////
  2. // Generated with a lot of love//
  3. // with TUNIOT FOR ESP8266     //
  4. // Website: Easycoding.tn      //
  5. /////////////////////////////////
  6. #include <ESP8266WiFi.h>
  7.  
  8. IPAddress staticIP753_20(192,168,1,2);
  9. IPAddress gateway753_20(192,168,1,1);
  10. IPAddress subnet753_20(255,255,255,0);
  11.  
  12. WiFiServer server(80);
  13.  
  14. void setup()
  15. {
  16.   Serial.begin(115200);
  17.     WiFi.disconnect();
  18.   delay(3000);
  19.   Serial.println("START");
  20.    WiFi.begin("xxxxxx","xxxxxxx");
  21.   while ((!(WiFi.status() == WL_CONNECTED))){
  22.     delay(300);
  23.     Serial.print("..");
  24.  
  25.   }
  26.   Serial.println("Connected");
  27.   WiFi.config(staticIP753_20, gateway753_20, subnet753_20);
  28.   Serial.println("Your IP is");
  29.   Serial.println((WiFi.localIP()));
  30.   server.begin();
  31.  
  32. }
  33.  
  34.  
  35. void loop()
  36. {
  37.  
  38.     WiFiClient client = server.available();
  39.     if (!client) { return; }
  40.     while(!client.available()){  delay(1); }
  41.     client.flush();
  42.     client.println("HTTP/1.1 200 OK");
  43.     client.println("Content-Type: text/html");
  44.     client.println("");
  45.     client.println("<!DOCTYPE HTML>");
  46.     client.println("<html>");
  47.     client.println(analogRead(A0));
  48.     client.println("</html>");
  49.     client.stop();
  50.     delay(1);
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement