You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ESP32 Captive Portal (think airport wifi sign in page) example that works on all devices (or that's the goal).
7
5
8
-
When you connect to the wifi "captive" password "12345678" it should take you straight to <http://4.3.2.1/> and display a green page with some simple text.
6
+
A ESP32 Captive Portal written in Arudino C++ (think airport wifi sign in page) demo that works on all devices[^1].
7
+
8
+
## ⚙️ Features
9
+
```
10
+
RAM: [= ] 11.6% (used 37976 bytes from 327680 bytes)
11
+
Flash: [== ] 22.6% (used 711089 bytes from 3145728 bytes)
12
+
```
13
+
- about 0.1s reload time using modern browsers and systems
14
+
- Lots of comments that explain how it all works
15
+
16
+
## 🖼️ User interface
17
+

18
+
19
+
## 📲 Quickstart with ESP Home Flasher tool on Windows, MacOS and Linux
20
+
21
+
This is a simple all in one GUI tool that can be downloaded from here: <https://github.com/esphome/esphome-flasher/releases/>
22
+
23
+
Download the firmware from the releases page and chuck it in select the serial port from the dropdown and press flash ESP
24
+
25
+
If running Windows , you will most likely need a driver from here: <https://www.wemos.cc/en/latest/ch340_driver.html> before your computer will show the ESP32 com port in the drop down menu in ESPhome Flasher.
26
+
27
+
### Compile yourself using PlatformIO
28
+
29
+
- Make sure Git client is installed on your system. https://github.com/git-guides/install-git
30
+
- Download and install Visual Studio Code by Microsoft. https://code.visualstudio.com/download
31
+
- Open Visual Studio Code and go to the Extensions manager (the icon with the stacked blocks in the left bar)
32
+
- Search for platformio and install the PlatformIO extension
33
+
- Download the source code by running a git clone (git gui can be found in your right click menu) with the link: https://github.com/CDFER/Captive-Portal-ESP32.git in your projects folder.
34
+
- In VS Code Go to File -> Open Folder and open that root folder (the one that contains platformio.ini, NOT the src folder)
35
+
- Upload to the esp32 using the right arrow button in the bottom left corner of vs code (it takes awhile for the first compile)
36
+
37
+
38
+
## Testing Status
9
39
10
40
| Status | Version | Connect | Popup | Serve Page | OS | Device Name | Browser | Notes |
## Quickstart with ESP Home Flasher tool on Windows, MacOS and Linux
30
-
31
-
This is a simple GUI-based tool that can be downloaded from here: <https://github.com/esphome/esphome-flasher/releases/>
32
-
33
-
If running Windows, you will most likely need a driver from here: <https://www.wemos.cc/en/latest/ch340_driver.html> before your computer will show the COM port in ESPhome Flasher.
34
-
35
-
## Did it work?
59
+
### Did it work?
36
60
37
61
If you test this code on a device (even if it works) it would be really helpful if you fill out the form here: <https://forms.gle/ArLPTnwRA3QGTKyc6>
38
62
63
+
39
64
## Known Bugs/limitations with current version
40
65
41
66
- Oneplus 6 phone (Oxygen OS 11) sometimes gets stuck on setting client side IP address when cellular is on
42
67
- On older devices you may need to open a web browser for it to display
43
68
- max of 4 clients connected at the same time
44
69
- MacOS post macOS Big Sur no pop up
45
70
71
+
46
72
### Further testing required
47
73
48
74
- If you have a lot of tabs open in Windows 11 (and probably other OS) it increases the load on the ESP32 DNS server.
49
75
- HTML Webpage being served multiple times
50
76
- Other ESP32 chip variants (all testing so far is on the ESP32 D0WDQ6 chip in the ESP32S module)
51
77
- Test increasing the max clients connected up from 4 to max supported 10
52
78
79
+
53
80
### Future Dev Options to look into (Help or suggestions are appreciated):
54
81
55
82
- Set client DHCP IP address range in private space (currently clients must accept DHCP Server Range: 4.3.2.2 to 4.3.2.12)
56
83
- Support integrating the DHCP or IPv6 Router Advertisement (RA) options for Captive Portals on iOS 14+ and macOS Big Sur+ https://developer.apple.com/news/?id=q78sq5rv
57
84
- Port https://github.com/Aircoookie/WLED-WebInstaller
const IPAddress localIP(4, 3, 2, 1); // the IP address the web server, Samsung requires the IP to be in public space
28
-
const IPAddress gatewayIP(4, 3, 2, 1); // IP address of the network
29
-
const IPAddress subnetMask(255,255,255,0);
31
+
const IPAddress gatewayIP(4, 3, 2, 1); // IP address of the network should be the same as the local IP for captive portals
32
+
const IPAddress subnetMask(255,255,255,0); //no need to change: https://avinetworks.com/glossary/subnet-mask/
33
+
34
+
const String localIPURL = "http://4.3.2.1"; //a string version of the local IP with http, used for redirecting clients to your webpage
30
35
31
-
const String localIPURL = "http://4.3.2.1";
32
36
37
+
//WARNING IOS (and maybe macos) WILL NOT POP UP IF IT CONTAINS THE WORD "Success" https://www.esp8266.com/viewtopic.php?f=34&t=4398
38
+
//SAFARI (IOS) there is a 128KB limit to the size of the HTML. The HTML can reference external resources/images that bring the total over 128KB
39
+
//SAFARI (IOS) popup browser has some severe limitations (javascript disabled, cookies disabled, no .gz extension (even though gzip files are supported))
33
40
constchar index_html[] PROGMEM = R"=====(
34
41
<!DOCTYPE html> <html>
35
42
<head>
@@ -56,11 +63,11 @@ void setup(){ //the order of the code is important and it is critical the the an
server.on("/wpad.dat",[](AsyncWebServerRequest *request){request->send(404);}); //Honestly don't understand what this is but a 404 stops win 10 keep calling this repeatedly and panicking the esp32 :)
82
90
83
-
//Probably not all are Required, but some are. Others might speed things up?
84
-
server.on("/canonical.html",[](AsyncWebServerRequest *request){request->redirect(localIPURL);}); //firefox captive portal call home
85
-
server.on("/chrome-variations/seed",[](AsyncWebServerRequest *request){request->send(200);}); //chrome captive portal call home
server.on("/success.txt",[](AsyncWebServerRequest *request){request->send(200);}); //firefox captive portal call home
88
-
server.on("/wpad.dat",[](AsyncWebServerRequest *request){request->send(404);}); //Honestly don't understand what this is but a 404 stops win 10 keep calling this repeatedly and panicking the esp32 :)
//Serve Basic HTML Page WARNING IOS (and maybe macos) WILL NOT POP UP IF THIS PAGE CONTAINS THE WORD "Success" https://www.esp8266.com/viewtopic.php?f=34&t=4398
0 commit comments