---
title: "HTTP/HTTPS Server on ESP32 + W5500 with Mongoose"
url: "https://maker.wiznet.io/Benjamin/projects/mongoose-networking-library-esp32-w5500/"
markdown_url: "https://maker.wiznet.io/Benjamin/projects/mongoose-networking-library-esp32-w5500/md"
type: "UCC: User Created Content"
author: "mongoose-examples"
author_url: "https://github.com/mongoose-examples/esp32-w5500"
editor: "WIZnet"
editor_url: "https://maker.wiznet.io/"
original_author: "mongoose-examples"
original_url: "https://github.com/mongoose-examples/esp32-w5500"
published: "2025-12-14"
language: "en"
tags: ["C/C++", "W5500", "ESP32", "Arduino"]
hardware: ["Espressif ESP32", "WIZnet W5500"]
likes: 0
views: 325
comments: 0
source: "WIZnet Makers (https://maker.wiznet.io/)"
---

# HTTP/HTTPS Server on ESP32 + W5500 with Mongoose

> A minimal Arduino sketch running an HTTP and HTTPS server on ESP32 + W5500, with REST API endpoints for LED control using the Mongoose networking library.

Original author: mongoose-examples (source: https://github.com/mongoose-examples/esp32-w5500)

## Components

- **Espressif ESP32** x 1 ([docs](https://www.espressif.com/en/products/socs/esp32))
- **WIZnet W5500** x 1 ([docs](https://docs.wiznet.io/Product/Chip/Ethernet/W5500))
- Software: **Arduino IDE** ([docs](https://www.arduino.cc/en/software))
- Software: **Cesanta Software Ltd Mongoose** ([docs](https://mongoose.ws/documentation/))

WIZnet parts: W5500 ([Datasheet](https://docs.wiznet.io/Product/Chip/Ethernet/W5500/datasheet?utm_source=maker&utm_medium=project&utm_campaign=w5500), [product hub](https://maker.wiznet.io/products/w5500/))

## Article

### Simple HTTP/HTTPS Server on ESP32 with W5500

This project is a minimal but complete example from the Mongoose networking library team, showing how to run an HTTP and HTTPS server on an ESP32 board connected to a WIZnet W5500 Ethernet module. The code fits in a single Arduino sketch file and is designed to be a clean starting point for anyone building a wired IoT device with ESP32.

### What It Does

The firmware sets up two listeners on boot — HTTP on port 80 and HTTPS on port 443 — and exposes three endpoints:

This gives a working REST API over both plain HTTP and encrypted HTTPS from a single ~100-line sketch.

### How the W5500 is Used

The W5500 is driven directly through Mongoose's built-in W5500 driver. SPI is initialized manually with pin assignments defined at the top of `esp32.ino`:

```cpp
// esp32.ino #define SS_PIN   10 #define SCLK_PIN  6 #define MOSI_PIN  7 #define MISO_PIN  2  mif.driver = &mg_tcpip_driver_w5500; mif.driver_data = &spi; mg_tcpip_init(&mgr, &mif);
```

The `mongoose_config.h` enables the W5500 driver and Mongoose's built-in TCP/IP stack:

```c
// mongoose_config.h #define MG_ENABLE_DRIVER_W5500 1 #define MG_ENABLE_TCPIP 1 #define MG_TLS MG_TLS_BUILTIN
```

The W5500 handles the actual Ethernet framing and TCP/IP in hardware — Mongoose simply passes data to and from the chip via SPI. This combination keeps the ESP32's RAM and CPU usage low.

### Limitations

The embedded certificate is a self-signed example cert — browsers will show a security warning when accessing the HTTPS endpoint. For any real deployment, replace `TLS_CERT` and `TLS_KEY` with your own certificate. The SPI pin numbers are also hardcoded for the ESP32-C3-DevKitC, so other boards will need minor edits at the top of `esp32.ino`.

### FAQ

**Q: Does this work with ESP32 boards other than the C3-DevKitC?** A: Yes. Update the pin definitions at the top of `esp32.ino` — `SS_PIN`, `SCLK_PIN`, `MOSI_PIN`, and `MISO_PIN` — to match your board's SPI layout.

**Q: Why use W5500 over the ESP32's built-in Wi-Fi?** A: The W5500 handles TCP/IP in hardware, providing a stable wired connection without relying on the ESP32's Wi-Fi stack. This is particularly useful in electrically noisy environments, and the SPI interface makes the code easy to port to other MCU families.

**Q: How do I replace the TLS certificate?** A: Replace the `TLS_CERT` and `TLS_KEY` string literals in `esp32.ino` with your own certificate and key. New certificates can be generated at `mongoose.ws/tls`.

---

Source: https://maker.wiznet.io/Benjamin/projects/mongoose-networking-library-esp32-w5500/
