Contenido principal

Prepare Raspberry Pi for Wi-Fi Setup

R2026b

The first step in using a Raspberry Pi® board as a Wi-Fi® hotspot is to configure and deploy the Wi-Fi application to run on the board. To do so:

  1. Configure application parameters.

  2. Generate Wi-Fi setup application files.

  3. Deploy the application to Raspberry Pi.

  4. Reboot Raspberry Pi to activate services.

Configure Application Parameters

To start, configure the parameters that define the Wi-Fi setup application and hotspot to host on Raspberry Pi. These parameters identify the application, determine how you discover the setup network, and control how to securely access the configuration portal.

In MATLAB®, make a connection with the Raspberry Pi hardware.

mypi = raspberrypi('<hostname or IP address>','<user name>','<password>');

Create an instance of the Wi-Fi setup application generator for the setup, setting properties to specify the app behavior.

Parameter NameParameter Description
NameDefines the application name and creates a directory that contains all generated files, including the web app, services, and setup scripts.
LogoDefines the path to a custom logo image that the web‑based configuration portal displays. The supported formats include .jpg, .jpeg, .png, .gif, .webp, and .svg.
HotspotNameDefines the SSID of the Wi-Fi hotspot that the Raspberry Pi hosts during setup. This is the network name visible when scanning for available Wi-Fi networks. the SSID must be 1 to 32 characters long.
HotspotPassword

Defines the hotspot password required to connect Raspberry Pi. This password must be between 8 to 63 characters long to meet the Wi-Fi security requirements.

Warning

If your hotspot password is shorter than 8 characters, the setup might fail.

AppName = matlab.raspi.wifiSetup(mypi,...
                                 Name="myWifiApp", ...
                                 Logo="mylogo.png", ... 
                                 HotspotName="MyHotSpot", ...
                                 HotspotPassword="12345678");

This object captures all the information required to generate a complete, deployable Wi-Fi application.

Build and Deploy Wi-Fi Setup Application

Build the Wi-Fi setup application on the host computer and deploy it to Raspberry Pi by using a single command.

app.buildAndInstall
Copying myWifiApp directory to Raspberry Pi...
Setting up application directory...
Installing dependencies on Raspberry Pi...
Updating dhcpcd.conf for Bullseye or earlier...
Enabling and starting my_create_ap.service...
Enabling and starting my_wifi_app.service...
Deployment completed successfully.
### Please reboot your Raspberry Pi.

When you run app.buildAndInstall, the system performs the following operations.

  • Generates the Wi-Fi setup application files on the host computer.

  • Creates and application directory on the hardware (for example, /opt/WifiProvisionApp/myWifiApp) to keep setup artifacts organized and isolated.

  • Compresses and packages the generated application files and copies them to Raspberry Pi.

  • Installs the system dependencies to host the hotspot and web portal:

    • hostapd

    • dnsmasq

    • iptables

    • haveged

    • linux-wifi-hotspot

  • Updates network settings as needed to support access point operation, including any OS‑specific configuration.

  • Registers and activates persistent system services:

    • Hotspot service for hosting the setup network

    • Web application service for hosting the configuration portal

  • Displays progress messages and confirms when the process completes successfully.

These messages confirm that the system builds the application, installs required dependencies, configures services, and prepares the Raspberry Pi for Wi-Fi provisioning.

Alternatively, you can build and manually deploy the customized

Reboot Raspberry Pi to Activate Services

After deployment, reboot Raspberry Pi to activate all the installed services. The reboot makes sure that the hotspot and web-based configuration portal start automatically.

system(mypi, 'sudo reboot');

Alternatively, you can log in to Raspberry Pi using SSH and reboot it manually.

sudo reboot

The Raspberry Pi hardware has rebooted and you can see a Wi-Fi network named MyHotSpot (or your chosen SSID) when scanning for Wi-Fi on your client device.

See Also