r/lua • u/Livid-Piano2335 • Jun 29 '25
Discussion Lua on microcontrollers. Surprised how far it’s come
Been mostly using lue for small scripting stuff over the years, config files, quick automation etc. Always loved how clean it feels but never thought of it as a serious option for embedded devices.
Recently tried out a setup where you run lua code directly on an esp32 and it honestly blew me away. Like full scripting, GPIO access, MQTT, TLS, even OTA updates and all of it handled from a browser based IDE. Didn’t expect that level of capability from such a tiny chip running Lua.
Curious if anyone else here is experimenting with Lua on constrained devices? I know NodeMCU is a thing, but this felt a bit more full featured.
4
u/ziggurat29 Jun 30 '25
and remarkably stable. I have devices that have been running continuously for 6 years now with no crashes other than power outages.
your post suggest you are /not/ using NodeMCU, so I would be interested in hearing what that platform is.
2
u/stahom Jul 07 '25 edited Jul 07 '25
Don't know if this is off topics. I've ported embLua (from https://github.com/szieke/embLua) to STM32F401 and STM32H723. Running Lua on M0 will be RAM constraint. Even on a 128KB RAM STM32F401, the RAM left for user application is very little. That's why I migrated to STM32H723 that gives 90KB of RAM for user application.
Take a look on https://7145d33p.wordpress.com/?s=emblua . The posts are not well organized as it is just to log my works. There is a test on toggling MCU's IO by a C API that writes to the MCU registers directly.
12
u/ineedanamegenerator Jun 29 '25
Been using it professionally since 2012. Most of our products use Lua for their application layer/GUI. Been advocating this for a long time. Nice to see it getting picked up more.
Our platform is mostly STM32 based. Multi threading support and a lot of low level API available. Almost nothing we can't do from Lua.
4
u/ibisum Jun 29 '25
Lua was designed specifically for this use case, so you shouldn’t be surprised really. It started out as a configuration tool for embedded devices, after all..
1
u/[deleted] Jul 07 '25
What microcontrollers work with Lua?
2
u/FrostVirux Jul 03 '25
Adafruit has a tiny MCU called qtpy, one version using Raspberry's rp2040 chip.
Of course Python is the most supported but I don't like Python, plus I use Lua in game modding and wanted to prototype from game to my chip using the same code.
There's a project called MicroLua (not to be confused with some Nintendo DS thing) that's a Lua layer for Raspberry's SDK (PicoSDK) It's meant for Pico's so I'm kind of doing a niche/unsupported thing using it on a qtpy
https://github.com/MicroLua
Super hard for a noob though, especially on Windows. Had to use WSL (linux emulator-ish thing) to get it building (it was mad about "C:/Program" lol), got the test firmware running but can't seem to get my own projects to work. Which is a shame it seems like a lot of effort went into this. Also nobody seems to be using it so I'm kind of trailblazing
I might give up and just make my own Lua layer on top of Arduino just for the features I need to use, then I'd have neopixel libs and stuff
1
u/[deleted] Jul 03 '25 edited Jul 03 '25
[removed] — view removed comment