🛠 Serveur web sur le port Ethernet 10/100 embarqué
Objectives
The Portenta H7 offers more than just Wi-Fi: an Ethernet 10/100 PHY is soldered onto the board, exposed via the 80-pin connector pair (the Max/Mid Carrier boards provide the RJ45 connector). In an industrial workshop, wired connections beat wireless: stable latency, no association management required. You will build a wired mini HTTP server, in the spirit of the official "Ethernet with the IDE" tutorial for the Portenta range.
Hardware
- 1 × Arduino Portenta H7 + carrier board with RJ45 (Max Carrier, Mid Carrier) or wiring the PHY to the 80-pin connectors
- Ethernet cable to a switch/router with DHCP
- "Arduino Mbed OS Portenta Boards" core
- A web browser on the same LAN
- Serial console at 115200 baud (to read the IP address)
Complete Code
// serveur_web_eth.ino — mini serveur HTTP sur Ethernet filaire
// >
// inits pins) pour le core Mbed — la base documentaire ne donne pas le
// code exact ; suis le tuto officiel ethernet-with-ide de docs.arduino.cc
// pour la config materielle de ta porteuse.
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
EthernetServer serveur(80);
void setup {
Serial.begin(115200);
while (!Serial) {}
if (Ethernet.begin(mac) == 0) {
Serial.println("DHCP Ethernet echoue");
while (true) {}
}
Serial.print("Serveur sur http://");
Serial.println(Ethernet.localIP);
}
void loop {
EthernetClient client = serveur.available;
if (client) {
String requete = client.readStringUntil('\r');
client.flush;
String page = "<h1>Bonjour depuis ma Portenta H7</h1>"
"<p>Ethernet 10/100 embarque</p>";
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.print("Content-Length: ");
client.println(page.length);
client.println("Connection: close");
client.println;
client.print(page);
client.stop;
Serial.println("requete servie : " + requete);
}
}
Expected Verification
The serial monitor displays the IP address assigned by DHCP; point your browser to it to see the page. Each reload logs the GET request on the console. The official combo "Vision Shield camera + Ethernet" (tutorial ethernet-with-ide) takes it further: streaming images over the wired LAN.
Common Errors
- Looking for an RJ45 jack on the board alone: the PHY is embedded, but the connector comes from the carrier boards (Max/Mid Carrier) or the 80-pin headers — without a carrier, there is no jack!
- Expired DHCP or missing static IP in the workshop: in production, set a static IP rather than relying on DHCP, which may be absent on isolated industrial networks.
- Confusing the two network stacks: Wi-Fi (
WiFi.h) and Ethernet (Ethernet.h) can coexist; check which interface handles your traffic (the core's routing table selects the default gateway). - Client isolation on the switch/router (AP isolation, VLAN): the board is "online" but unreachable — test with ping before debugging the code.
- HTTP response without
Content-Length: some browsers remain open and block the next client — always close cleanly withclient.stop. - >
Other tutorials for this board
- Premier programme : installer le core et faire clignoter la LED (M7 à 480 MHz !)
- Se connecter au Wi-Fi avec le module Murata 1DX (station WPA2)
- Apprivoiser les connecteurs 80 broches : bouton, LED et entrée analogique
- Dual-core M7 ↔ M4 : appels de fonctions distants avec la bibliothèque RPC
- Client HTTPS/TLS : interroger une API sécurisée via le Murata 1DX
- MicroPython + machine vision : le firmware OpenMV sur un cœur, C++ sur l'autre
Code examples for this board
clignotante.inoArduinobouton-poussoir.inoArduinopwm-respiration.inoArduinoentree-analogique.inoArduinomulti-uart.inoArduinocapteur-i2c-bmp280.inoArduino