The ESP32 is a cool little device, and the ESP32-WROVER can be purchased in bulk for as low as $3. As hardware becomes faster, more powerful, and cheaper, C/C++ is no longer the only choice for embedded systems programming. After following the initial setup instructions below, everything can be done in the web browser from editing Lua code to controlling the servo via WebSockets, and loading a trusted TLS certificate from Let’s Encrypt.
The ESP32 and the free ESP-IDF development environment is a great starting point for anyone interested in running the Barracuda App Server on FreeRTOS. The development environment, which can be downloaded from GitHub, includes a ready to use FreeRTOS setup and the lwIP TCP/IP stack.
The following video gives a quick introduction on how to compile and use the included Barracuda App Server example. The servo control example, shown in the video below, is based on the design pattern explained in the article Modern Approach to Embedding a Web Server in a Device.
All you need is an ESP32 with pSRAM such as ESP32-WROVER and the free ESP-IDF development environment. The following is a set of compressed installation instructions for this environment. Consult the official ESP IDF documentation if you feel you need more information.
We recommend using the Linux ESP-IDF version and if you are on Windows, just install the "Windows Subsystem for Linux". It's super easy to install and use. Just open the Windows 10 Store and search for Ubuntu. See this tutorial if you feel you need more information.
Open the Ubuntu shell after installation and make sure to enable copy and paste so you can copy the commands below and paste the commands into the shell using Ctrl-Shift-V.
The following set of commands work on standard Linux and the Windows Linux subsystem. Copy the commands below and paste the commands into the Ubuntu shell:
1: Update system:
2: Upgrade system:
3: Install required tools:
4: Install ESP-IDF:
We can install the ESP-IDF as soon as the above set of commands completes. Copy and paste the following commands:
The last command above sets up the path to the ESP IDF tools such as the compiler. You must run this command each time you open a new Ubuntu (Bash) shell.
You should now be in the ~/esp directory if you followed the above commands and the environment should be ready for compiling the Barracuda App Server example.
Using git, clone the Barracuda App Server ESP32 Github repository as follows:
Windows tip: If you are using Windows and not accustomed to the Windows Subsystem for Linux or prefer to edit files using standard Windows tool, you may instead clone LspAppMgr-ESP32 in, for example, c:\develop. You may run the following commands from the Windows Subsystem for Linux if you have the directory c:\develop :
The next step is to configure the build and set your own Wi-Fi credentails. Enter the following command to start the configuration tool.
Using the configuration tool, navigate to "Example Connection Configuration" and set your Wi-Fi credentials. Save the configuration data and exit the configuration tool.
You are now ready to build the example. Simply type the following to compile the example:
You may flash (upload) the code to the ESP32 as soon as you have compiled the code; however, you may first have to install Silicon lab's USB to UART drivers if you are using Windows. The drivers are needed when flashing the ESP32.
Attach the ESP32 to your computer using USB and upload the example as follows:
Windows Linux sub system:
The above command is for COM4. See the Windows Device Manager for the port assigned to your ESP32. We had problems with the default baud rate, which is 460800. The above command sets the baud rate to 115200.
The example should start and connect to your Wi-Fi as soon as the code is uploaded. Consult the Github repository's README.md file for what to do next.
Python may be the king of the desktop, but Lua rocks in embedded systems. Python's main focus is to be a generic and easy to use command line scripting language, while Lua is designed to be a C Library with its main focus on being easy to integrate into a larger program. Lua is found in many games such as World of Warcraft. Lua has traditionally been selected when speed and size matters. Developers generally find Lua to be much faster and less resource hungry than Python. A developer that knows Python will find it easy to learn Lua since both languages are similar.
The C/C++ programming languages dominate embedded systems programming, but developers often run into issues such as buffer overflows, memory leaks, and other memory corruption errors. With Lua you avoid these problems, particularly in larger projects where many computer programmers with varying skills are involved.
Lua abstracts out the details for the underlying microcontroller hardware. Instead of worrying about the bits and the bytes, a developer simply accesses methods of a peripheral object to control the hardware. Hardware control is done via a so called Lua binding. The abstraction of the hardware layer allows developers to focus on the application specifics rather than on the workings of the low-lying hardware.