What are Embedded Systems ?
Embedded systems are tiny computers built into devices to perform specific tasks. Unlike general-purpose computers, they are designed for control, automation, and real-time operations. You'll find them in everything from smartwatches to washing machines.
What is ESP32 ?
The ESP32 is a low-cost, low-power microcontroller with built-in Wi-Fi and Bluetooth, developed by Espressif Systems. It's widely used in IoT projects due to its rich set of peripherals, dual-core processor, and community support. Perfect for smart devices, sensors, and wireless applications.
What is Rust ?
Rust is a systems programming language focused on safety, speed, and concurrency. It’s known for preventing common bugs at compile time without needing a garbage collector.
Features of Rust
- Memory Safety : Eliminates NULL pointer and buffer overflows due to it's ownership and lifetimes features.
- Zero-cost abstraction : High-level code with low-level performance.
- Concurrency : Fearless Multithreading without Race conditions.
-
Modern Tooling :
cargo
makes it easier for project management and installing Rust tools.cargo
is for Rust whatpip
anduv
are for Python. - Cross-platform support : From Bare-metal Linux to WebAssembly.
Why use Rust for Embedded Systems ?
Rust offers the performance of C/C++ with memory safety guarantees, making it ideal for low-level, resource-constrained environments. Its strong compile-time checks prevent many common embedded bugs early in development. With growing ecosystem support (like esp-hal
), Rust is becoming a powerful and ergonomic choice for writing safe, efficient firmware for microcontrollers like the ESP32.
Setting up the Environment
This blog assumes that :
- You are using a Linux Distribution (Like Ubuntu, Fedora , Debian or Arch).
- You have installed Rust. If not install it by following the instruction here
- You are familiar with using the Terminal.
Hardware
- ESP32-WROOM
For future blogs, the following sensors are required :
- HC-SR04 Ultrasonic Sensor
- DHT22 Temperature and Humidity Sensor:
- Touch Sensor :
Installing the tool chain
ESP32 doesn't have enough power to run a full OS based program, so we will be using the no_std
library for Embedded Programming.
Install the following tool chains
- Installing
espup
. This is a tool that simplifies installing and maintaining the components required to develop Rust applications for theXtensia
andRISC-V
architectures. (Make sure thatcargo
is in your PATH).
cargo install espup
- Installing the necessary tool-chains
espup install
- Now a file named
export-esp.sh
will be created in your$HOME
directory. Add it's contents to your~/.bashrc
or~/.zshrc
using the following command
cat $HOME/export-esp.sh >> ~/.bashrc
The export-esp.sh
file consists of all the environment variables required to run the Rust Code.
You are now ready to write Embedded Rust Code
Find the other blogs here
- Hello World
- LED Blinking
- Button interfacing
- Sensor Integration
- DHT22 Temperature and Humidity Sensor
- [Ultrasonic Sensor]
- [Touch Sensor]
Top comments (0)