Portenta H7 and WiFi

Hi,
i'm trying to run the web server sketch, but when it runs the program it's stuck on "Creating access point named: ssid_test"
I used the code posted here https://www.arduino.cc/pro/tutorials/portenta-h7/por-ard-ap

Can you help me please?

#include <WiFi.h>
//#include "arduino_secrets.h"

///////please enter your sensitive data in the Secret tab/arduino_secrets.h
char ssid[] = "ssid_test";    // your network SSID (name)
char pass[] = "pass_test";    // your network password (use for WPA, or use as key for WEP)
int keyIndex = 0;             // your network key Index number (needed only for WEP)

int status = WL_IDLE_STATUS;

WiFiServer server(80);

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  Serial.println("Access Point Web Server");

  pinMode(LEDR,OUTPUT);
  pinMode(LEDG,OUTPUT);
  pinMode(LEDB,OUTPUT); 

  // by default the local IP address of will be 192.168.4.1
  // you can override it with the following:
  // WiFi.config(IPAddress(10, 0, 0, 1));

  // print the network name (SSID);
  Serial.print("Creating access point named: ");
  Serial.println(ssid);

  //Create the Access point
  status = WiFi.beginAP(ssid,pass);
  if(status != WL_AP_LISTENING){
    Serial.println("Creating access point failed");
    // don't continue
    while (true);
  }

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

  // start the web server on port 80
  server.begin();

  // you're connected now, so print out the status
  printWiFiStatus();

}

void loop() {

 // compare the previous status to the current status
  if (status != WiFi.status()) {
    // it has changed update the variable
    status = WiFi.status();

    if (status == WL_AP_CONNECTED) {
      // a device has connected to the AP
      Serial.println("Device connected to AP");
    } else {
      // a device has disconnected from the AP, and we are back in listening mode
      Serial.println("Device disconnected from AP");
    }
  }

  WiFiClient client = server.available();   // listen for incoming clients

  if (client) {                             // if you get a client,
    Serial.println("new client");           // print a message out the serial port
    String currentLine = "";                // make a String to hold incoming data from the client

    while (client.connected()) {            // loop while the client's connected

      if (client.available()) {             // if there's bytes to read from the client,
        char c = client.read();             // read a byte, then
        Serial.write(c);                    // print it out the serial monitor
        if (c == '\n') {                    // if the byte is a newline character

          // if the current line is blank, you got two newline characters in a row.
          // that's the end of the client HTTP request, so send a response:
          if (currentLine.length() == 0) {
            // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
            // and a content-type so the client knows what's coming, then a blank line:
            client.println("HTTP/1.1 200 OK");
            client.println("Content-type:text/html");
            client.println();

            // the content of the HTTP response follows the header:
            client.print("<html><head>");
            client.print("<style>");
            client.print("* { font-family: sans-serif;}");
            client.print("body { padding: 2em; font-size: 2em; text-align: center;}");            
            client.print("a { -webkit-appearance: button;-moz-appearance: button;appearance: button;text-decoration: none;color: initial; padding: 25px;} #red{color:red;} #green{color:green;} #blue{color:blue;}");
            client.print("</style></head>");
            client.print("<body><h1> LED CONTROLS </h1>");
            client.print("<h2><span id=\"red\">RED </span> LED </h2>");
            client.print("<a href=\"/Hr\">ON</a> <a href=\"/Lr\">OFF</a>");
            client.print("<h2> <span id=\"green\">GREEN</span> LED </h2>");
            client.print("<a href=\"/Hg\">ON</a> <a href=\"/Lg\">OFF</a>");
            client.print("<h2> <span id=\"blue\">BLUE</span> LED </h2>");
            client.print("<a href=\"/Hb\">ON</a> <a href=\"/Lb\">OFF</a>");
            client.print("</body></html>");

            // The HTTP response ends with another blank line:
            client.println();
            // break out of the while loop:
            break;
          } else {      // if you got a newline, then clear currentLine:
            currentLine = "";
          }
        } else if (c != '\r') {    // if you got anything else but a carriage return character,
          currentLine += c;      // add it to the end of the currentLine
        }

        // Check to see if the client request was "GET /H" or "GET /L":
        if (currentLine.endsWith("GET /Hr")) {
          digitalWrite(LEDR, LOW);               // GET /Hr turns the Red LED on
        }
        if (currentLine.endsWith("GET /Lr")) {
          digitalWrite(LEDR, HIGH);                // GET /Lr turns the Red LED off
        }
        if (currentLine.endsWith("GET /Hg")){
          digitalWrite(LEDG, LOW);                // GET /Hg turns the Green LED on
        }
        if (currentLine.endsWith("GET /Lg")){
          digitalWrite(LEDG, HIGH);                // GET /Hg turns the Green LED on
        }
        if (currentLine.endsWith("GET /Hb")){
          digitalWrite(LEDB, LOW);                // GET /Hg turns the Green LED on
        }
        if (currentLine.endsWith("GET /Lb")){
          digitalWrite(LEDB, HIGH);                // GET /Hg turns the Green LED on
        } 

      }
    }
    // close the connection:
    client.stop();
    Serial.println("client disconnected");
  }

}

void printWiFiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print where to go in a browser:
  Serial.print("To see this page in action, open a browser to http://");
  Serial.println(ip);
}

Are you adding a password to the network? Try adding a password of around 10 characters

Hi Bakust

Suggest heading over to your Arduino IDE (hopefully version 1.8.13) and then following the path:

Tools->Board->Boards Manager

Once at Boards Manger ensure that the installed boards are limited to:

Arduino Mbed OS Boards (nRF52840/STM32H747)

You can uninstall any other boards from

Tools->Board->Boards Manager

Click uninstall on any other board packages

Doing this should allow the Web Server example on the Arduino PRO page to run (am using Catalina 10.15.5 and Arduino IDE 1.8.13)

Portenta WiFi Server

I have found that the Web Server example will not run when I have both Mbed libraries installed

Arduino Mbed OS Boards (nRF52840/STM32H747) & Arduino nRF528x (Mbed OS) -- Arduino Nano 33 BLE

Hi bakust! The output in your serial monitor looks fine. Are you sure that the Portenta doesn't create the WiFi access point? Have you checked in the WiFi network list on any of your devices if it shows up?

I found that if I have my portenta plugged into a computer wifi will not work it just keeps rebooting.

I ended up commenting out the serial wait loop, plugged the portenta into a usb power adapter and now wifi works. I just have to connect to serial via the data pins (D13, D14).

//while (!Serial) {
//  ; // wait for serial port to connect. Needed for native USB port only
//}

I'm not sure if it's a bug that wifi+usb can't be used together or if it's a limitation as I haven't found any documentation on usb and wifi. Hopefully someone knows more.

So after a bit more digging I found out it looks like an issue with the USBD/SerialUSB and wifi still not sure exactly the cause. Adding the following to the top of my sketch fixes the issue.

#undef SERIAL_CDC

This will disable PluggableUSBD and SerialUSB in the main method and change Serial from SerialUSB to UART1 but for me serial over usb still works just fine.

I tried the WiFi LED Web Server examples and saw similar issues.

  1. If Portenta H7 USB is connected on/via an USB Hub - it does not work. It seems to re-boot all the time.
    The USB (with the UART) has to be on a native USB port on PC (not via a hub).
  2. I cannot connect to the WiFi SSID from an Android Smartphone: It stops on phone always at stage
    "Obtaining IP address".
    But from my Win10 PC I can connect to H7 WiFi and it works (to see web site, toggle LEDs).
  3. But the WiFi seems to be unreliable: after a while, nothing touched, the PC loses WiFi connection (and
    it changes back to my home WiFi). Even the SSID is still there - I cannot reconnect PC to it
    (I think obvious because in loop() it does not start over if it crashes somewhere after a client was
    connected).

Hi all!

In case you still experience issues, you may try with the latest core version from the repository:

We fixed a couple of issues with WiFi. Please let me know if it solves your problem.