Arduino Portenta H7 Part 3: Wi-Fi Access

Arduino PRO Portenta H7

Shortly after Unboxing the Arduino Pro Portenta H7, we put the new platform and the dual-core capabilities of its STM32H747XI Arm microcontroller through a few basic tests.  This is thanks in no small part due to the example code published directly on Arduino’s website for how to get started.

In this third Arduino Pro project, we will examine the third Portena H7 example by unleashing its capabilities as a Wi-Fi hotspot.  This function is completely programmable via the basic Arduino Integrated Development Environment (IDE) with which you are probably already familiar.

Notice of Non-Affiliation and Disclaimer: As of the publication date, we are not affiliated with, associated with, authorized with, endorsed by, compensated by, or in any way officially connected with Arduino, Portenta H7, Microsoft, Google or their owners, subsidiaries or affiliates.

The names Arduino, Portenta H7, Windows, Android, Android OS, mBed, as well as related names, marks, emblems, and images are trademarks of their respective owners.

External Links: Links to external web pages have been provided as a convenience and for informational purposes only. Unboxing Tomorrow and Voxidyne Media bear no responsibility for the accuracy, legality or content of the external site or for that of subsequent links. Contact the external site for answers to questions regarding its content.

Objectives

On completion, you will be able to control the Portenta H7’s red, green, and blue (RGB) light-emitting diode (LED) using the web browser of a Wi-Fi capable device such as a laptop or smartphone.  Your wireless range will be roughly the same as any typical Wi-Fi device.

If your Portenta H7 is brand new, consider following these projects first, since they will help you configure your hardware drivers and boards manager for the Portenta H7.

Material Requirements

  • Arduino Pro Portenta H7
  • Antenna for Arduino Pro Portenta H7 (connector type: u.FL)
  • USB C cable
  • Host Computer
  • (Recommended) Anti-static work area
  • (Recommended) Compressed air or canned air to clean the antenna connector
  • (Optional) Smart Device with Wi-Fi

Recommendations

  • Consider avoiding a USB hub.  You should use a native (direct) USB connection to your PC.  This may avoid problems making the Wi-Fi access point visible to other devices.
  • As usual, your COM port number may vary.  You can check that you are connected to the right one using Tools –> Get Board Info

Software Requirements

You will know you are ready for this walkthrough if you can successfully compile and upload any amount of code to the Portenta H7 platform.

Boards Manager Update: In the Arduino IDE, you should check that you are no longer using “[DEPRECATED] mBed-enabled boards” unless you have a distinct need for it.  The old version is no longer being maintained and may have connectivity problems with this project (especially on Android devices).  Instead, you can find the newest release using the Arduino Boards Manager.

  • Arduino IDE version 1.8.10 or later
    • (Featured here) Arduino IDE version 1.8.13
  • Arduino mbed-enabled Boards non-deprecated version
    • (Featured here) Arduino mbed-enabled Boards version 1.3.1

Step 1: Attach the Antenna

The antenna included with the Portenta H7 uses the u.FL connector type. If possible, you may wish to clear any dust from both connectors by lightly cleaning them with a blast of compressed air.

  1. Line up the antenna’s connector directly above the u.FL connector on the board.
  2. Firmly press down while making the larger cable-side connector slip completely over the smaller board-mounted connector on all sides.
  3. The connector may or may not click into place. 

The u.FL connector type is generally delicate and not made for repeated mating and unmating.  Consider leaving the antenna attached from this point forward unless you have a genuine need to remove it.

Step 2: Connect the Arduino USB

With the antenna in place, connect the Arduino to your computer using the USB cable.

Step 3: Retrieve the Example Code

This example code is quite large compared to the previous two projects.  So, save yourself some trouble by copying the official code from https://www.arduino.cc/pro/tutorials/portenta-h7/por-ard-ap.

Step 4: Start the Arduino IDE

When you’ve copied the code, create a new Arduino sketch (i.e.: project).  Erase the main() and loop() functions, and then paste in the example code.

Save the project as simpleWebServer.

Figure 1: The Pasted Application and New Tab Location

In the Arduino IDE, create a new tab by clicking the down button in the top-left corner of the Arduino IDE.

When you are prompted to name it, call the new tab “arduino_secrets.h” per Arduino’s instructions.

Step 5: Name and Password

In the new arduino_secrets.h tab, enter the following lines of code:

# define SECRET_SSID "PortentaAccessPoint"
# define SECRET_PASS "123Qwerty"

Leaving the double-quotations present, replace PortentaAccessPoint and 123Qwerty password with whichever access point name and password you prefer.  SECRET_SSID is the access point name that the public will see.  I will call my network: “Network1.”

Step 6: Configure and Upload

Before compiling, use Tools –> Board to select “Arduino Portenta H7 (M7 core).”  If you haven’t already done so, update the Arduino mbed-enabled boards driver using Tools –> Board –> Boards Manager; and prepare to unplug and re-plug the Arduino after your driver is updated.

