Download Here

Transcript
Programming with Lua
Lua is a powerful scripting language that is available on ESP8266 environments. The most
popular implementation of Lua for the ESP8266 is known as the NodeMCU Lua firmware and is
available at its github repository. Some folks interchange the phrase NodeMCU for the Lua
firmware itself so take care to make sure that you understand the context involved.
Builds of the firmware can be downloaded directly as can the source.
Once you have a copy of the firmware you can flash it using your favorite flash tools.
We won't be describing the Lua language itself in this book. There are excellent books already
written on Lua and also references and tutorials can be found on the Internet. Rather, let us look
at the specifics of running Lua on an ESP8266.
Assuming you have flashed an ESP8266 with Lua, you will need to connect a serial terminal to it
in order to interact with it. The serial baud rate should be 9600.
See also:
•
•
•
•
•
•
Github: nodemcu/nodemcu-firmware
NodeMCU firmware Wiki
Lua 5.1 Reference Manual
lua.org
NodeMCU ua Forum on ESP8266.com
nodemcu-unofficial-faq
ESPlorer IDE
The ESPlorer IDE is a development environment for building Lua applications for the ESP8266.
See also:
•
•
•
Esplorer home page
eBook: Getting Started with the ESPlorer IDE
GitHub: 4refr0nt/ESPlorer
GPIO with Lua
Lua has the concept of 13 logical pins identified by 0-12. These pins map to the GPIO pins of an
ESP8266 as follows:
Lua pin
number
ESP8266 Pin
NodeMCU
devKit
Lua pin
number
ESP8266 Pin NodeMCU devKit
0
GPIO16
D0
7
GPIO13
D7
1
GPIO5
D1
8
GPIO15
D8
2
GPIO4
D2
9
GPIO3
D9
3
GPIO0
D3
10
GPIO1
D10
4
GPIO2
D4
11
GPIO9
SD2
Page 229