In the following video tutorial, we show how Lua can be used to rapidly and interactively develop control logic in an embedded FreeRTOS system without having to compile or upload new firmware during the development process.
From a device perspective, IoT typically means acting as a network client. This tutorial focuses on using Lua and the Barracuda App Server network libraries to simplify the design of an IoT device client. The web server component is used for the initial development, then later disabled in the final product since only the network client libraries are needed.
What is an IoT device?
An IoT device is simply a network-enabled client that sends and/or receives data from an online cloud server. The data transmitted can be anything including sensor data and control messages. IoT device protocols include HTTP, MQTT, WebSockets, SMQ, OPC-UA and so on.
The high-level Lua language is well suited for running on embedded systems, including microcontrollers. You may have used other high-level languages, such as Python, and you will find Lua very similar to Python. In general, high-level languages, including JavaScript, have much in common. We like to refer to Lua as a high-level language and not a scripting language since the code is compiled into machine code. However, the machine code is run on a Lua virtual machine and not natively on the microcontroller. In general, you will find Lua being fast when it is used for what it is good at.
The real benefit of Lua comes when mixing real-time modules implemented in C code with control logic designed in Lua. The dynamic nature of Lua enables the developers to interactively test control code in an embedded device without having to build and upload new firmware. See the tutorial Why Smart Developers Use Both Lua and C Code for additional details on the benefits of embedding Lua in firmware.
John Doe: Stressed Out Until Barracuda App Server Saved the Day.
In the video below, we will look into how Lua can significantly speed up the interactive development time of an IoT-enabled headless device. A headless device simply means it has no onboard graphical user interface. We will use a web-based IDE and the Barracuda App Server running on the microcontroller during the interactive development process to speed up the development time. When the development is complete, the web-based IDE will be removed, and the final IoT application implemented in Lua will be embedded as a ZIP file inside the firmware image.
The video below shows the complete development process from rapid interactive development to creating the final firmware release. The video starts by providing an introduction to the available tools and documentation.
We use an ESP32 in the video tutorial below, but Lua can run on most embedded systems. You can follow along the video tutorial with your own ESP32 if you install Xedge32, the Barracuda App Server for ESP32.
While the video tutorial above is still relevant and valuable, we’ve significantly enhanced the LSP Application Manager showcased in it. Now rebranded as Xedge32, it leverages the web-based Visual Studio Code Editor, providing a far more streamlined and improved development experience along with many Xedge deployment options.
Xedge32 is a tool designed for edge computing. It efficiently handles data collection, basic analytics, and connectivity directly at the edge, minimizing the need for immediate cloud interaction and making your edge infrastructure more efficient and responsive. With its capability to send processed data to larger systems using various supported protocols, Xedge32 acts as a bridge between your sensors and your central data platform. Designed as a ready-to-run software package for the ESP32 processor, it's particularly suited for projects focused on developing their own hardware.
Xedge32 is Secure by Design and simplifies the development of secure and EU Cyber Resilience Act compliant products. It features built-in support for OTA firmware updates and is easily integrated with cloud-based delivery services. With a TPM and a user database vault, Xedge32 ensures robust protection of sensitive information. Applications can be both signed and encrypted, preventing the installation of non-vendor applications. Xedge32 streamlines security by automatically installing trusted X.509 TLS certificates.
The video above, starting at 16:45, demonstrates how to replace the integrated Xedge32 IDE with a custom application. In other words, the BAS-Resources shown in the following figure are swapped out for custom code in the final product. However, this is just one example - the Barracuda App Server development platform is highly flexible and can accommodate any deployment strategy you require. See the Xedge Build Documentation for details and the section Xedge: Creating a Release Build for the various release options.
Get a quick introduction to Lua by following our Online Interactive Lua Tutorials
Don't let networking, security, and device management hold you back! Let Real Time Logic help your business, development team, or customers save time and money by handling these complex tasks for you.
With a wealth of experience creating IoT solutions and embedded device interfaces, we're well-equipped to dramatically improve your products and how you build them. And if you prefer to tackle things on your own, check out our extensive list of embedded web server and IoT tutorials.
Whether you choose to work with us or take the DIY route, we're here to help you succeed. Let's team up and make your vision a reality!