Select the Arduino’s COM number, and then click “upload.”

Step 7: Start the Serial Monitor

Your access point will not be visible to nearby devices until you start the Arduino IDE’s Serial Monitor (Tools –> Serial Monitor).  This condition is enforced by the while (!Serial) loop near the start of the setup() function, which you can comment out later.

Once you open the serial monitor, your simpleWebServer application will attempt to create an access point using the Wi-Fi radio firmware.  The serial monitor may report “Device disconnected from AP,” but this only indicates that no other Wi-Fi device has connected yet.

Troubleshooting Serial Monitor

At this point, you may see the following error…

Access Point Web Server
Creating access point named: Network1
Failed to mount the filesystem containing the WiFi firmware.
Usually that means that the WiFi firmware has not been installed yet or was overwritten with another firmware.
Please run the "PortentaWiFiFirmwareUpdater" sketch once to install the WiFi firmware.

If so, you can remedy it using the PortentaWiFiFirmwareUpdater code example included with the Arduino IDE.  To do it:

  1. Open the Portenta Wi-Fi Firmware Updater sketch with: File –> Examples –> WiFi
  2. Select the Portenta M7 core (Tools –> Board –> Arduino mBed OS Boards –> …M7 Core)
  3. Select the appropriate COM port (Tools –> Port)
  4. Click Upload.
  5. Close PortentaWiFiFirmwareUpdater if update was successful
  6. Re-open the simpleWebServer sketch
  7. Re-upload the simpleWebServer sketch

Step 8: Log In

Use a Wi-Fi enabled device such as a smartphone to try and locate your access point.  Connect to the network, and supply the password when you’re asked.

Troubleshooting Log In

In my case, connecting a Windows 10 laptop worked fine without any special adjustments, even with the deprecated Arduino mbed-enabled boards driver.

Android phones would return the error “Could not obtain an IP address.”  This occurred before I used the Portenta WiFi Firmware Updater and a the Android phone was configured to use DHCP when joining the access point.  This appeared to be fixed by doing the Wi-Fi firmware update.  However, if you absolutely need the old Wi-Fi firmware (or cannot update it for some reason) you may have some luck by joining the network with the following settings…

  • IP Setting = Static
  • IP address = 192.168.3.100
  • Gateway = 192.168.3.1
  • Network Prefix Length = 24

Otherwise, you’re better off allowing DHCP and default settings.

Step 9: View the Server Address

Figure 2: The Arduino-based HTTP page.

Take whatever device you are using to wirelessly log in to your Portenta H7, and use its web browser to access the address shown in the terminal.  As of this writing, that address will be http://192.168.3.1.

The web page should show the title “LED CONTROLS” followed by the various on/off states of the Portenta’s (RGB) LED. 

Clicking “ON” or “OFF” should correspondingly change the LED state on the board, refresh the LED CONTROLS page, and push HTTP metadata to the serial terminal.

Conclusions

From here, you can modify the sketch as you see fit.  In my case, that was to comment out the while(!Serial) loop so the system could operate without a virtual serial connection.

If you plan to power this project using sources other than USB, then you may do so using the onboard 5V and ground pins.  This access point will only draw around 1 watt at startup. If your system reboots continually, it may be due to an inadequate 5-volt supply or excessively long wires connecting it.  For this reason, you may wish to connect a bypass capacitor near the Portenta H7 to satisfy its spikes in power demand.

In summary, the Wi-Fi library and code example provide an easy start when it comes to connecting mobile devices to real Arduino peripherals and signals. This also side-steps the challenge of wireless pairing and device setup, allowing just about any smart device to work as a convenient user interface.

References

[1]B. Mayes, “Unboxing the Arduino Pro Portenta H7,” Voxidyne Media, 24 June 2020. [Online]. Available: https://unboxing-tomorrow.com/unboxing-the-arduino-pro-portenta-h7/. [Accessed 29 Jan 2020].
[2]B. Mayes, “Arduino Portenta H7 Part 2: Dual-Core Computing,” Voxidyne Media, 5 Aug 2020. [Online]. Available: https://unboxing-tomorrow.com/arduino-portenta-h7-part-2-dual-core-computing/. [Accessed 29 Jan 2020].
[3]Arduino, “Portenta H7 as a WiFi Access Point,” Arduino, 7 May 2020. [Online]. Available: https://www.arduino.cc/pro/tutorials/portenta-h7/por-ard-ap. [Accessed 29 Jan 2020].

Important Notice: This article and its contents (the “Information”) belong to Unboxing-tomorrow.com and Voxidyne Media LLC. No license is granted for the use of it other than for information purposes. No license of any intellectual property rights is granted.  The Information is subject to change without notice. The Information supplied is believed to be accurate, but Voxidyne Media LLC assumes no responsibility for its accuracy or completeness, any error in or omission from it or for any use made of it.  Liability for loss or damage resulting from any reliance on the Information or use of it (including liability resulting from negligence or where Voxidyne Media LLC was aware of the possibility of such loss or damage arising) is excluded.