Building and Deploying MicroFMU on ESP32
Overview
This guide explains how to compile MicroPython with MicroFMU for ESP32 and deploy it to the microcontroller.
Prerequisites
ESP32 board
Installed ESP-IDF toolchain
MicroPython source code (
micropython_dir
set correctly)USB serial drivers for ESP32
Steps
Navigate to the ESP32 port directory
cd "$micropython_dir/ports/esp32"
Initialize ESP-IDF and set environment variables
. $HOME/esp/esp-idf/export.sh
Compile MicroPython with MicroFMU
make submodules make USER_C_MODULES=$micropython_dir/MicroFMU-library/micropython.cmake
Flash MicroPython onto ESP32
make erase make deploy USER_C_MODULES=$micropython_dir/MicroFMU-library/micropython.cmake
Run FMU Simulation on ESP32
Connect via serial and run:
>>> import ufmu as fmu >>> simulation = fmu.setup_simulation(0, 3, 0.1) >>> for step, time, h, _, v, _, g, e in simulation: ... print(time, h)