Skip to content

Instantly share code, notes, and snippets.

@thingforward
Last active October 28, 2019 20:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thingforward/ffe0409ca580e3342010336eed6ade1c to your computer and use it in GitHub Desktop.
Save thingforward/ffe0409ca580e3342010336eed6ade1c to your computer and use it in GitHub Desktop.
ESP8266 WiFiServer Example
#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