ESP32 scripting language

Hi, what would be your go-to language in terms of interpreting small chunks of code in an existing C++ firmware on ESP32?

Imagine it as re-usable modules, that will get interpreted on the go. I already tried AssemblyScript with WASM, but scrapped it because of the WASM RAM page size of 64kB.

We need as optimized runtime interpreter (optimally under 40kBs) as possible because of the limited space.

I have looked into:

  • AssemblyScript (WASM) → 64kB RAM page issues, as mentioned above
  • Berry Language (compilation problems, however looks like a good fit)
  • Lua (size issues)

Any other ideas? Thanks a lot!

I’ve once experimented with a rather tiny (but also limited) Python interpreter: https://github.com/pikasTech/PikaPython

It was small enough to fit in the 20kB of RAM for an STM32F103CB (Bluepill, Cortex-M3), so an ESP32 should stem it with ease: https://github.com/maxgerhardt/pikascript-pio-bluepill (2 year old version of the core though!)

There’s also JavaScript: https://github.com/marcelkottmann/esp32-javascript

Try this GitHub - hpwit/ESPLiveScript: A C like compiler for esp32
it’s running on an esp32 classic.
The code is not interpreted but compiled into assembly. → no runtime needed

(Just throwing this out there for future readers finding this via search.)

This is a year late, but since I recently saw this integration and used Lua successfully in a similar system long ago, I’d look for recent developments in Lua.

Being part of the ESP-IDF’s component ecosystem, you’re not alone in maintaining it and Lua is a pretty well known language for embeddings. It’s also really easy to make bindings to “real” C++ objects with a pretty thin layer of goo.