-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dc5ee9c
commit b45234f
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include <ESP8266WiFi.h> | ||
#include <ESP8266WebServer.h> | ||
#include <ESP8266NetBIOS.h> | ||
|
||
const char* ssid = "............"; | ||
const char* password = ".............."; | ||
|
||
ESP8266WebServer wwwserver(80); | ||
String content; | ||
|
||
static void handleRoot(void) { | ||
content = F("<!DOCTYPE HTML>\n<html>Hello world from ESP8266"); | ||
content += F("<p>"); | ||
content += F("</html>"); | ||
|
||
wwwserver.send(200, F("text/html"), content); | ||
} | ||
|
||
void setup() { | ||
Serial.begin(115200); | ||
|
||
// Connect to WiFi network | ||
WiFi.mode(WIFI_STA); | ||
WiFi.begin(ssid, password); | ||
Serial.println(""); | ||
|
||
// Wait for connection | ||
while (WiFi.status() != WL_CONNECTED) { | ||
delay(500); | ||
Serial.print("."); | ||
} | ||
Serial.println(""); | ||
Serial.print("Connected to "); | ||
Serial.println(ssid); | ||
Serial.print("IP address: "); | ||
Serial.println(WiFi.localIP()); | ||
|
||
|
||
wwwserver.on("/", handleRoot); | ||
wwwserver.begin(); | ||
|
||
NBNS.begin("ESP"); | ||
} | ||
|
||
void loop() { | ||
wwwserver.handleClient(); | ||
} |