Reconfigurable multi-protocol communication adapter (STM32F446RE + ESP-01) — FreeRTOS firmware + embedded Lua VM + ESP-01 web dashboard + PC companion tool.
This repository contains the firmware and tools for a prototype multi-protocol adapter that enables real-time routing and conversion between UART, SPI, I²C, and CAN. The system is powered by an STM32F446RE running FreeRTOS with an embedded Lua VM for scripting, paired with an ESP-01 (ESP8266) module hosting a web dashboard. A PC companion tool (Windows installer or Python GUI) is provided for editing/uploading Lua scripts, serial monitoring, and debugging.
- Bidirectional protocol bridging: UART ↔ SPI ↔ I²C ↔ CAN
- Runtime reconfiguration via ESP-01 web dashboard
- Embedded Lua scripting for message filtering, processing, and routing
- Deterministic task scheduling with FreeRTOS
- PC companion tool: Windows
.exe
installer or Python GUI for script editing and serial monitoring - DMA/ISR-driven low-latency data paths for real-time performance
ESP01 Web Dashboard/
— ESP-01 dashboard firmware and static web UI filesPC Companion Software/
— Python-based PC tool (script editor and serial monitor), including a Windows.exe
installer and Python GUI scriptSTM32 Firmware.zip
— Zipped STM32/FreeRTOS firmware project (for STM32CubeIDE)README.md
— This fileLICENSE
— MIT License file
- STM32F446RE (Nucleo board or custom breakout)
- ESP-01 (ESP8266) module
- CAN transceiver (e.g., MCP2551, SN65HVD230)
- USB-to-Serial adapter or ST-Link for flashing
- Wiring: STM32 UART3 ↔ ESP-01 UART (TX/RX + GND)
- Power supply: 5V USB or equivalent
- STM32CubeIDE — To build and flash the STM32 firmware
- Arduino IDE or PlatformIO — For flashing ESP-01 dashboard firmware
- Python 3.x — For running the Python GUI (
main.py
) - PC companion tool includes:
- Windows
.exe
installer (double-click to run) - Python GUI script (
main.py
)
- Windows
Follow these steps in order: STM32 firmware → ESP-01 dashboard → PC companion tool.
- Unzip
STM32 Firmware.zip
to a folder. - Open the project in STM32CubeIDE (load the
.ioc
or project file). - Configure your debug probe (ST-Link, JTAG, etc.) if necessary.
- Build and flash the firmware to the STM32F446RE.
- Connect hardware peripherals (CAN transceiver, SPI/I²C devices, etc.) and wire UART3 to ESP-01 UART.
Notes:
- The firmware includes FreeRTOS and an embedded Lua VM. If you modify clock or pin configurations, regenerate code via CubeMX or update HAL settings.
- Ensure USART pins for ESP-01 match the wiring in your board and ESP firmware.
- Open the
ESP01 Web Dashboard/
folder in Arduino IDE or PlatformIO. - Install the ESP8266 board package and select Generic ESP8266 Module or ESP-01.
- Set the correct COM port and upload settings (flash size/mode).
- Flash the dashboard firmware to the ESP-01.
- Connect ESP-01 UART pins to STM32 UART3 (TX↔RX, RX↔TX, common GND).
- After boot, access the ESP-01 IP address in a browser (check serial output for the IP or use captive setup if available).
Dashboard Features:
- Real-time serial monitor (Terminal)
- Protocol configuration (baud rates, SPI mode, I²C params, CAN bitrate)
- Routing matrix editor
- Lua script upload interface (if implemented)
Choose one of the following methods:
- Navigate to
PC Companion Software/
and run the.exe
installer. - Follow the installation steps to create a desktop/start-menu shortcut.
- Use the GUI to:
- Edit and save Lua scripts
- Upload scripts to the STM32 (via serial or dashboard)
- Monitor serial traffic and logs
Note: If Windows flags the installer as unknown, verify the file and allow it to run (common for unsigned test installers).
- Ensure Python 3.x is installed.
- Open a terminal and navigate to:
cd PC Companion Software
- (Optional) Create and activate a virtual environment:
python -m venv venv # Windows venv\Scripts\activate # macOS/Linux source venv/bin/activate
- Install dependencies (if
requirements.txt
is included):pip install -r requirements.txt
- Run the Python script:
python lua_editor.py
- Use the GUI to edit/upload Lua scripts and monitor serial logs.
Serial Connection Tip:
- Connect the STM32 to the PC via USB (if the board supports USB-to-UART) or a USB-to-TTL adapter. Select the correct COM port in the PC tool.
- Flash STM32 firmware and ESP-01 dashboard.
- Open the ESP dashboard and configure protocol parameters (baud, SPI mode, CAN speed).
- Define routing rules using the dashboard or PC tool.
- Edit a Lua script in the PC companion GUI or a local editor.
- Upload the Lua script to the STM32 via the dashboard or serial upload.
- Monitor traffic using the dashboard Terminal or PC companion serial monitor.
-- Example: Wrap UART messages with '#' and forward to CAN
function handle_message(protocol, data)
if protocol == UART then
local wrapped_data = "#" .. data .. "#"
send_message(CAN, wrapped_data)
else
send_message(CAN, data)
end
end
- No ESP IP address: Check ESP-01 serial output at 115200 baud. Verify Wi-Fi credentials (STA mode) or use AP mode if available.
- Garbled serial data: Ensure matching baud rates and 3.3V logic levels between STM32 and ESP-01.
- CAN not visible: Check CAN transceiver wiring and termination resistors (120Ω at each bus end).
- Lua scripts not executing: Verify upload success and check Lua VM logs in the dashboard Terminal. Test with small scripts.
- Installer blocked: On Windows, right-click the
.exe
and select "Run as administrator" if needed.
- ✅ Prototype completed and tested in lab: Low-latency protocol bridging, stable Lua execution.
- 🚧 Planned features:
- Cloud integration (MQTT/HTTP)
- Auto protocol detection and heuristics
- Enhanced routing UI and traffic analytics
This project is licensed under the MIT License. See the LICENSE
file for details.
- Ghaith Jebali — Firmware and system design, report author
- M. Yassine Boussa — Academic supervisor
- M. Halim KACEM — Industrial supervisor (CSF)
For assistance with building, flashing, or running the tools, open an issue in this repository and include:
- Your operating system (Windows/macOS/Linux)
- PC tool version used (installer or Python script)
- Serial logs (if applicable) and wiring description