dev esp-println

Provides print! and println! implementations various Espressif devices

13 releases (8 breaking)

0.9.0 Feb 7, 2024
0.8.0 Dec 20, 2023
0.7.1 Nov 8, 2023
0.5.0 Apr 18, 2023
0.2.1 Jul 15, 2022

#43 in Embedded development

Download history 5784/week @ 2023-10-31 5294/week @ 2023-11-07 4690/week @ 2023-11-14 4890/week @ 2023-11-21 5882/week @ 2023-11-28 5344/week @ 2023-12-05 5493/week @ 2023-12-12 4121/week @ 2023-12-19 3708/week @ 2023-12-26 3865/week @ 2024-01-02 3376/week @ 2024-01-09 3696/week @ 2024-01-16 3675/week @ 2024-01-23 3020/week @ 2024-01-30 3726/week @ 2024-02-06 3171/week @ 2024-02-13

14,128 downloads per month
Used in 19 crates


436 lines


A library that provides print!, println!, dbg! implementations and logging capabilities for Espressif devices.

  • Supports all Espressif ESP32 family devices.
  • Supports different communication methods:
    • UART (Default)
    • JTAG-Serial (Only available in ESP32-C3, ESP32-C6, ESP32-H2, ESP32-S3)
    • No-op: Turns printing into a no-op
  • Supports defmt backend


esp-println = { version = "0.8.0", features = ["esp32c2"] }

or cargo add esp-println --features esp32c2 It's important to specify your target device as feature.

Then in your program:

use esp_println::println;

You can now println!("Hello world") as usual.


  • There is one feature for each supported target: esp32, esp32c2, esp32c3, esp32c6, esp32h2, esp32s2, and esp32s3.
    • One of these features must be enabled.
    • Only one of these features can be enabled at a time.
  • There is one feature for each supported communication method: uart, jtag-serial and no-op.
    • Only one of these features can be enabled at a time.
  • log: Enables logging using log crate.
  • colors enable colored logging.
    • Only effective when using the log feature.
  • critical-section enables critical sections.
  • defmt-espflash: This is intended to be used with espflash, see -L/--log-format argument of flash or monitor subcommands of espflash and cargo-espflash. Uses rzCOBS encoding and adds framing.

Default Features

By default, we use the uart, critial-section and colors features. Which means that it will print to the UART, use critical sections and output messages will be colored. If we want to use a communication method that is not uart, the default one, we need to disable the default features.


With the feature log activated you can initialize a simple logger like this


There is a default feature colors which enables colored log output.

Additionally, you can use


In this case the following environment variables are used:

  • ESP_LOGLEVEL sets the log level, use values like trace, info etc.
  • ESP_LOGTARGETS if set you should provide the crate names of crates (optionally with a path e.g. esp_wifi::compat::common) which should get logged, separated by , and no additional whitespace between

If this simple logger implementation isn't sufficient for your needs, you can implement your own logger on top of esp-println. See Implementing a Logger section log documentaion


Using the defmt-espflash feature, esp-println will install a defmt global logger. The logger will output to the same data stream as println!(), and adds framing bytes so it can be used even with other, non-defmt output. Using the defmt-espflash feature automatically uses the rzCOBS encoding and does not allow changing the encoding.

Follow the defmt book's setup instructions on how to set up defmt. Remember, the global logger is already installed for you by esp-println!

Troubleshooting linker errors

If you experience linker errors, make sure you have some reference to esp_println in your code. If you don't use esp_println directly, you'll need to add e.g. use esp_println as _; to your import statements. This ensures that the global logger will not be removed by the compiler.


Licensed under either of:

at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.