Connecting to Wi-Fi SSID on Portenta H7 compile error

Has anyone successfully connected to an SSID on their Portenta H7?

I am simply just trying to connect to WI-Fi and report the status by copy pasting the example here: WiFi - WiFi.status() - Arduino Reference But getting the following error when attempting to compile at the function int begin(const char* ssid); from WiFi.h:

/private/var/folders/5j/36d9y2k17739_ggvj_s8vc4hp4csn7/T/arduino-sketch-396C02043F5E571FFC98FE4576F2AFFA/sketch/sketch_sep6a.ino.cpp.o: In function `setup':
/private/var/folders/5j/36d9y2k17739_ggvj_s8vc4hp4csn7/T/.arduinoIDE-unsaved202286-7744-f7cd39.ofada/sketch_sep6a/sketch_sep6a.ino:67: undefined reference to `arduino::WiFiClass::begin(char const*)'
collect2: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1

I've made sure the board is working before hand, by uploading the WifiWebClient example sketch which it does without any issues.

The error points to incorrect usage of the function WiFi.begin however I've tried changing the SSID variable type to const char, const char*, and char* but it also fails in the same manner.

Interestingly the WifiWebClient example uses the same type as my example I am following -- char ssid[] = SECRET_SSID; and can compile correctly.

Here's the code copied:

#include <SPI.h>
#include <WiFi.h>

char ssid[] = "yourNetwork";                     // your network SSID (name)
int status = WL_IDLE_STATUS;                     // the Wifi radio's status

void setup() {
  //Initialize serial and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

  // check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue:
    while (true);
  }

  // attempt to connect to Wifi network:
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to WEP network, SSID: ");
    Serial.println(ssid);
    status = WiFi.begin(ssid);

    // wait 10 seconds for connection:
    delay(10000);
  }

  // once you are connected :
  Serial.print("You're connected to the network");
}

void loop() {
  // check the network status connection once every 10 seconds:
  delay(10000);
 Serial.println(WiFi.status());
}

From some more debugging....

This works: status = WiFi.begin(ssid, pass);
But this doesn't: status = WiFi.begin(ssid);

Why would the function without a password fail?
I'm a little confused here.

Bump, could this be an error in the library specific to Portenta?

It is a C++ convention:
if "pass" is not an optional parameter (it does not have a default initialization), you have to provide this parameter.

As I understand:
WiFi.begin(type ssid, type pass);
vs.
WiFibegin(type ssid, type pass = Default);

are two different 'signatures'. If the second one is not provided - you "must" provide "pass" as a mandatory parameter.
(not a FW issue, a C++ issue and how the FW is provided/implemented - check the H-files)

BTW: I cannot assume that anybody would implement and use a "default" pass code. A pass code, password sounds to me as very specific (and providing a "default" creates a security hole).
Obvious for me that such one is "mandatory" to provide.

I didn't see you reply until just now, thank you! that makes sense.

Hi, were you able to get it working?

I'm also trying to connect to an open network, but I'm running into the same issues with the WiFi. I looked at the implementation of the WiFi library, and it seems to be missing the function corresponding to connecting to an open method. Does setting the password parameter to "" seem to do the trick?

Hey I never tried, I just made an AP with a password.

It really does seem like a bug though, as the WI-Fi library has several begin functions and one of them is for an open network that doesn't require a password.

From Wifi.h:
Untitled

Did you try the method @tjaekel mentioned?
i.e. do WiFibegin(type ssid, type pass = Default); ?

Hello!

Check the mbedOS Core for Portentas example ArduinoCore-mbed/WiFiWebClient.ino at main · arduino/ArduinoCore-mbed · GitHub

Hey @PMarquinez, thanks for replying to this.

Has your team validated connecting to and open network on the Portenta H7?

Like I mentioned (and I just tried again this morning to double confirm), the example code works only for a network with a password. Connecting to an open network with no password fails to compile.

The error says: undefined reference to arduino::WiFiClass::begin(char const*)

However, in the documentation there is a function for an open network which takes only a string. Am I misunderstanding something?

/* Start Wifi connection for OPEN networks
*
* param ssid: Pointer to the SSID string.
*/
int begin(const char* ssid);

Have you tried passing an empty password?

Huh yeah I did a blank password i.e. char pass[] = ""; and it connected.

Thank you!

1 Like