Go Down

Topic: Many SSID to Conect (Read 289 times) previous topic - next topic


Hi! I'm David, It's my first post. I try to find my problema in the fórum, but I didn't find an answer, so I'm apologize if it's answered.
I have an Arduino MKR Wifi 1010, in the secret tab i want to add many ssid to conect. That can be possible?
My problem is that if the board is moved from one place to another , it need to conect to another network.
Please help me here!

Thanks a lot


You should be able to create as many input fields in the Secret tab as you like (I'm not aware of any limit). Whenever a name starting with SECRET_ that's all in caps is encountered in your sketch, a new input field is automatically added to the Secret tab. You might find it convenient to put the SSID and passwords in an array, like this:

Code: [Select]
const char SSIDs[][33] = {SECRET_SSID_1, SECRET_SSID_2, SECRET_SSID_3, SECRET_SSID_4, SECRET_SSID_5}; // maximum SSID length is 32 characters (reduce array size to save memory if less will suffice)
const char WiFiPasswords[][65] = {SECRET_WIFI_PASSWORD_1, SECRET_WIFI_PASSWORD_2, SECRET_WIFI_PASSWORD_3, SECRET_WIFI_PASSWORD_4, SECRET_WIFI_PASSWORD_5};  // maximum password length is 64 cxharacters? (reduce array size to save memory if less will suffice)

After adding that code to your sketch, you'll find 10 new input fields in the Secret tab.

The array approach allows you to do things like this:
Code: [Select]
for (byte networkCounter = 0; networkCounter < sizeof(SSIDs) / sizeof(SSIDs[0]); networkCounter++) {
  if (WiFi.begin(SSIDs[networkCounter], WiFiPasswords[networkCounter]) == WL_CONNECTED) {
    break;  //connected to network


Thanks, I'll try it.!!! :)


May 15, 2019, 02:44 pm Last Edit: May 15, 2019, 02:45 pm by snalgur
It won't compile I get the following error:
expected unqualified-id before 'for'

the code is of the thingsProperties.h

#include <ArduinoIoTCloud.h>
#include <WiFiConnectionManager.h>

const char THING_ID[] = ;

const char SSID[][33]     = {SECRET_SSID, SECRET_SSID1};    // Network SSID (name)
const char PASS[][65]     = {SECRET_PASS,SECRET_PASS1};    // Network password (use for WPA, or use as key for WEP)

void onInteriorChange();
void onTsetChange();
void onRadioChange();
void onEncendidoHeladeraChange();

bool Interior;
float Tset;
bool Radio;
float Temperatura;
bool EncendidoHeladera;

void initProperties(){
  ArduinoCloud.addProperty(Interior, READWRITE, ON_CHANGE, onInteriorChange);
  ArduinoCloud.addProperty(Tset, READWRITE, ON_CHANGE, onTsetChange);
  ArduinoCloud.addProperty(Radio, READWRITE, ON_CHANGE, onRadioChange);
  ArduinoCloud.addProperty(Temperatura, READ, ON_CHANGE, NULL);
  ArduinoCloud.addProperty(EncendidoHeladera, READWRITE, ON_CHANGE, onEncendidoHeladeraChange);

//ConnectionManager *ArduinoIoTPreferredConnection = new WiFiConnectionManager(SSID, PASS);

for (byte networkCounter = 0; networkCounter < (sizeof(SSID) / sizeof(SSID[0])); networkCounter++) {
  if (WiFi.begin(SSID[networkCounter], WiFiPassword[networkCounter]) == WL_CONNECTED) {
    break;  //connected to network


You can't use for outside of a function. Put that code inside your setup() function.

Go Up