I'm trying to create a Captive Portal on my Arduino UNO R4 WiFi.
I have no problems creating the Access Point and accessing it from my phone's browser.
Additionally, there is a nice description available at Arduino's WiFi Examples (https://docs.arduino.cc/tutorials/uno-r4-wifi/wifi-examples/ ).
However, I need to implement a Captive Portal.
This means that when I choose the wireless network to connect to and input its password, I should be automatically redirected to a page where I can enter my SSID and password.
I tried using WiFiManager.h (WiFiManager by tzapu), but:
The WiFiManager library claims to support only ESP8266 and ESP32 architectures.
It may not be compatible with my current board, which uses the Renesas_UNO architecture.
I couldn't find any library for this functionality.
Does anyone have a solution?
The "Captive" part requires a DNS server. It lies to every connected device, saying that whatever site they actually want is at the same hard-coded IP (usually of the AP itself), which in turn will serve the "Portal" page. For a hotel WiFi, it would prompt for your room number.
In your use case, the R4 will already have done a WiFi scan to find all the legit APs, and generate a page with a form. Submitting that form will then do a WiFi.begin with the chosen AP/SSID and password.
ESP32 and ESP8266 both have a DNSServer library. Each has a simple captive portal -- first paragraph above -- as an example. The ESP8266 also has a more advanced one that does the second paragraph. The hard part might be adapting the DNSServer class of either to the R4.
Create the Access Point: Already created the Access Point (AP) and hosting the configuration page, which is a good start. You'll be using the Arduino UNO R4 WiFi as the AP, serving the Captive Portal page (a form to configure the WiFi credentials).
DNS Spoofing (Captive Portal DNS Server): The core of a captive portal is the DNS spoofing. When a device connects to AP and tries to browse the web, it will be directed to the portal page. This can be achieved by setting up a DNS server that intercepts all DNS requests and redirects them to the AP's IP address.
Since the board doesn’t have native support for a DNSServer (like ESP32 or ESP8266), we might have to implement it manually.
Redirection to the Portal Page: Once the user connects to the AP, any HTTP request to any domain (e.g., google.com) will be redirected to the IP address of the AP. At that point, the AP serves the Captive Portal page, where the user can input the SSID and password for the desired WiFi network.
Handle the Form Data: After the user enters the SSID and password in the form and submits it, Arduino will attempt to connect to the specified network using the provided credentials.
Redirect the User After Setup: After the WiFi connection attempt is made (success or failure), we should redirect the user to a page indicating whether the connection was successful or not.
Summary: I need to implement manually a new WiFiManager.h
Is this correct?