-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmakesmart_basic_wifi_project.ino
50 lines (38 loc) · 1.09 KB
/
makesmart_basic_wifi_project.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
ESP8266WebServer server(80);
const char* ssid = "wlan_ssid";
const char* password = "wlan_password";
// following for the name of: http://name_esp.local/
const char* dns_name = "name_esp";
void setup()
{
Serial.begin(115200);
Serial.println("ESP Gestartet");
WiFi.begin(ssid, password);
Serial.print("Verbindung wird hergestellt ...");
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println();
Serial.print("Verbunden! IP-Adresse: ");
Serial.println(WiFi.localIP());
if (MDNS.begin(dns_name)) {
Serial.println("DNS gestartet, erreichbar unter: ");
Serial.println("http://" + String(dns_name) + ".local/");
}
server.onNotFound([](){
server.send(404, "text/plain", "Link wurde nicht gefunden!");
});
server.on("/", []() {
server.send(200, "text/plain", "ESP-Startseite!");
});
server.begin();
Serial.println("Webserver gestartet.");
}
void loop() {
server.handleClient();
}