For the next part of my ESP8266 experiments, I’m going to need LUA running on my RPI, so I want to document the process.
I first stumbled across LUA last fall when I was playing with CHDK – it is one of the scripting languages available to control canon cameras using CHDK. So far, I kind of like it. I detest Perl and just have never really got into Python either. LUA is really what I expect from a scripting language. A clean, simple, easy way to do quick and dirty stuff which doesn’t warrant spending time writing a real program.
The fact LUA’s basic syntax takes only 5 pages of the manual is a bonus. It’s easy enough I might actually remember the syntax between projects.
Turns out, LUA was already installed on my Raspberry Pi. I easily verified this by just typing lua:
rpi/~:lua Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio >
You can also check with whereis:
rpi/~:whereis lua lua: /usr/bin/lua5.1 /usr/bin/lua /usr/bin/X11/lua5.1 /usr/bin/X11/lua /usr/share/lua /usr/share/man/man1/lua.1.gz rpi/~:
If it isn’t installed, install it with:
sudo apt-get update sudo apt-get install lua5.1
I notice there is a lua5.2 available as well. I know what I’m trying to do works with 5.1 so that is the version I am choosing.
I also need the networking module. That is installed with:
sudo apt-get install lua-socket
Other lua modules you may have interest in can be found with this command:
apt-cache search '^lua-.*'
Now create a simple test program such as this helloworld:
rpi/lua:vi helloworld #!/usr/bin/lua print ('hello world')
Make it executable:
rpi/lua:chmod 755 helloworld
and finally try it out:
rpi/lua:./helloworld hello world rpi/lua:
Now I’m ready to write some networking code in LUA on my RPI.
Pingback: ESP8266 UDP to/from Raspberry Pi running LUA | Big Dan the Blogging Man
Pingback: SNMP Environmental Monitoring using ESP8266-based Sensors | Big Dan the Blogging Man
I had lua on my Pi, I get that you can use a terminal to write and make executable…as-well as run code, but I am trying to get a basic interpreter on the Pi for Lua…I have many editors, but I struggle with other languages when I want to run code with additional modules…
What I am looking for is Lua’s standard interpreter – Like Pythons IDLE for example. Something I can edit code easily with, and save and import things etc. I am still learning so please bare with me – Is there a basic interpreter? A search shows there is, but a normal sudo apt-get install just gives me the files needed to run in a terminal. I also have a tarball of it from their site – to try manual installation, I thought it might be included like IDLE is with Python. I got fatal errors when running the make command?
Please help me if possible. I have stumbled across a Lua editor with lessons on my Win10 PC (ZeroBrane) and it seems quite a nice language, plus more suitable than python for a 3D game idea I want to mess around with!
I have only used Lua two times so I really don’t know much about it; however, on my PC I have SciTE installed which is a front-end for Lua. It may be what you are looking for. And if it is available for windows, I’ll bet there is a version for linux as well.