Module esp_idf_svc::hal::rmt

source ·
Expand description

Remote Control (RMT) module driver.

The RMT (Remote Control) module driver can be used to send infrared remote control signals. Due to flexibility of RMT module, the driver can also be used to generate or receive many other types of signals.

This module is an abstraction around the IDF RMT implementation. It is recommended to read before using this module.

This is implementation currently supports transmission only.

Not supported:

  • Interrupts.
  • Receiving.
  • Change of config after initialisation.


// Prepare the config.
let config = Config::new().clock_divider(1);

// Retrieve the output pin and channel from peripherals.
let peripherals = Peripherals::take().unwrap();
let channel = peripherals.rmt.channel0;
let pin = peripherals.pins.gpio18;

// Create an RMT transmitter.
let tx = TxRmtDriver::new(channel, pin, &config)?;

// Prepare signal pulse signal to be sent.
let low = Pulse::new(PinState::Low, PulseTicks::new(10)?);
let high = Pulse::new(PinState::High, PulseTicks::new(10)?);
let mut signal = FixedLengthSignal::<2>::new();
signal.set(0, &(low, high))?;
signal.set(1, &(high, low))?;

// Transmit the signal.

See the examples/ folder of this repository for more.

§Loading pulses

There are two ways of preparing pulse signal. FixedLengthSignal and VariableLengthSignal. These implement the Signal trait.

FixedLengthSignal lives on the stack and must have the items set in pairs of Pulses. This is due to the internal implementation of RMT, and const generics limitations.

VariableLengthSignal allows you to use the heap and incrementally add pulse items without knowing the size ahead of time.


  • Types used for configuring the rmt module.




  • RMT peripheral channel.
  • Signal storage for [Transmit] in a format ready for the RMT driver.


  • A utility to convert a duration into ticks, depending on the clock ticks.
  • A utility to convert ticks into duration, depending on the clock ticks.

Type Aliases§