Connect to Mult-Wifi (Hidden SSID) using Blynk on esp8266

Hey ,

I wanted to connect my esp8266 (Nodemcu using Arduino IDE) to Multiple available Access points using Blynk . Searched for it and came across this. It has exactly what i need that is connecting to multi-wifi using blynk ,but the problem is the I’ve kept 2 of SSID’s as hidden and 1 as visible. The tutorial mentioned can connect to non-hidden SSID’s easliy but doesn’t work with hidden SSID’s.I’ve tried giving overload function WiFi.scanNetworks(async, show_hidden) like the one mentioned in this doc but still it doesn’t connect .it always loops in a wifi search . tried commenting on that tutorial but never got any solutions for it.All i want is that the esp8266 gets connected to the SSID which has the best signal,incase if anyone of them fails.also a bit confused on using Wifi.begin() for using Multi-wifi library when i’m using Blynk.begin(). :confused:
It’ll be very helpful if somebody can show me how it can be achieved.
Also this is my first Post here,kindly bear with me. :smile:

It’s good that you’ve done some research before posting. You can sharpen the most powerful tool in learning (searching, researching) by using the correct search topics. For example in this forum you can see MultiWiFi MultiBlynk topics:

and many many more discussing similar things.

RE: Hidden WiFi SSID, there are many limitations as you can’t scan and show hidden SSID (that’s the main purpose). You have to know exactly the hidden SSID/PW to input.


Sorry for the late reply . Thank you for the insight. :raised_hands: I went through the two above mentioned links and found out that both do not meet the requirements. The second one only works for ESP32 !!
Btw,I exactly know my SSID/PW (hidden) :stuck_out_tongue:

My only requirement is that it should connect to any one of the hidden SSID’s that i’ve pre-configured in sketch,not passing it through some GUI ,as it is for remote home automation .
Could anyone please Help me find the solution to this :confused:

What makes you think that?

If you want to connect to the hidden SSID with the best signal strength then you’ll need to connect to them in turn and check the RSSI readings. If the one you are currently connected to is better than the first one you tried then continue with that, otherwise disconnect and re-connect to the first one.

Personally, I’d give both hidden networks the same SSID and password and just connect to it. The ESP will take care of connecting to the strongest access point.


What makes you think that?

Because I saw this as the first line in examples.

#ifndef ESP32
#error This code is intended to run on the ESP32 platform! Please check your Tools->Board setting.

Personally, I’d give both hidden networks the same SSID and password and just connect to it

I’ve tried that too, but unfortunately I’m ending up in a network loop (maybe my router doesn’t allow multiple access points with the same name, I know ideally it shouldn’t happen but that’s what I’ve observed). That’s why i had to give different names to my access points but now i don’t have redundancy if any access point breaks down. Forget connecting to the best signal strength ,i just want it to connect it to any available SSID that I’ve preconfigured in the sketch.

Yes, in the ESP32 examples. But if you look at the ESP8266 examples you’ll see:

#ifndef ESP8266
#error This code is intended to run on the ESP8266 platform! Please check your Tools->Board setting.

Is your second access point set-up as a DCHP server?

There’s quite a few topics on hard-coding multiple SSIDs, maybe this is the simplest to run with…


Yes, in the ESP32 examples. But if you look at the ESP8266 examples you’ll see:

Sorry very neglectful of me :sweat_smile:

Is your second access point set-up as a DCHP server?

Initially upon first encountering the issue , I found out that indeed it was ,but upon removing the DHCP function from the one of the access points still I’m face Network Loop issue If i have the same SSID/pw for all my access points.Went on a google spree trying to find a solution for it but couldn’t find a thing for my particular setup, so ended up giving different credentials to the access points and now have no redundancy :grimacing:

There’s quite a few topics on hard-coding multiple SSIDs, maybe this is the simplest to run with…

I’ll try this with my test setup and see if it works (particularly with hidden SSID) :sweat_smile:

I guess it depends on the type of WAP. I have 4 wired WAPs in addition to my router, all using the same SSID and password, to provide total coverage for the house and garden.
Wireless repeater WAPs tend to be more difficult to configure to work on a single SSID, although some of the Netgear Nighthawk routers do allow ‘single SSID’ usage, but I’m not sure if this applies to hidden SSIDs.


Ok , I tried this on my test sketch and I’m happy to report that this indeed works, with hidden SSID’s too !! :raised_hands:

