Last active
June 12, 2024 10:40
-
-
Save maxpromer/49e2e209bbdb64df35fa5f3d54e117d4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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<WiFi.h> | |
#define WIFI_STA_NAME "xxxxxxxxxxx" | |
#define WIFI_STA_PASS "xxxxxxxxxxx" | |
WiFiServer server(80); | |
void setup() { | |
Serial.begin(115200); | |
pinMode(LED_BUILTIN, OUTPUT); | |
Serial.println(); | |
Serial.println(); | |
Serial.print("Connecting to "); | |
Serial.println(WIFI_STA_NAME); | |
WiFi.mode(WIFI_STA); | |
WiFi.begin(WIFI_STA_NAME, WIFI_STA_PASS); | |
while (WiFi.status() != WL_CONNECTED) { | |
delay(500); | |
Serial.print("."); | |
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); | |
} | |
digitalWrite(LED_BUILTIN, HIGH); | |
Serial.println(""); | |
Serial.println("WiFi connected"); | |
Serial.println("IP address: "); | |
Serial.println(WiFi.localIP()); | |
server.begin(); | |
} | |
void loop() { | |
WiFiClient client = server.available(); | |
if (client) { | |
Serial.println("new client"); | |
while (client.connected()) { | |
if (client.available()) { | |
char c = client.read(); | |
Serial.write(c); | |
} | |
delay(1); | |
} | |
client.stop(); | |
Serial.println("client disonnected"); | |
} | |
delay(10); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment