Advertisement
Guest User

Untitled

a guest
Jan 17th, 2020
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. #include <ESP8266WiFi.h>
  2. // #include "DHT.h"
  3. const char* ssid ="Panda"; // Tu wpisz nazwę swojego wifi
  4. const char* password = "TurlanieSpanieJedzenie2137"; // Tu wpisz hasło do swojego wifi
  5.  
  6.  
  7. WiFiServer server(80);
  8.  
  9. void setup() {
  10. Serial.begin(115200);
  11. delay(10);
  12.  
  13.  
  14. // Connect to WiFi network
  15. Serial.println();
  16. Serial.println();
  17. Serial.print("Connecting to ");
  18. Serial.println(ssid);
  19.  
  20. WiFi.begin(ssid, password);
  21. while (WiFi.status() != WL_CONNECTED) {
  22. delay(500);
  23. Serial.print(".");
  24. }
  25.  
  26. Serial.println("");
  27. Serial.println("WiFi connected");
  28.  
  29. // Start the server
  30. server.begin();
  31. Serial.println("Server started");
  32.  
  33. // Print the IP address
  34. Serial.print("Use this URL to connect: ");
  35. Serial.print("http://");
  36. Serial.print(WiFi.localIP());
  37. Serial.println("/");
  38. }
  39.  
  40. void loop() {
  41. // Check if a client has connected
  42. WiFiClient client = server.available();
  43. if (!client) {
  44. return;
  45. }
  46.  
  47. // Wait until the client sends some data
  48. Serial.println("new client");
  49. int timewate = 0;
  50. while(!client.available()){
  51. delay(1);
  52. timewate = timewate +1;
  53. if(timewate>1800)
  54. {
  55. Serial.println(">>> Client Timeout !");
  56. client.stop();
  57. return;
  58. }
  59. }
  60.  
  61. // Read the first line of the request
  62. String request = client.readStringUntil('\r');
  63. Serial.println(request);
  64. client.flush();
  65.  
  66.  
  67. // Return the response
  68. client.println("HTTP/1.1 200 OK");
  69. client.println("Content-Type: text/html");
  70. client.println(""); // do not forget this one
  71. client.println("");
  72. client.println("");
  73. client.print("Agatka maslo kupa");
  74.  
  75. client.println("");
  76. client.println("");
  77. client.println("");
  78. client.println("");
  79. client.println("");
  80. client.println("");
  81. delay(1);
  82. Serial.println("Client disonnected");
  83. Serial.println("");
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement