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

How I can use multiple wifi network

#1

Hi everybody

How I can do more than one wifi network.
Because I’m making is a portable device and hence we will be using it in different locations.
I’m using Arduino uno and ESP8266.

char ssid[] = “xxxxxxxxxxxxx”;

char pass[] = “xxxxxxxxxx”;

I mean If one network not available trying to other one.

0 Likes

#2
0 Likes

#3

You can explain more please

0 Likes

#4

@Moosa Please read the How It Works section of the above link, it explains it in as much detail as anyone here could.

And that is just one way of picking any available WiFi connection in the area of your device.

If you have pre-set WiFi options, then you can set up something similar to how typical re-connection management works for reconnecting if Server link is lost… only using different connections each time.

  • Boot…

  • Try to connect to A… if after x time with no connection…

  • Try to connect to B… if after x time with no connection…

  • Try to connect to C… if after x time with no connection… curl up and have a nap.

You are going to have to figure most of this out, as no one is going to code it all for you.

0 Likes

#5

Thanks

0 Likes

#6

I’m use Arduino uno with ESP8266

 #include <ESP8266WiFi.h>        
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <WiFiManager.h>      

void setup() {
  Serial.begin(115200);
    WiFiManager wifiManager;
  wifiManager.setTimeout(180);
 
  if(!wifiManager.autoConnect("AutoConnectAP")) {
    Serial.println("failed to connect and hit timeout");
    delay(3000);
    ESP.reset();
    delay(5000);
  } 

  Serial.println("connected...yeey :)");
 
}

void loop() {

}

I get Error compling for board
When I using with NodeMcu It is works. How I can use in arduino uno?

0 Likes

#7

Totally different process… requiring a different library and setup.

You should read though the Documentation and Help Pages.

http://help.blynk.cc/how-to-connect-different-hardware-with-blynk/arduino/esp8266-with-at-firmware

0 Likes

#8

To make you clear I uesed this code and everything fine but I’m asking if any method to get multiple wifi networks

#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <DHT.h>

char auth[] = "xxxxxxxxxxxxxccxxxxxxxxxxxx";

char ssid[] = "xxxxxxxx";
char pass[] = "xxxxxxxxx";

//#define EspSerial Serial


#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2, 3); // TX, RX

#define ESP8266_BAUD 9600

ESP8266 wifi(&EspSerial);

#define DHTPIN 7


#define DHTTYPE DHT11     // DHT 11

DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;

void sendSensor()
{
  float h = dht.readHumidity();
  float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit

//****************************************  
   Serial.print("Humidity: ");
  Serial.print(h);
Serial.println (" % ");
  Serial.print("Temperature: ");
  Serial.print(t);
  Serial.println (" C ");
 //*******************************

  if (isnan(h) || isnan(t)) {
  }
  
  Blynk.virtualWrite(V5, h);
  Blynk.virtualWrite(V6, t);
  
}

void setup()
{

  Serial.begin(9600);


  EspSerial.begin(ESP8266_BAUD);
  delay(10);

  Blynk.begin(auth, wifi, ssid, pass);

  dht.begin();

  timer.setInterval(1000L, sendSensor);
}

void loop()
{
  Blynk.run();
  timer.run();
}

Because I’m making is a portable device and hence we will be using it in different locations.

If I can make multiple ssid & pass.

0 Likes

#9

I take it that you didn’t like @Gunner’s suggestion of hard-coding multiple SSIDs and passwords then trying to connect to each in turn?

Pete.

0 Likes

#10

Thanks for trying to help
That you mean need to be known which ssid used to put in the code.
Any method can use like wifimanager. I mean no need enter the ssid & pass in the code for my program.

0 Likes

#11

Then use WiFi Manager (linked above)… that is the best way to do it without hard coding… period.

1 Like

#12

That’s not available for shield connections.

@Moosa use the ESP as an ESP, not a shield and use the Arduino as a shield. Then you can use WiFiManager.

2 Likes

#13

Right you are :blush: … so many repeated “how can I use” that I got confused (it happens :innocent:).

1 Like

#14

Just a suggestion here if you use a board with WiFi like the ESPxxxx boards.

I used to use the wifimanager but have developed a small bit of code that on boot will scan the available wifis and dynamically select and connect to the strongest wifi without the need for a web interface. It will also check connection periodically and if there is a disconnect then it will reset and select the best wifi. I have about 15 devices around the property with about 6 available wifis. This setup means I don’t need to play around with resetting the wifi via coding or wifimanager as I move them around the property. It just does it itself.

The Blynk interface looks like this. I use the device selector to select the device. You will see I have a button which rescans the available wifis and this populates a menu so I can reselect the wifi on the fly.

If you are interested in the code I can make it available on an as is where is basis :slight_smile:

I have no passwords on my wifi so that makes the above very easy. If you have passwords then it probably doesn’t work :slight_smile:

0 Likes