NPLua - Networked Pico Lua

20 November, 2025

As part of preparing myself for the release of SLua for Second Life, I've been trying to take on more projects using the Lua language so that I'll be fully familiar when it's time to use it in-world. Well, I thought to myself, "Why not just write a Lua interpreter then?" Even though the interpreter had to be written in C instead of Lua for its Pi Pico 2W target, it's a fine way to get familiar with some of the functions, especially if some don't work correctly/can't work exactly the same on this hardware. (I'm looking at you, os.execute on a system with no OS!)

However, I really do think that NPLua (I'll explain the name in a bit) has some actual utility! Officially, the Pi Pico supports having code written for it only in MicroPython, C, and assembly. Also, generally you have to have your Pico hooked up to your computer via its USB interface in order to transfer new programs over to it, usually by flashing it and overwriting what's already there. NPLua makes it possible not only to write code for the Pi Pico 2W in Lua, an additional language, but it also allows programs to be uploaded to the Pi over the network, using the telnet protocol. And those Lua scripts only overwrite the last Lua script that you uploaded, not the full software stack on the Pi.

That's right, it's a networked Lua interpreter! "NPLua" stands for Networked Pico Lua (or No Problem Lua, if you're feeling confident). Once the software is flashed to your Pi Pico 2W, you can then set it up anywhere you like as long as it has access to wifi, and be able to write new Lua scripts to it remotely. If you can find some way to expose its port 23 to the internet, you could even send it new scripts truly remotely. Is that something that you want to do, in terms of good network security practices? Well, that's up to you.

In any case, I think I've made a neat toy at the very least! I can now enjoy writing Lua scripts for my Pico, and NPLua has full access to the Pico's GPIO and LED controls, so you could actually make this into a fairly functional little interface if you were so inclined. Every pin on the Pico can be set to input or output mode, and switched on and off. The program is multithreaded, with the scripts running on one core full-time and the telnet and user interface running on the other core. Lua is generally not a multithreaded language, so to me, it makes sense to only provide it with a single core.

Where can you find this wonder of modern software? Well, look no further than right here. You can git clone it, and there are build instructions and a small walkthrough in the README.md file. If you have any other questions, write me a message!



Back