My only gripe is this :sweat_smile:

while (!Blynk.connected() && ssid_count<ssid_mas_size);
if (!Blynk.connected() && ssid_count==ssid_mas_size) {
Serial.println("I could not connect to blynk =( Ignore and move on. but still I will try to connect to wi-fi " + String(ssid[ssid_count-1]));

with this,even if it doesn’t connect to Blynk Servers it stays connected to that Access point (“Ignore and move on. but still I will try to connect to wi-fi”) . Somewhat defeating the whole purpose of redundancy (Connect to the access point that has internet connectivity or else try the next one ).Any ideas for this ?

You could use Blynk.connected to see if you are connected to Blynk:

If not, then do a wifi disconnect and re-connect to the other SSID.

Or, you could ping a website (the Blynk server or maybe) to see if you are connected to the internet and if not then switch to your alternate WiFi connection.

As I said, the code I linked to was a starting point for you to run with.


Can Someone please help me with this? :sweat_smile:

So you didn’t like any of my suggestions from 27th April?


Hey ,

Running a basic home automation setup with ep8266(nodemcu),referring to my post regarding connecting to multiple ssids in case of a WiFi failure, came across this post , been running this for a while now and facing a issue where the esp8266 still is connected to the internet but looses connection to blynk server(as it still continues to get the time from ntp meaning the internet is still connected). The code runs fine for a day or two and all of a sudden goes offline for almost an entire day,is this because of a possible flood error(& yes my void loop() is clean AF with just;; ) How to determine if anything is causing a flood error? I am sending around 20 values(mostly weather stuff) via blynk every 5 seconds or so. Btw, i have a timer for resetting the esp twice a day and sometimes even after resetting blynk doesn’t get connected but it gets the time via ntp rather fine . Is something wrong in the connecting to blynk process in this code? is checking Blynk.connected(); every minute a bad practice?

Little snippet of my code:

  void setup()
  // Debug console
  WiFi.softAPdisconnect (true);


  timer5 = timer.setInterval(60000L, MultyWiFiBlynkBegin);

  Serial.print("Connecting to the Internet ");
  Serial.print("Connecting Now...");  
  Serial.println("Successfully Connected to the Internet ");
  Serial.print("NodeMCU IP Address : ");
  Serial.println(WiFi.localIP() );
  Serial.println("Channel : " + String(;
  configTime(timezone, dst, "","");
  Serial.println("\nWaiting for Internet Time");

  Serial.println("\nSyncing Time Now..."); 

void MultyWiFiBlynkBegin() {
  int ssid_count=0;
  int ssid_mas_size = sizeof(ssid) / sizeof(ssid[0]);
  do {
    if (!Blynk.connected())  {
    digitalWrite(D8,LOW);// power to router
    Serial.print("\n" );
    Serial.println("Trying to connect to WiFi " + String(ssid[ssid_count]));
    WiFi.begin(ssid[ssid_count], pass[ssid_count]);    
    int WiFi_timeout_count=0;
    while ((WiFi.status() != WL_CONNECTED) && (WiFi_timeout_count<50)) { //waiting 10 sec
    if (WiFi.status() == WL_CONNECTED)  {
      Serial.print("\n" );
      Serial.println("Connected to WiFi! WiFi SSID = "+ String(ssid[ssid_count])+"!");
      Serial.println("Checking connection to Blynk server");
      Blynk.connect(); //for waiting 5 sec Blynk.connect(5000);
      int quality = getQuality();
  while (!Blynk.connected() && ssid_count<ssid_mas_size);
  if (!Blynk.connected() && ssid_count==ssid_mas_size) {
    Serial.print("\n\n" );
    Serial.println("Could not connect to Blynk =( Retrying!! Please Wait .....");

I’ve moved this post to your original topic, as it’s really just a continuation of the same subject.

More accurately, I provided you a link to that post and suggested that it could be a good starring point.

Code snippets are useful in some cases, but in this case I don’t think that the code you’ve provided helps anyone to assist you with resolving your issue(s).

No, not based on the snippet of code you’ve provided (but as that isn’t the complete picture then its impossible to know if you’re doing ‘illegal’ elsewhere).

Could these be causing more then 10 virtual writes per second? - if so then that’s ‘illegal’

While loops are blocking and can’t be exited until the criteria are met. They don’t seem to be an appropriate method in this case, but its difficult to understand the code flow based on this snippet blah, blah, blah…


1 Like