esp32-ethernet-http-server-7.ino
A minimal web server hosted on ESP32 using the Ethernet interface provided by the UEXT-CH390 module.
Compatible with ESP32 boards featuring UEXT connectors. This code uses the Arduino WebServer API. For full integration, replace the simulation with calls to the Ethernet library specifically adapted for CH390 (WCH driver). Test the connection by pointing a browser to the defined static IP.
esp32-ethernet-http-server-7.ino
#include <WiFi.h>
#include <WebServer.h>
#include <SPI.h>
// Configuration CH390 sur ESP32 (Pins typiques UEXT)
// CH390 CS: GPIO5, RST: GPIO15, INT: GPIO4
// MISO: GPIO12 (MISO), MOSI: GPIO11 (MOSI), SCK: GPIO13 (SCK)
WebServer server(80);
void handleRoot() {
server.send(200, "text/html", "<h1>Ethernet via CH390 sur ESP32</h1><p>Fonctionnel !</p>");
}
void setup() {
Serial.begin(115200);
Serial.println("Démarrage du serveur Ethernet CH390...");
// Initialisation SPI
SPI.begin(13, 12, 11, 5);
// En ESP-IDF natif ou Arduino avec bibliothèque Ethernet adaptée au CH390:
// ETH.begin(CS_PIN, RST_PIN, INT_PIN, ETH_TYPE_CH390);
// Note: La bibliothèque standard Arduino Ethernet.h nécessite souvent des patches pour CH390.
// Utiliser la lib fournie par Olimex ou 'ETH.h' si compatible.
// Simulation d'attribution IP pour l'exemple compilable
IPAddress local_IP(192, 168, 1, 100);
server.on("/", handleRoot);
server.begin();
Serial.println("Serveur démarré. Adresse IP configurée.");
}
void loop() {
server.handleClient();
delay(100);
}