Skip to content

nanoframework/nanoFramework.Hardware.Esp32.Rmt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

185 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Quality Gate Status Reliability Rating NuGet #yourfirstpr Discord

nanoFramework logo


Welcome to the .NET nanoFramework Hardware.Esp32.Rmt Library repository

RMT (Remote Control) is an ESP32 module driver that is, originally, intended to be used with infrared remote control signals. However, the module and APIs are generic enough that they can used to send/receive other types of signals.

Getting Started

Our samples repository contains commented code showcasing how to use the RMT module in ESP32 MCUs to control various types of devices using nanoFramework. The RMT samples can be found Here.

A detailed explanation about the RMT module can be found here.

Migrating from v1 to v2

There are breaking changes in the managed API surface. If you have existing code that depends on v1.x of this library you will need to refactor it so it works with the new API surface in v2.x.

The changes are mostly around how receive/transmit channels are initialized. The other APIs from v1.x remain as they are.

Please update the code as follows:

V1.x API Surface

// creating a transmit channel
var txChannel = new TransmitterChannel(TxPinNumber);
txChannel.ClockDivider = 80;
txChannel.CarrierEnabled = false;
txChannel.IdleLevel = false;
txChannel.AddCommand(new RmtCommand(20, true, 15, false));
// add more commands...

txChannel.Send(false);

// creating a receive channel
var rxChannel = new ReceiverChannel(RxPinNumber);
rxChannel.ClockDivider = 80; // 1us clock ( 80Mhz / 80 ) = 1Mhz
rxChannel.EnableFilter(true, 100); // filter out 100Us / noise 
rxChannel.SetIdleThresold(40000);  // 40ms based on 1us clock
rxChannel.ReceiveTimeout = new TimeSpan(0, 0, 0, 0, 60); 
rxChannel.Start(true);

In V2.x, the above code must be rewritten as:

var txChannelSettings = new TransmitChannelSettings(-1, TxChannelPinNumber)
{
  ClockDivider = 80,
  EnableCarrierWave = false,
  IdleLevel = false
};

var txChannel = new TransmitterChannel(txChannelSettings);
txChannel.AddCommand(new RmtCommand(20, true, 15, false));
// add more commands...

txChannel.Send(false);


var rxChannelSettings = new ReceiverChannelSettings(pinNumber: RxChannelPinNumber)
{
  EnableFilter = true,
  FilterThreshold = 100,
  IdleThreshold = 40_000,
  ReceiveTimeout = new TimeSpan(0, 0, 0, 0, 60)
};

using var rxChannel = new ReceiverChannel(rxChannelSettings);
rxChannel.Start(clearBuffer: true);

ESP Boards and available channels

If you get Exception initializing TX or RX Channel, you have to set the channel based on your ESP32 board version:

  • The ESP32 has 8 channels, each of them can be either receiver or transmitter (this is ok for no channel specification, first free channel is ok)
  • The ESP32-C3 has 4 channels, Channel<0> and Channel<1> hardcoded for transmitting signals and Channel<2> and Channel<3> hardcoded for receiving signals.
  • The ESP32-C6 has 4 channels, Channel<0> and Channel<1> hardcoded for transmitting signals and Channel<2> and Channel<3> hardcoded for receiving signals.
  • The ESP32-H2 has 4 channels, Channel<0> and Channel<1> hardcoded for transmitting signals and Channel<2> and Channel<3> hardcoded for receiving signals.
  • The ESP32-S2 has 4 channels, each of them can be either receiver or transmitter.
  • The ESP32-S3 has 8 channels, Channel<0>-Channel<3> hardcoded for transmitting signals and Channel<4>-Channel<7> hardcoded for receiving signals. Based on this you can specify the channel in settings:
rxChannelSettings = new ReceiverChannelSettings(0)
                {
                    Channel = 3, //2,3 ESP32-C3 ESP32-C6 ESP32-H2 | 4-7 ESP32-S3
                    ...

txChannelSettings = new TransmitChannelSettings(0)
                {
                    Channel=1, //0,1 ESP32-C3 ESP32-C6 ESP32-H2 | 1-3 ESP32-S3
                    ...

Build status

Component Build Status NuGet Package
nanoFramework.Hardware.Esp32.Rmt Build Status NuGet

Feedback and documentation

For documentation, providing feedback, issues and finding out how to contribute please refer to the Home repo.

Join our Discord community here.

Credits

The list of contributors to this project can be found at CONTRIBUTORS.

License

The nanoFramework Class Libraries are licensed under the MIT license.

Code of Conduct

This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behaviour in our community. For more information see the .NET Foundation Code of Conduct.

.NET Foundation

This project is supported by the .NET Foundation.

About

πŸ“¦ .NET nanoFramework class library for the RMT (remote control) peripheral for ESP32 targets

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

8 stars

Watchers

5 watching

Forks

Sponsor this project

  •  

Contributors

Languages