🛠 Se connecter au Wi-Fi avec le module Murata 1DX (station WPA2)

Arduino Portenta H7 · debutant · Schéma : IMG-portenta-h7-debutant-2-portenta-h7-connexion-wifi.svg — Portenta H7 sur un bureau, ondes Wi-Fi reliant le module blindé Murata 1DX à une box Internet, terminal série affichant l'adresse IP obtenue, étiquette 802.11n 65 Mbps

Objectives

First networking step with the Portenta H7: joining an access point in station mode. The embedded radio module is a Murata 1DX: Wi-Fi 802.11n up to 65 Mbps (dual-band capable, supporting AP, STA, and simultaneous AP+STA modes) + Bluetooth 5.1 (Classic and Low Energy). You will use the WiFi library from the Mbed core, follow best practices by storing credentials in the Secrets tab, and learn about the official reconnection pitfall after losing the AP.

Hardware

Complete code

// wifi_station.ino — connexion station sur Murata 1DX
#include <WiFi.h>
#include "arduino_secrets.h"    // onglet Secrets de l'IDE

char ssid[] = SECRET_SSID;      // ne mets JAMAIS le mot de passe en dur
char pass[] = SECRET_PASS;
int status = WL_IDLE_STATUS;

void setup {
  Serial.begin(115200);
  while (!Serial) {}

  if (WiFi.status == WL_NO_MODULE) {
    Serial.println("Module Murata 1DX non detecte !");
    while (true) {}
  }

  while (status != WL_CONNECTED) {
    Serial.print("Connexion a "); Serial.println(ssid);
    status = WiFi.begin(ssid, pass);   // WPA2
    delay(3000);
  }
  Serial.print("IP obtenue : ");
  Serial.println(WiFi.localIP);
}

void loop {
  if (WiFi.status != WL_CONNECTED) {
    // Piege documente (ArduinoCore-mbed#382) : apres perte de l'AP,
    // WiFi.begin seul ne recolle pas -> il faut WiFi.end avant.
    WiFi.end;
    delay(1000);
    status = WiFi.begin(ssid, pass);
  }
  delay(2000);
}

Expected verification

The console displays Connexion a <ssid> followed by the IP address obtained via DHCP; you can ping the board from a PC on the same network. The Murata 1DX module also supports access point mode (and even simultaneous AP+STA modes) — the official tutorial wifi-access-point on docs.arduino.cc explores this path.

Common errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials