The Internet of Things is a new reality in our world. It helps people automate, monitor, and control their lives. IoT makes it possible for every device in the world to send data about itself and allows the building of smart cities and even smart countries.
IoT is a transformative force that reshapes industries, enhances our daily lives, and propels us into an era where our devices and environments are becoming increasingly interconnected and intelligent.

According to IoT Analytics, the number of connected IoT devices growing by 16% to 16.7 billion globally. That number is estimated to reach as high as 75 billion by 2026. Image source:

According to PRIMEIQ RESEARCH (OPC) PRIVATE LIMITED, the IoT Market is expected to grow from USD 0.20 Billion in 2022 to USD 1.07 billion by 2030, at a CAGR of 23.10% during the forecast period.
As IoT continues to expand, the need for robust and reliable technology becomes more and more obvious. This is where the role of programming as the backbone of IoT development is the most visible. Among these, Rust, known for its emphasis on safety and performance, emerges as a particularly compelling choice for IoT with Rust applications. Its unique features offer solutions to some of the most pressing challenges in IoT development, including memory safety, concurrency, and system reliability.
In the next few minutes, we will explore the essence of IoT, its profound implications, and weigh the advantages and disadvantages of utilizing Rust, a modern programming language, in IoT development.
Why should Rust be your go-to choice for IoT projects
Reliability, efficiency, and security are especially meaningful in IoT, so Rust emerges as a rational choice for developers. This programming language, known for its focus on safety and performance, addresses several critical challenges faced in IoT development. Let’s delve into the reasons why Rust is becoming the go-to choice for IoT projects.
Rust is a popular multi-paradigm programming language that provides significant performance, safety, and noticeable flexibility. Since Rust is a compiled language with zero-cost abstractions, it allows the language to compete in the same space as C and C++ due to its speed, safety, and flexibility.
According to the benchmark Rust is at least as fast as C++ and even faster in some cases.

Since IoT products include at least two parts of the system: smart devices( e. g. sensors) and cloud or edge servers that handle all information from devices, let’s talk about IoT devices and how rust can help there.
The majority of IoT devices contain low-performance CPU ( like ARM, etc) and have minimum RAM memory and persistent storage. It means that firmware for such devices should be highly effective and should be minimum size.
Rust is a system programming language which means that this language is effective for low-level programming and it also allows to user to control memory and get all power from any kind of hardware. Rust is good for embedded systems since it provides zero-cost abstraction and allows engineers to use high-level conceptions in low-level programming, making code more readable, maintainable, and flexible for the future.
Rust for IoT. Advantages
Safety and Reliability: Rust’s strong emphasis on safety and memory management extends to cloud server applications. This can help prevent common security vulnerabilities and ensure the reliability of your cloud-based services, which is crucial when dealing with IoT data.
Concurrency: Cloud solutions often require handling a large number of concurrent connections and tasks. Rust’s ownership system and concurrency model make it well-suited for building scalable and concurrent server applications.
Performance: Rust’s focus on performance optimization can result in faster and more efficient cloud services, allowing for quick processing and response to IoT device data.
Cross-Platform Compatibility: Rust’s cross-platform capabilities extend to cloud infrastructure, making it possible to run Rust-based services on various cloud providers and architectures.
Web Assembly (Wasm) Support: Rust can compile to WebAssembly (Wasm), making it suitable for building IoT-related web applications and services, and enhancing the user interface and interaction with IoT devices.
Open Source Community: Rust has a growing and active open source community, providing libraries and tools that can be useful for cloud development, such as web frameworks and database connectors.
Disadvantages IoT with Rust might cause
Learning Curve: As mentioned previously, Rust has a learning curve. Developers new to Rust may require time and training to become proficient in the language, potentially impacting project timelines.
Ecosystem Maturity: While Rust’s ecosystem is growing, it may not have as mature or comprehensive libraries and frameworks for cloud development as some other languages.
Talent Pool: Finding Rust developers with expertise in cloud development can be more challenging than finding developers for more established languages like Python or JavaScript.
Integration: If your cloud solution needs to integrate with other services and technologies, you should ensure that there are compatible Rust libraries or consider the effort required to build necessary integrations.
Let’s compare Rust with C and C++

As we can see, Rust is a wise technology choice and has multiple winning points over C and C++. The ecosystem of Rust is still growing and become better than C and C++ in the toolchain. Also, the build system and ‘God level’ infrastructure in Rust offer significant advantages for starting new projects. The constantly evolving ecosystem provides more and more quality libraries and frameworks for working with projects of varying complexity.
Rust in Action: Real-World IoT Use Cases
The theoretical advantages of Rust for IoT development are compelling, but it’s in the real-world applications where its capabilities truly shine. Below are some noteworthy use cases demonstrating how Rust is being leveraged in IoT projects, showcasing its versatility and effectiveness.
Smart Home Devices
In the domain of smart home technology, Rust has been used to develop secure, reliable, and high-performance devices. Companies are adopting Rust to build firmware and control systems for devices like smart thermostats, lighting, and security systems. Rust’s memory safety and concurrency features ensure these devices operate reliably over long periods, often with minimal maintenance, while its security features protect against common vulnerabilities, a crucial aspect in the home automation space.

Samsung – one of the world’s technology market leaders- uses Rust for IoT Devices in the Smart Home Solution.
Rust for IoT projects in industrial automation
The industrial sector is increasingly utilizing Rust for building IoT solutions that require high reliability and performance. For instance, Rust is employed in the development of sensors and controllers in manufacturing lines. These devices often need to process large amounts of data in real time and make rapid decisions. Rust’s performance efficiency and ability to handle concurrent operations make it an ideal choice for such applications.
One of the biggest industrial automation open-source platforms was rewritten to Rust.

Agricultural IoT Solutions
Agriculture is another field where Rust-based IoT solutions are making an impact. Developers are using Rust to create sensor networks that monitor environmental conditions like temperature, humidity, and soil moisture. These sensors help in making data-driven decisions for crop management. Rust’s efficient use of resources is particularly beneficial here, as many agricultural IoT devices like Slowtec or Netlume are deployed in remote locations with limited power and connectivity.
Rust performance for IoT in transportation and logistics
Rust is also finding applications in the transportation and logistics industry. For example, it’s being used in IoT systems for vehicle tracking, fleet management, and cargo monitoring. These systems benefit from Rust’s robustness and its ability to function consistently across different hardware and network conditions.
For example, Routific uses Rust for route optimization in the delivery business. Nextbilion, Deliveroo and Bepark are some more great use cases of Rust in IoT for logistics
These use cases illustrate just a few examples of how Rust is being effectively applied in various IoT domains. Its blend of safety, performance, and cross-platform capabilities not only makes it a practical choice for current IoT needs but also positions it as a forward-thinking solution for the challenges of tomorrow’s interconnected world.
Rust IoT Ecosystem
Tockos

TockOS is an open-source operating system specifically designed for running on microcontrollers in IoT (Internet of Things) devices. It is unique in its approach as it is written entirely in Rust, a programming language known for its focus on safety and efficiency.
Key Features of TockOS
Memory Safety: One of the core advantages of TockOS, derived from its Rust foundation, is its memory safety. This feature is crucial in preventing common programming errors that can lead to security vulnerabilities, especially important in IoT devices that are often deployed in security-sensitive environments.
Multitasking with Security: TockOS supports multitasking, enabling IoT devices to run multiple applications concurrently. This is achieved through a capsule model, which isolates applications from each other, thus providing security and stability.
Low Overhead: TockOS is designed to be lightweight, making it suitable for IoT devices with limited computing resources. Its efficiency is a significant advantage in scenarios where devices must operate with minimal power and memory usage.
Open Source and Community-Driven: Being an open-source project, TockOS benefits from community contributions. This aspect fosters continuous improvement and adaptation, keeping the OS up-to-date with the latest technological advancements and security practices.
Targeting Constrained Devices: TockOS is specifically tailored for microcontrollers and constrained devices, which are common in IoT applications. This focus ensures that the OS is optimized for the types of hardware typically used in IoT systems.
RIOT
This is an operating system for IoT written in C. However, it is a popular operating system and framework, specifically designed for IoT, with support for various protocols such as MQTT, TCP, QUIC, LoRaWAN, Bluetooth, Wi-Fi, etc. Riot provides native support for various microcontrollers, including eight-bit ones.

One of the advantages and important steps is the introduction of Rust support. It’s possible to write applications using Rust, but if you look at their documentation, it’s more likely that you’ll get lost in how to do it rather than understand it. However, this indicates that Riot is considering the use of Rust for software development, which is a positive step for the future. Riot is well-documented, even better than TOCKOS, and has efficient tooling, including Cargo support.
Embassy
This is not an operating system, but a framework for IoT that has its own asynchronous executor. Its main advantage is that it allows for asynchronous operation, which simplifies writing functions using async/await. The framework has its own task scheduler and supports a wide range of tasks.

Other

