2

I've often encountered WiFi networks that require you to sign in through a web page that automatically opens after connecting to the access point, such as hotels. I'd like to implement something similar with an ESP32, where a web page opens automatically after connecting to the AP. Is this doable? This seems to be difficult to Google, because I just get a bunch of introductory tutorials on setting up an AP.

Here's some project context in case it helps. I'm making an IoT device that needs to connect to the user's WiFi network, so the user needs to specify the login credentials. The solution I'm trying to implement is having the ESP32 set up a temporary AP, where the user can connect to that and enter their home WiFi credentials. As it stands now, the user has to manually type in the IP address of the ESP32 after connecting to the AP, but it'd be much more user friendly if the web page opened automatically like hotel WiFi networks sometimes do.

I've tinkered with this WiFi Manager library that appears to do what I want, but I'd like to implement mine from scratch.

2
  • 2
    I think you didn't find anything, because you searched for the wrong terms. What you want is a "captive Portal". I think there are some tutorials available on the web about that. Please try a search with that term. Something like "ESP32 captive portal".
    – chrisl
    Commented Sep 27, 2021 at 8:14
  • Yeah, I figured that out as I was writing the question. I decided to post it anyways, since I'm guessing others may be in the same boat as me. I've already posted an answer with that info, but thanks for the help anyways!
    – Fromen
    Commented Sep 28, 2021 at 13:23

1 Answer 1

4

Of course, as soon as I linked that WiFi Manager library in my question, I figured it out. The term I was missing was "captive portal" and I was able to figure it out from there. But I decided to post the question anyways, since it might help someone else stuck in the same situation.

Here's my understanding of how it works: when your device connects to a new network, it tries to ping a server to see whether it has internet access. With the ESP32, you can set up a DNS that redirects that ping to a web server running on the ESP32, which opens up the browser on the device.

I found this tutorial helpful for me to understand how that works, along with example code. This should be enough for me to get it working.

https://iotespresso.com/create-captive-portal-using-esp32/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.