BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

How to automatically dual SSIDs for redundancy

esp8266
#1

Before creating the topic

  1. Search forum for similar topics
  2. Check http://docs.blynk.cc and http://help.blynk.cc/
  3. Add details :
    • Hardware model + communication type. For example: Arduino UNO with Ethernet Shield
    • Smartphone OS (iOS or Android) + version
    • Blynk server or local server
    • Blynk Library version
    • Add your sketch code. :point_up:Code should be formatted as example below.

Simply paste your code between ``` If you don’t format your code, your topic can be deleted by moderators.

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
////////////////////////////////////////////////////

char auth[] = "4bf59a2fddc046cea78ec8de6cba7831";
////////////////////////////////////////////////////
char ssid1[] = "ssid1";
char pass1[] = "pass1";
char ssid2[] = "ssid2";
char pass2[] = "pass2";
/////////////////////////////////////////////////////




void setup()
{
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid1, pass1);
 while(Blynk.connect()==false){
  delay(500);
  Blynk.begin(auth, ssid2, pass2);
 }
}

void loop()
{
  Blynk.run();
}
0 Likes

#2

Take a cue from this sketch

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).

char auth[] = "YourAuthToken"; //Put Your Auth Token Here

//Array to store Network Credentials for different WiFi Networks
const char* KNOWN_SSID[] = {"Nucleus", "Factory Forward", "SSID3"}; //Put all Your WiFi Network Names
const char* KNOWN_PASSWORD[] = {"", "1234567809", "Pass3"}; //Put the WiFi Passwords in same order. For Open networks leave the password blank inside the double quotes.

const int KNOWN_SSID_COUNT = sizeof(KNOWN_SSID) / sizeof(KNOWN_SSID[0]); // number of known networks

void setup() {
boolean wifiFound = false;
int i, n;

Serial.begin(9600);

// ----------------------------------------------------------------
// Set WiFi to station mode and disconnect from an AP if it was previously connected
// ----------------------------------------------------------------
WiFi.mode(WIFI_STA);
WiFi.disconnect();
delay(100);
Serial.println("Setup done");

// ----------------------------------------------------------------
// WiFi.scanNetworks will return the number of networks found
// ----------------------------------------------------------------
Serial.println(F("Scan start"));
int nbVisibleNetworks = WiFi.scanNetworks();
Serial.println(F("Scan Completed"));
if (nbVisibleNetworks == 0) {
Serial.println(F("No networks found. Reset to try again"));
while (true); // no need to go further, hang in there, will auto launch the Soft WDT reset
}

// ----------------------------------------------------------------
// if you arrive here at least some networks are visible
// ----------------------------------------------------------------
Serial.print(nbVisibleNetworks);
Serial.println(" network(s) found");

// ----------------------------------------------------------------
// check if we recognize one by comparing the visible networks
// one by one with our list of known networks
// ----------------------------------------------------------------

for (i = 0; i < nbVisibleNetworks; ++i) {
Serial.println(WiFi.SSID(i)); // Print current SSID
for (n = 0; n < KNOWN_SSID_COUNT; n++) { // walk through the list of known SSID and check for a match
if (strcmp(KNOWN_SSID[n], WiFi.SSID(i).c_str())) {
Serial.print(F("\tNot matching "));
Serial.println(KNOWN_SSID[n]);
} else { // we got a match
wifiFound = true;
break; // n is the network index we found
}
} // end for each known wifi SSID
if (wifiFound) break; // break from the "for each visible network" loop
}

if (!wifiFound) {
Serial.println(F("No Known Network identified. Reset to try again"));
while (true);

}

const char* ssid = (KNOWN_SSID[n]);
const char* pass = (KNOWN_PASSWORD[n]);
Serial.println(WiFi.localIP());
Blynk.begin(auth, ssid, pass);
Serial.println("Blynk Connected"); //Connected and Authenticated with Blynk Server
}

void loop()
{
Blynk.run();
}
2 Likes

#3

thanks for prompt reply only one ssid connected other than.

0 Likes

#4

You with this code can put in array two or more ssid

0 Likes

#5
#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>


char auth1[] = "";


char ssid1,ssid2[] = "ssid1,ssid2";
char pass1,pass2[] = "pass1,pass2";



void setup()
{
  
  Serial.begin(9600);
Blynk.begin(auth1,auth2, ssid1,ssid2, pass1,pass2);

}
void loop()
{
  Blynk.run();
}
0 Likes

#6

Please do not create multiple topics for same issue… I merged your 2nd topic Titled (Hi dears blynker can you all help me to add 2 ssid and 2 passwords i mean mukti ssid & passwords) here.

Please also format all posted code properly as required in the Welcome Topic or your posts will be deleted.

1 Like

#7

@amran Since you didn’t seem to listen, I fixed your code posting this time.

Next time follow the recommended formatting method please.

Blynk%20-%20FTFC

Oh, and use your words to supply details in the posts instead of simply posting code.

0 Likes

#9

We can help you learn to properly format posted code in this forum… as per the Welcome Topic :wink:

Blynk%20-%20FTFC

And again… please do NOT create multiple topics for same issue.

1 Like

#10

That character doesn’t exist on the Italian keyboard, damn it! You could have chosen a different one though! Every time I have to do copy&paste :stuck_out_tongue_winking_eye: :joy:

0 Likes

#11

Hold down the ALT key and use the numeric keypad to type the number 96

Another option is that in the Arduino IDE, when you select code then right-click you get this option:
image

When you paste in the forum you’dll see that teh IDE has added these code tags:
image

which displays correctly.

Pete.

1 Like

#12

And another option:

Just copy and paste the following and then paste your code between the lines.
```cpp
```

0 Likes

#13

It appears that @saddys is already aware of that option and finds it a bit tiresome, hence my alternative suggestions.

Pete.

1 Like

#14

Mine was a joke, it was never an insurmountable or tiresome problem. But having the [code] alternative for me will be very useful.
Thanks :slight_smile:

1 Like

#15

Another option:
If you have a spare Arduino board that’s compatible with the Keyboard library, and a spare pushbutton, wire the pushbutton between the defined pin and ground, and load the following sketch. With the board plugged into a USB port on your PC, you can push the button to generate the required characters. :wink:

#include <Keyboard.h>

#define BUTTON 2 // pin for button

void setup() {
  pinMode(BUTTON, INPUT_PULLUP);
  Keyboard.begin();
}

void loop() {
  if (digitalRead(BUTTON) == LOW) {
    Keyboard.print("```cpp\n```\n");
    delay(200); // delay for button debounce
    while (digitalRead(BUTTON) == LOW) {} // wait for button release
  }
}
2 Likes

#16

The “elegant” solution to “source code formatting” would be this :wink:
I’ve only spent a couple of hours working on this little plugin, but it would save a lot of posts for moderators. :smiley:

2 Likes

#17

This forum already has those characters sitting there ready for the initial post… just create a new topic and chose the category… bingo… Copy/Paste for further posting.

0 Likes

#18

I had never seen this feature for new topics :slight_smile:
New users have no excuse to format the code :smiley:
Maybe this new button for those who reply would also be comfortable

1 Like

#19

Good point… I have no idea why your plugin idea never moved forward :thinking:

0 Likes

#20

As I say, mine was only a joke, I have always write a formatted code.

0 Likes