Last active
October 28, 2019 20:09
-
-
Save thingforward/ffe0409ca580e3342010336eed6ade1c to your computer and use it in GitHub Desktop.
ESP8266 WiFiServer Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Arduino.h> | |
#include <ESP8266WiFi.h> | |
const char* ssid = "ThingForwardWiFi"; | |
const char* password = "thingforwardiot"; | |
WiFiServer server(3000); | |
void setup() { | |
Serial.begin(9600); | |
WiFi.mode(WIFI_STA); | |
WiFi.begin(ssid, password); | |
while ( WiFi.status() != WL_CONNECTED) { | |
Serial.print("."); | |
delay(100); | |
} | |
Serial.println(WiFi.localIP()); | |
server.begin(); | |
} | |
void loop() { | |
WiFiClient client = server.available(); | |
if (!client) { return; } | |
while(!client.available()) { | |
delay(10); | |
} | |
String req = client.readStringUntil('\r'); | |
Serial.println(req); | |
client.flush(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment