Skip to content

Instantly share code, notes, and snippets.

@dhavlik
dhavlik / captive_portal.ino
Last active May 21, 2019 15:09
short example for esp8266 - run in ap mode and reply with a static page to every request with a simple dns trick - this leads to a captive portal being displayed on most clients directly after connecting to the ap.
#include <ESP8266WiFi.h>
#include <DNSServer.h>
#include <ESP8266WebServer.h>
const byte DNS_PORT = 53;
IPAddress apIP(192, 168, 1, 1);
DNSServer dnsServer;
ESP8266WebServer webServer(80);