This project implements a versatile interface device using the ESP32-S3 microcontroller that allows for multiple HID input devices (keyboards, mice, gamepads, etc.) to be connected and their inputs mapped to either serial or CAN bus outputs. The system includes a web-based configuration interface, firmware upgrade capability, and TunerStudio integration.
- Multiple HID Device Support: Connect and use multiple USB HID devices simultaneously
- Flexible Input Mapping: Map any HID input to serial or CAN bus outputs with customizable conditions
- Web Configuration Interface: Configure all aspects of the system through a browser
- OTA Firmware Updates: Update firmware through the web interface
- TunerStudio Integration: Compatible with TunerStudio for advanced configuration and monitoring
- Persistent Settings: All configurations are saved to non-volatile memory
- ESP32-S3-DevKitC-1-N8R8 development board
- USB HID devices (keyboards, mice, gamepads, etc.)
- CAN bus transceiver (for CAN bus functionality)
- USB power supply
| Function | GPIO Pin |
|---|---|
| USB D+ | GPIO 20 |
| USB D- | GPIO 19 |
| UART0 TX | GPIO 43 |
| UART0 RX | GPIO 44 |
| UART1 TX | GPIO 17 |
| UART1 RX | GPIO 18 |
| UART2 TX | GPIO 14 |
| UART2 RX | GPIO 15 |
| CAN TX | GPIO 4 |
| CAN RX | GPIO 5 |
| LED | GPIO 2 |
The system is built on the ESP-IDF framework and consists of several key components:
- HID Host: Manages USB HID device connections and processes input events
- Serial Port: Handles serial communication through multiple UART ports
- CAN Bus: Manages CAN bus communication using the TWAI driver
- Input Mapping: Maps HID inputs to serial or CAN outputs based on configurable rules
- Web Server: Provides a web interface for configuration and firmware updates
- Firmware Update: Handles OTA firmware updates
- TunerStudio: Implements TunerStudio protocol for integration with tuning software
- ESP-IDF v4.4 or later
- Python 3.6 or later
- Git
-
Install ESP-IDF following the official guide
-
Clone this repository:
git clone https://github.com/your-username/esp32-hid-to-serial-can.git cd esp32-hid-to-serial-can -
Configure the project:
idf.py set-target esp32s3 idf.py menuconfig -
Build the project:
idf.py build -
Flash the firmware:
idf.py -p (PORT) flash
- Power on the ESP32-S3 board
- Connect to the WiFi network "ESP32-HID-Config" with password "password"
- Open a web browser and navigate to http://192.168.4.1
- Follow the on-screen instructions to configure your WiFi network
- Connect USB HID devices to the ESP32-S3 USB port
- The system will automatically detect and initialize the devices
- Use the web interface to configure input mappings
- Navigate to the "Mappings" section in the web interface
- Click "Add New Mapping"
- Select the input device, input type, and input index
- Configure the condition for when the mapping should trigger
- Select the output type (serial or CAN bus) and configure its parameters
- Set the output format and any scaling or offset values
- Click "Save" to create the mapping
- Navigate to the "Serial Config" section in the web interface
- Configure baud rate, data bits, stop bits, parity, and flow control for each port
- Click "Apply" to save the configuration
- Navigate to the "CAN Config" section in the web interface
- Configure bit rate, mode, and message filtering options
- Click "Apply" to save the configuration
- Navigate to the "Firmware" section in the web interface
- Click "Browse" and select the new firmware binary file
- Click "Upload & Flash" to start the update process
- Wait for the device to reboot with the new firmware
- Navigate to the "TunerStudio" section in the web interface
- Configure the protocol type, signature, and output port
- Download the INI file
- Open TunerStudio and create a new project using the downloaded INI file
- Connect to the ESP32-S3 using the configured serial port
The system provides a RESTful API for programmatic control:
GET /api/devices- Get list of connected HID devices
GET /api/mappings- Get list of all input-output mappingsPOST /api/mappings- Create a new mappingPUT /api/mappings/{id}- Update an existing mappingDELETE /api/mappings/{id}- Delete a mappingPOST /api/mappings/save- Save mappings to non-volatile memoryPOST /api/mappings/load- Load mappings from non-volatile memoryPOST /api/mappings/reset- Reset all mappings to default
GET /api/serial- Get serial port configurationPOST /api/serial- Update serial port configuration
GET /api/can- Get CAN bus configurationPOST /api/can- Update CAN bus configuration
GET /api/firmware/info- Get current firmware informationGET /api/firmware/status- Get firmware update statusPOST /api/firmware/upload- Upload and flash new firmware
GET /api/tunerstudio/config- Get TunerStudio configurationPOST /api/tunerstudio/config- Update TunerStudio configurationGET /api/tunerstudio/ini- Download TunerStudio INI filePOST /api/tunerstudio/ini- Upload custom TunerStudio INI file
- Ensure the device is properly connected to the USB port
- Check if the device is powered on
- Try disconnecting and reconnecting the device
- Verify the device is a supported HID device
- Check if the device is properly detected in the "Devices" section
- Verify the input type and index are correct
- Ensure the condition is properly configured
- Check the serial or CAN bus configuration
- Verify the ESP32-S3 is powered on
- Check if you're connected to the correct WiFi network
- Try resetting the ESP32-S3 and reconnecting
- Ensure the firmware binary is valid for ESP32-S3
- Check if the ESP32-S3 has enough free space
- Try resetting the ESP32-S3 and attempting the update again
This project is licensed under the MIT License - see the LICENSE file for details.
- Espressif for the ESP-IDF framework
- TinyUSB library for USB HID support
- Bootstrap for the web interface
- TunerStudio for the tuning software integration