SHOW:
|
|
- or go back to the newest paste.
| 1 | - | |
| 1 | + | |
| 2 | ||
| 3 | - | |
| 3 | + | const char* wifi_name = ""; //Your Wifi name |
| 4 | - | const char* wifi_name = "FRITZ!Box 7560 DN"; //Your Wifi name |
| 4 | + | const char* wifi_pass = ""; //Your Wifi password |
| 5 | - | const char* wifi_pass = "420044369429418134534"; //Your Wifi password |
| 5 | + | |
| 6 | ||
| 7 | - | |
| 7 | + | |
| 8 | Serial.begin(115200); | |
| 9 | - | Serial.begin(115200); |
| 9 | + | // Let's connect to wifi network |
| 10 | - | // Let's connect to wifi network |
| 10 | + | |
| 11 | Serial.print(wifi_name); | |
| 12 | WiFi.begin(wifi_name, wifi_pass); //Connecting to wifi network | |
| 13 | ||
| 14 | - | |
| 14 | + | |
| 15 | delay(500); | |
| 16 | Serial.print(".");
| |
| 17 | } | |
| 18 | ||
| 19 | - | |
| 19 | + | |
| 20 | Serial.println("Connection Successful");
| |
| 21 | Serial.print("IP address: ");
| |
| 22 | Serial.println(WiFi.localIP()); //Getting the IP address at which our webserver will be created | |
| 23 | Serial.println("Put the above IP address into a browser search bar");
| |
| 24 | server.begin(); //Starting the server | |
| 25 | } | |
| 26 | ||
| 27 | - | |
| 27 | + | |
| 28 | int counter=0; | |
| 29 | - | int counter=0; |
| 29 | + | |
| 30 | ||
| 31 | - | |
| 31 | + | if (client) {
|
| 32 | - | if (client) {
|
| 32 | + | |
| 33 | String currentLine = ""; //Storing the incoming data in the string | |
| 34 | while (client.connected() && client.available()) { //if there is some client data available
| |
| 35 | char c = client.read(); //read a byte | |
| 36 | Serial.print(c); | |
| 37 | ||
| 38 | - | |
| 38 | + | if (c == '\n' && currentLine.length() == 0) { //check for newline character, if line is blank it means its the end of the client HTTP request
|
| 39 | - | if (c == '\n' && currentLine.length() == 0) { //check for newline character, if line is blank it means its the end of the client HTTP request
|
| 39 | + | |
| 40 | client.print("<body><h1>Hello World</h1><br />");
| |
| 41 | client.print("Die Temperatur beträgt: " + String(++counter) + " </body>");
| |
| 42 | - | client.print("Die Temperatur beträgt: " + std::string(++counter) + " </body>");
|
| 42 | + | |
| 43 | } else if (c != '\r') {
| |
| 44 | currentLine += c; //if you got anything else but a carriage return character, | |
| 45 | } else {
| |
| 46 | - | } else {
|
| 46 | + | |
| 47 | } | |
| 48 | } | |
| 49 | delay(1000); | |
| 50 | - | delay(1000); |
| 50 | + | |
| 51 | delay(2000); | |
| 52 | } |