Hello World

In the last chapter you flashed and run your first piece of code on the SoC - while that is already really exciting we can do better.

Traditionally the first thing to run on a microcontroller is blinky.

However, we will start with Hello World here.

Add a Dependency

You can add a dependency by any of the following methods:

  • By Editing Cargo.toml. In Cargo.toml in the [dependencies] section add this line:
esp-println = { version = "0.3.1", features = ["esp32c3"] }
cargo add esp-println --features "esp32c3"

esp-println is an additional crate that calls ROM functions to print text that is shown by espflash (or any other serial monitor).

We need to pass the feature esp32c3 since that crate targets multiple SoCs and needs to know which one it is supposed to run on.

Note that there might be new versions by the time you are reading this, please check crates.io.

In main.rs before the loop {} add this line

esp_println::println!("Hello World");

See Results

Again run

cargo run

You should see the text Hello World printed!