This project is a DIY Button Box controller for Euro Truck Simulator 2, built using an ESP32 microcontroller. Unlike standard controllers that act as USB HID devices, this project uses WiFi and UDP Sockets to communicate with the PC.
It consists of two parts:
- Transmitter (ESP32): Reads physical buttons/switches and sends state data via UDP.
- Receiver (Windows PC): A C++ console application that listens for UDP packets and simulates keystrokes using the Win32 API.
- Wireless: Completely air-gapped data transmission over local WiFi.
- Low Latency: Uses UDP protocol for minimal delay.
- No Drivers Needed: The receiver app runs as a standalone user-mode application.
- Custom PCB/Wiring: Simple GPIO pull-up logic.
- Microcontroller: ESP32 (DOIT DEVKIT V1 or similar)
- Connection: Buttons connected between GPIO and GND (Internal Pull-ups used).
| Component | ESP32 GPIO Pin | ETS2 Function | Keyboard Key |
|---|---|---|---|
| Ignition (Switch) | GPIO 18 | Start/Stop Engine | E |
| Horn (Button) | GPIO 15 | Air Horn | H |
| Parking Brake (Switch) | GPIO 21 | Toggle Handbrake | SPACE |
| Lights (Switch) | GPIO 5 | Hazard Lights | F |
The firmware is written in C using ESP-IDF and FreeRTOS Task Management.
- Open
main.c. - Update
wifi_configwith your WiFi SSID and Password. - Update
SERVER_IPwith your PC's local IP address (e.g.,192.168.1.X). - Flash to ESP32.
The receiver is a standard C++ Console Application using winsock2.
- Open
receiver.cpp(ormain.cpp). - Update the
server.sin_addr.s_addrline with your PC's IP address. - Compile using Visual Studio or MinGW (Link with
ws2_32.lib). - Run the executable before starting the game.
This is a hobby project created for educational purposes to learn about Socket Programming and Embedded Systems. The code is in a "prototype" state.
Feel free to use and modify!