DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Related

  • A Deep Dive Into Firmware Over the Air for IoT Devices
  • Optimizing Firmware: The Key to Shipping IoT Devices on Time
  • 4 Best Practices for IoT OTA Updates
  • IoT and Cybersecurity: Addressing Data Privacy and Security Challenges

Trending

  • Intro to RAG: Foundations of Retrieval Augmented Generation, Part 2
  • SaaS in an Enterprise - An Implementation Roadmap
  • Next Evolution in Integration: Architecting With Intent Using Model Context Protocol
  • Building Reliable LLM-Powered Microservices With Kubernetes on AWS
  1. DZone
  2. Data Engineering
  3. Big Data
  4. Easy IoT and Device Management for Non-C Coders

Easy IoT and Device Management for Non-C Coders

You will find learning Lua to be super easy if you have worked with other scripting languages — it's the language for children!

By 
Wilfred Nilsen user avatar
Wilfred Nilsen
·
Updated Jan. 07, 23 · Analysis
Likes (3)
Comment
Save
Tweet
Share
28.1K Views

Join the DZone community and get the full member experience.

Join For Free

If you're interested in using microcontrollers for home monitoring or developing commercial IoT products, but don't have any experience with C programming, then this tutorial is for you! You'll learn how to get your projects up and running quickly and easily using a high-level language called Lua. With this tutorial, you won't need any prior C experience, and you'll be able to install the ready-to-use microcontroller firmware by following a few simple instructions. Plus, you'll be able to learn the basics of programming microcontrollers in a fun and interactive way, which will help you to build your skills and confidence as you progress. So why wait? Start learning today and take the first step towards creating exciting and innovative projects with microcontrollers!

Lua - easy for kids to learn and also powerful enough for developing professional IoT solutions!

The Lua language, which is similar to Python, but easier to learn, is very common in the gaming industry. For example, the Roblox game engine provides a free developer environment allowing anyone to create games in Lua. The gaming industry uses Lua since it is easy to embed the Lua virtual machine into a larger program, and the language makes it easy to program the ever-increasing complexity in the game's state machines.

An experienced C developer could take the stock Lua C code delivery and embed it into a microcontroller. One can also download ready-to-use Lua microcontroller versions such as NodeMCU and eLua. However, neither stock Lua, NodeMCU, or eLua includes any useful IoT capabilities. What we need is an IoT library that includes common IoT protocols such as HTTPS, MQTT, SMTP, etc. For professional products, one also needs a framework with easy-to-use security components such as X.509 certificate management. That's where the Barracuda App Server comes in. It provides a complete IoT solution specifically designed for Lua developers, making it easy for you to build secure and reliable IoT products that meet your needs.

This is a Hands-On video tutorial using the ESP32 microcontroller. The firmware (Lua + IoT library) and example Lua code can be downloaded from GitHub.

We use an ESP32 in the video tutorial, but Lua can run on most embedded systems. You can follow along the video tutorial with your own ESP32 WROVER if you follow the firmware installation instructions at the end of this tutorial.

In this 19-minute video tutorial, you'll learn how using Lua can significantly speed up the interactive development time of an IoT-enabled headless device. A headless device is one that has no onboard graphical user interface. To make the development process even faster, we'll use a web-based Lua IDE (a so-called REPL) and the Barracuda Application Server running on the microcontroller. This will allow us to quickly prototype and test our code as we go. 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. This is a great way to quickly and easily build and deploy IoT projects, and you'll be able to see for yourself just how powerful and efficient Lua can be. 

It's important to note that in the video tutorial above, the web-based development environment was removed from the firmware before creating the final release. This is because the IoT example shown in the tutorial does not require an embedded web server.

However, an embedded web server can be very useful for an IoT-enabled product, as it allows for direct interaction with a device running within an intranet. The following video shows how a servo can be controlled in real time using an HTML app powered by WebSockets. The server-side code that controls the servo and manages the WebSocket communication is all written in Lua. This is just one example of how Lua can be used to build powerful and interactive IoT applications, and you'll find that it is a great language for building a wide range of projects.

The above video also shows one of the really cool features enabling the web server to automatically obtain a trusted X.509 Intranet certificate signed by Let's Encrypt. To learn more about how this works, see my DZone article Certificates for Intranet Servers.

Firmware Installation Instructions

 As mentioned above, The Lua REPL consists of two main components: the Barracuda App Server and the LSP Application Manager. To use the Lua REPL, these two C code components must be compiled together with the Espressif IoT Development Framework and some startup code. This will create a firmware image that can be uploaded to your ESP32 microcontroller, allowing you to start developing Lua programs on the ESP32.

There are two options for installing the firmware for the Lua REPL, and which one you choose will depend on your experience with running command-line Linux, such as using the Linux Subsystem for Windows.

If you have command-line experience and want to understand the C code compilation and firmware building process in detail, you can follow the Lua ESP32 IoT Developer Kit command-line tutorial. 

Alternatively, you can download the virtual machine-based IDE that lets you use a web-based UI for compiling the necessary C code and uploading the produced firmware to the ESP32. Just keep in mind that the IDE includes many examples designed for C programmers, so you'll want to focus on the example designed for compiling and uploading the LSP Application manager. This will allow you to get up and running with the Lua REPL as quickly and easily as possible, regardless of your experience level.

Here's a Fun Example Project:

The owl in the following video, with its blinking eyes and servo-controlled head, is powered by Lua using the Barracuda App Server. The software runs on an ESP32, which includes a Lua REPL called the LSP Application Manager that is based on the Barracuda App Server. See the video description for additional details.


IoT Lua (programming language) Web server Firmware

Opinions expressed by DZone contributors are their own.

Related

  • A Deep Dive Into Firmware Over the Air for IoT Devices
  • Optimizing Firmware: The Key to Shipping IoT Devices on Time
  • 4 Best Practices for IoT OTA Updates
  • IoT and Cybersecurity: Addressing Data Privacy and Security Challenges

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!