There are also other smaller projects which will be good for the IoT and Rust. For example, the Hardware Abstraction Layer (HAL), which has an entire repository on GitHub and describes hardware abstraction for Rust, is intended for use on various platforms. Another example is AWS IoT Core, which offers an ecosystem for IoT as a service. They have an SDK for Rust that allows writing applications for microcontrollers using Rust, working with their protocols. Eva is another IoT framework that provides support for various protocols and allows writing applications in Rust. Some less popular libraries and protocols can be found on Create.io, such as libraries for LoRaWAN, MQTT, Quic, LWM2M, CoAP, as well as for security, Bluetooth, Wi-Fi, and other IoT protocols. Although some of these libraries may be less mature, they are constantly evolving, and with the growing demand, there will be a supply of new and better solutions in this area.
Practice
I made a small project by using ESP32, which might seem simple but at the same time is very useful for understanding how embedded devices work with Rust.
Here you can find decent guidelines for ESP32 and Rust: github
First of all, we need to install Rust.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
And after that, we need to install a cargo generator which will allow us to use templates.
cargo install cargo-generate
ESP has its own project templates that can be used. There are templates for both std and no-std usage. Let’s generate a project using std.
cargo generate esp-rs/esp-idf-template
The generator itself is quite interactive and, besides the name of the project, allows you to choose the following options:
- MCU target – the chip for which the firmware will be written.
- A version of the ESP-IDF library
- std or no-std
- Use of Dev Containers – a very convenient mechanism that allows you to develop the program in a Docker container, where all the necessary programs will already be installed. This is very convenient to use in combination with VS Code. Since it allows you to simply open the project folder and engage in development without worrying about installed libraries or programs.
- Use of the Wokwi simulator – this is a program that allows you to simulate work with various microcontrollers, as well as peripherals that can be connected to these microcontrollers. Very convenient for those who still don’t have a real device.
After the generator generates the project, its structure will look like that:

This structure fully allows you to engage in programming without worrying about infrastructure, as it is already deployed here.
- In the scripts folder, there are necessary scripts to compile the project and upload it to a real device.
- wokwi.toml and diagram.json are configuration files that allow you to launch the simulator. You will need a license for the simulator, it’s free and can be obtained here: https://wokwi.com/license?v=2.1.1&r=LicenseMissing&s=v
Let’s create a fairly simple project with an LCD display connected to an ESP32 that will display on the screen: Hello World, Rust & Yalantis. Actually, this example was taken from the Wokwi site and serves to show the capabilities of Rust and its ecosystem.

I will not detail all the code for working with the LCD, but will only show main.rs, where all the logic is executed:
use esp_idf_hal::i2c::*;
use esp_idf_hal::prelude::*;
use esp_idf_hal::delay::FreeRtos;
use esp_idf_hal::peripherals::Peripherals;
mod lcd;
fn main() -> anyhow::Result<()> {
let peripherals = Peripherals::take().unwrap();
let i2c = peripherals.i2c0;
let sda = peripherals.pins.gpio6;
let scl = peripherals.pins.gpio5;
let config = I2cConfig::new().baudrate(100.kHz().into());
let mut i2c = I2cDriver::new(i2c, sda, scl, &config)?;
let _ = lcd::init(&mut i2c);
let _ = lcd::backlight(&mut i2c);
let _ = lcd::set_cursor(&mut i2c, 0, 1);
let _ = lcd::print_str(&mut i2c, " Hello, World");
let _ = lcd::set_cursor(&mut i2c, 0, 2);
let _ = lcd::print_str(&mut i2c, " Rust & Yalantis");
loop {
for _ in 0..3 {
lcd::scroll_left(&mut i2c);
FreeRtos::delay_ms(100);
}
for _ in 0..2 {
for _ in 0..6 {
lcd::scroll_right(&mut i2c);
FreeRtos::delay_ms(100);
}
for _ in 0..6 {
lcd::scroll_left(&mut i2c);
FreeRtos::delay_ms(100);
}
}
for _ in 0..3 {
lcd::scroll_right(&mut i2c);
FreeRtos::delay_ms(100);
}
for _ in 0..3 {
lcd::no_backlight(&mut i2c);
FreeRtos::delay_ms(250);
lcd::backlight(&mut i2c);
FreeRtos::delay_ms(250);
}
}
}
The program code is quite simple; it displays the specified text on the LCD and moves it across the LCD at intervals of 100 ms. After this, we can compile the project:
cargo build
And set the path to the binary file in wokwi.toml.
[wokwi]
version = 1
>gdbServerPort = 3333
elf = "target/riscv32imc-esp-espidf/debug/example"
firmware = "target/riscv32imc-esp-espidf/debug/example"
Clicking on diagram.json will launch the simulator. It will take the firmware from the specified location automatically and run the project as if it were running on a real device.

This is all that this example does, but much more important are the possibilities that this infrastructure and Rust provide for developing prototypes and their debugging. Wokwi also allows you to run the program in debug mode and debug the program.
Summary: choosing Rust for IoT projects is (mostly) a great idea
So, Rust is a decent choice for IoT and Embedded projects. The language ensures type-level safety and helps avoid null-pointers, as well as eliminates undefined behavior. For more complex projects, the support for concurrency and the ability to use multitasking mode is important, and Rust provides this possibility. For the language’s success, the ecosystem must continue to grow and be filled with various libraries and frameworks. Support from large companies, such as Microsoft and Google, also speaks to the language’s potential. Despite all the advantages, Rust still has disadvantages: the maturity of the ecosystem, a high entry barrier, and a variety of tooling. Rust is characterized by its versatility, supporting various fields, including Embedded, Game Development, and Backend Development. Although Rust development might be slower compared to other languages, it compensates with the safety, productivity, and convenience of tools.
Rate this article
4.9/5.0
based on 17 reviews