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
51
52
53
Enable usb: sudo chmod a+rw /dev/ttyUSB0
Additional board manager url: https://arduino.esp8266.com/stable/package_esp8266com_index.json
Board Manager: esp8266
Select board: Tools > Board > ESP8266 Boards > LOLIN(WEMOS) D1 mini (clone).
Select port
Code:
#include <ESP8266WiFi.h>
#include <DNSServer.h>
#include <ESP8266WebServer.h>
const byte DNS_PORT = 53;
IPAddress apIP(172, 217, 28, 1);
DNSServer dnsServer;
ESP8266WebServer webServer(80);
String responseHTML = "<!DOCTYPE html>"
"<html>"
"<head>"
"<title>YO WAT</title>"
"</head>"
"<body>"
"<p>18 * 5/6</p>"
"</body>"
"</html>";
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
WiFi.mode(WIFI_AP);
WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
WiFi.softAP("FRACTRAN 95");
dnsServer.start(DNS_PORT, "*", apIP);
webServer.onNotFound([]() {
webServer.send(200, "text/html", responseHTML);
digitalWrite(LED_BUILTIN, LOW);
delay(500);
digitalWrite(LED_BUILTIN, HIGH);
});
webServer.begin();
}
void loop() {
if (WiFi.softAPgetStationNum() == 0) {
delay(100);
} else {
delay(100);
dnsServer.processNextRequest();
webServer.handleClient();
}
}