Latest update: March 2015
In this tutorial, we will go over how to execute a basic script.
There are three ways to run your Lua scripts on your FlashAir: on boot, on a write event, or with an HTTP request. Lets put together a quick “Hello World” program to demonstrate.
print("Hello World!") local file = io.open("Hello.txt", "a") file:write("Hello There!\n") file:close()
All this script does is print “Hello World!”, and appends “Hello There!” to a Hello.txt file.
To execute it on boot, edit SD_WLAN/CONFIG and add the following line.
Unmount the Sdcard, the remove and re-insert it. Your script should run immediately!
To execute it every time a file is written, use LUA_SD_EVENT instead.
LUA_RUN_SCRIPT and LUA_SD_EVENT can be used together. LUA_SD_EVENT is ignored until the operation of LUA_RUN_SCRIPT is completed. LUA_SD_EVENT becomes executable after the execution of LUA_RUN_SCRIPT is finished.
You can also execute your script with an HTTP request, for example opening
http://flashair/HelloWorld.lua will display Hello World!.
All sample code on this page is licensed under BSD 2-Clause License