- Project Description
- Features
- Hardware Configuration
- Network Protocol
- Installation and Building
- Configuration
- Launch and Usage
This project implements a TCP file server for ESP32 with file upload/download capabilities over Wi-Fi. Files are stored on an SD card using SPI interface, and system messages are displayed on a 128×64 OLED screen via I2C bus.
- File upload/download over TCP
- 8.3 filename format restriction (8 characters + "." + 3-character extension)
- Data storage on SPI-connected SD card
- Status display on 128×64 I2C OLED screen
- Configurable SSID, password, and peripheral pins in
config.h
| Component | Interface | Default Pins |
|---|---|---|
| SD Card | SPI | Configured in main/include/config.h |
| OLED 128×64 | I2C | Configured in main/include/config.h |
| ESP32 Wi-Fi | UART/TCP | SSID/PASSWORD in main/include/config.h |
The server expects special control packets to initiate data transfers.
- Client sends header:
| 1B FLAG | 4B FILESIZE | 8B + 1B + 3B FileName |- FLAG: Control code for transfer start
- FILESIZE: File size in bytes (little-endian)
- FileName: Up to 12 characters (FAT32 limitation)
- After receiving header, server expects data packet:
| 1B FLAG (0xDD) | up to 31B DATA | - Server writes content to SD card with specified filename
- Client sends request:
| 1B FLAG | 8B + 1B + 3B FileName | - Server opens file and sends data through established TCP socket
- If file not found, server returns error message and waits for next control packet
- Clone repository:
git clone https://github.com/warlcan/ESP32-TCP-FileServer.git
- Navigate to project directory:
cd ESP32-TCP-FileServer - Configure parameters in
main/include/config.h:- SD card and OLED pins
- Wi-Fi SSID and PASSWORD
- Build and flash firmware:
idf.py build idf.py -p <PORT> flash monitor
All customizable parameters are located in main/include/config.h:
Wi-Fi Settings
#define WIFI_SSID "your-ssid"
#define WIFI_PASSWORD "your-password"SD Card (SPI)
#define PIN_SPI_MISO 19
#define PIN_SPI_MOSI 23
#define PIN_SPI_CLK 18
#define PIN_SPI_CS 5OLED Display (I2C)
#define PIN_SDA_GPIO 21
#define PIN_SCL_GPIO 22
#define PIN_RESET_GPIO -1- After flashing, the module will connect to Wi-Fi and listen on TCP port (default: 12035)
- ESP32's IP address will be displayed on OLED screen (line 2)
- Use TCP client (e.g.,
netcator custom script) to send control packets and data
Test scripts in scripts/ directory:
# Upload file to server
python3 UPLOAD_test_script.py <IP> <PORT> <FILE>
# Download file from server
python3 DOWNLOAD_test_script.py <IP> <PORT> <FILE>Note: IP address is shown in
monitorconsole and on OLED display