How to set up an ESP8266 access point with a guest login

What I want is to create an access point to which I can log in privately, but also where guests can log in with separate passwords.
Now I use the code below, but when I use it I only see 'GuestNetwork' and not 'MyNetwork' when I log in to my WiFi.
Is there a way to get this done?

#include <ESP8266WiFi.h>

const char* ssid = "MyNetwork";
const char* password = "password123";

const char* guestSsid = "GuestNetwork";
const char* guestPassword = "guestpassword456";

void setup() {
  Serial.begin(115200);
  
  WiFi.softAP(ssid, password);
  delay(100);  // Wait briefly to ensure the first network is set up before configuring the second one
  WiFi.softAP(guestSsid, guestPassword);
  WiFi.softAPConfig(IPAddress(192, 168, 1, 1), IPAddress(192, 168, 1, 1), IPAddress(255, 255, 255, 0));
  
  Serial.println("Access Points started");
}

void loop() {
  // Add any additional functionality here
  
  delay(1000);  // Prevent CPU overload
}

you can only set up one access point with your ESP.
(So in your code the first one is overwritten by the second call to WiFi.softAP())

That's a shame, is there no solution for it, or is it a hardware problem?

I’m not aware of a solution

What do you think there is to win having two SSIDs ? You could handle sessions in your code to separate admin capabilities from normal users.

it is for a gate, I have the WiFi connection on my phone set to memorized and when I come close and unlock my phone, the gate is unlocked and that works well and I want I'd like to keep it that way.

Now I want guests with a code to be able to enter. and to be able to distinguish guests from admin without knowing MAC addresses, I thought I would do it that way.

ESP8266 start at $3. Just use a second one configured for the guests.
Same amount of SSIDs.

So simply connecting to the WiFi opens the gate?

How about using a small website where a code must be entered.

1 Like

You can add a password to the webserver. You have 1 AP with the same password, all can log onto, bit to access the webpages you need to enter a username + password. You ca in that way also set permissions fir different users.

1 Like

I think a web server is unfortunately my only solution.

why can't you get a second ESP? that was a good idea

Yes, the idea is certainly a good one, but the design is with an ESP-01 and I can still connect one via software serial, but I have very little space in that pillar and I also want to keep it neat.

you could take two ESP32 and you would heavily simplify your design... No need for a Nano + voltage adaptation + ESP01.

Some ESP32 have a builtin SD slot as well but if you don't need to remove the SD card, you could leverage the ESP32 flash drive to store information and get rid of the SD altogether...

You can really find small footprints, for example an XIAO ESP32C3 is pretty damn small...

The Web Server suggestions sound much better than adding extra hardware. Trouble is, @mark1971 is fixated on the Dual SSID idea.

I am now adjusting the code, WiFi without password, with WiFi connection it automatically goes to an HTML login page, where 1 password applies to the main user and 1 for the guest. let's see if I can make the password so that my phone can also save it, then it actually works as I thought without changing the hardware

thanks guys

There is a risk involving an open access point, being that the amount of devices connected is limited to 8, and that many phone will automatically connect to it, considering it a hotspot. That may not apply in your case, but it is information i want to add.

The issue is that it is actually your browser that needs to save it. (on desktop Chrome it can be done) But the good news is that the length is undefined, a 4 digit pin will also work (unlike wifi which requires a minimum of 8 characters)

1 Like

Not sure for Android (but I guess it’s the same) and definitely not the case with iOS.

You don’t join random unknown open networks just by walking around them. That would be a major security risk.

The SDID would need to be known and that entry trusted and the phone configured for auto connect.

Logging in with a laptop and remembering the password is no problem and he will be redirected immediately, I have not tried with Android. but iOS is indeed a problem. I'm still testing...

I would not call keeping you secure a problem :slight_smile:

You expect guests to enter a password anyway, so create a captive portal for your ESP32 and on various devices it will present a configuration dialogue as soon as you connect to the created access point. You can use GitHub - tzapu/WiFiManager: ESP8266 WiFi Connection manager with web captive portal for this.

1 Like

I (we) just experienced that open access points became in-accessible to us when there was a significant crowd at parties and festivals, which of course is hugely unpractical, so we switched to password protected SSID's My conclusion was that the 8 connecting devices were not one of ours anymore.

that could have been people actively/willingly trying to join your network in the hope of getting free internet access.. could be hackers too...

Also when there is a huge crowd, the 2.4Ghz band becomes quite saturated making it challenging to do anything with WiFi.

I am still programming and have certainly taken the security connections seriously, so I have a WiFi connection with a password, an HTML password for admin and guests with passwords stored in the memory of the ESP8266 so that they cannot be accessed from the HTML code. can be seen.

The only problem in the iPhone that does not want to automatically save and fill in the passwords. but I'm not ready and I don't plan on giving up. I will share how the codes are structured this week, then everything will be a lot clearer for everyone to think about. In any case, I thank everyone for their input so far.