You know the page that pops up when you join hotel or café Wi-Fi? That's a captive portal. This project gives you one for your own ESP8266 hotspot, even on a tiny ESP-01: anyone who joins your board's Wi-Fi lands on a page you control, with games, a chat, a guestbook or a welcome screen, all served by a module that costs about two euros.
What it does
- Open mode: no login, and the captive page appears straight away. It can even play a sound.
- Login mode: visitors enter the username and password you set. It's a simple gate to your device's pages.
- Admin page at
/admin, with its own password: switch modes, change the network name, WPA2 key and guest login, edit the captive page, and manage files (upload, run, compile, delete). - Several page designs to pick from: minimal, info, event, offline, welcome. There are login styles too, including a "terms" checkbox version.
Worth knowing: an ESP8266 is an access point, not a router. It serves its own pages; it doesn't pass internet through to the visitors. That's exactly what makes it fun for offline places.
The fun part: a pocket arcade on a Wi-Fi chip
The default captive page is a games menu, served entirely by the board:
- Solo games: tic-tac-toe, 4 in a row, memory, snake, 2048, minesweeper, 15 puzzle, Simon, whack-a-mole, breakout, hangman, rock-paper-scissors, flappy, lights out and sudoku.
- Music and art: piano (turn the phone sideways for a full keyboard), drums, theremin and a drawing pad.
- Shared between phones on the same Wi-Fi:
- 2 Phones: tic-tac-toe or 4 in a row, one phone against another.
- Live chat.
- Guestbook: one note per phone every 30 seconds.
- Pixel wall: everyone paints on the same canvas.
- Quiz buzzer: the first press wins and lights the LED; the quizmaster starts each round.
- Light the box: sets the colour of a WS2812 LED on the board.
- The menu shows how many phones are connected.
Great for a party, a classroom, a camping trip, a geocache or a maker-fair stand.
Built for very little memory
On an ESP8266 running NodeMCU Lua, RAM (heap) is the scarce resource, not flash, so the whole design works around it:
- Pages are files on flash. Only tiny
{{SSID}}-style tokens are filled in, and no big HTML strings are ever built in RAM. - Large files stream in 1 KB chunks, and CSS and JS are sent pre-gzipped, about 60% fewer bytes.
- Code loads on demand: each feature and admin action is a small module loaded per request.
- Low memory doesn't crash it: when free heap runs low, the server answers "503 busy" instead of rebooting.
- Editing in small steps: the captive page is edited line by line, and MP3 uploads stream straight to flash.
Getting started
-- lua/config.lua
config.portal_ssid = "Guest-WiFi"
config.portal_ap_password = nil -- WPA2 key (8+ chars), or nil for an open network
- Flash the bundled NodeMCU firmware. The repo includes BugZapper for flashing and its Lua upload tab.
- Upload the portal files with
tools/upload.py. It minifies, gzips and compiles them on boot. - Join the network with your phone, and the portal pops up.
- Configure: open
/adminand set your own admin password first.
To reset: press RST, then hold FLASH (GPIO0) right after to clear the saved settings.
GitHub: https://github.com/gumslone/esp8266-captive-portal
Use it only on your own hotspot, for your own content. It's a welcome page and a playground, not a way to imitate someone else's network.
What would you put on your captive page? A party game, an info board for your event, or something else?
Advertise your mobile site for FREE with AdTwirl