Software overview


The ESP8266 may be programmed using:

  • any programming language that has a compiler that creates the machine code that the processor understands.
  • any programming language that has an interpreter that can be uploaded (programmed).

Anyway, there is also the problem of actually putting the compiled program or the interpreter in the processor and, in the later, to upload the code to be interpreted. All this is done usually using a few open-source programs and the serial port (USB for NodeMcu boards).

Note: There is also a firmware for running AT commands. "Fresh" boards usually come pre-programmed with it, but I'll not study it.

Interpreted e-Lua (NodeMcu - my focus on this notebook)

First, the interpreter is uploaded (flashed) to the flash memory using a "flasher" program. There are a few open source flasher programs (next chapter) available.

Once the interpreter is flashed, it constantly runs a program (sort of an Operating System) capable of:

  • take care of the file system;
  • receive NodeMcu commands (mostly Lua) and data over the serial port;
  • execute the code of any .lua program in its file system.

Compiled C++ (Arduino):

The most popular compiled language is C++, programmed through the Arduino IDE. There are many explanations on the web about using the Arduino IDE to program the ESP8266.

What the Arduino IDE does is:

  • use a library to define special commands (about pins, serial ports etc.) and thus create an "Arduino language".
  • use gcc C++ compiler to produce an .elf file (and a few extra files) compatible with Tensilica's xtensa processor.
  • then use a program called esptool.exe (not esptool.py) to convert that .elf file into a .bin file and to "flash" (upload) it to the flash memory.

NodeMcu vs Arduino

NodeMcu system occupies a LOT of memory, so there maybe little left for your program. In fact, it is usual to create a custom made bynary file of the NodeMcu system for each specific application, so you only add the modules you really need. However, most NodeMcu boards these days come with 4M or more (Wemos D1 mini does) and lack of memory space seems to be a problem only to smaller modules.

Arduino on the other hand uses all the available memory to your program, and there is usually a lot of space for it.

On the other hand, every time you change your Arduino program, you re-flash the entire memory with it, while NodeMcu allows you to upload as many .lua files as you want (if you have space) and/or delete them. The Lua programs are just files in the NodeMcu file system.

My focus in this notebook is the NodeMcu Lua interpreter. First because I couldn't find a good comprehensive beginners guide on the internet, and second because I like the way it feels like a little computer from the 80's, where you can save your programs and interact with the "operating system".

results matching ""

    No results matching ""