At the moment the IRLib2 library from cyborg5 is missing support for the ESP32 module.
I have updated the library so it supports the ESP32. Until cyborg5 merges my pull request you can find the updated code on my Github in the branch esp32-support.
Download
You can download the code here: download (mirror).
Installation
The installation instructions can be found in the included readme.md file. They are also available here: readme.md.
The default IR send GPIO pin is 26. This can be changed in the file: IRLibProtocols/IRLibESP32.h.
Trying to implement a trainable IR remote control on an M5Stick C. Help from any one, Please
Thank you for this i was using the IRlib 2 library and when i needed more processor power i starte dto use teh esp32 but it would not work, and i had based all my code on the IRlib2 library after finding your page iand using your module everything works again.
thanks
Nice to hear that my edit to the library helped your project!
i cant seem to get this library to work on the esp32, i have installed it as shown but it just will not compile on the esp32 but it works great on the Uno.
is anyone else having issues with this?
I have sorted it, I had to go back to the first v 1.0.1 of the ESP 32 boards manager, somehow the latest version does not compile for the ESP 32.
This is the error that I am getting compiles fine on the UNO but not esp32, have the files been changed or something as this used to work.
Arduino: 1.8.19 (Windows 10), Board: “ESP32 Dev Module, Disabled, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, Core 1, Core 1, None, Disabled, Disabled”
In file included from C:\Program Files (x86)\Arduino\libraries\IRLibProtocols\IRLibHardware.h:97,
from C:\Program Files (x86)\Arduino\libraries\IRLibProtocols\IRLibSendBase.cpp:14:
C:\Program Files (x86)\Arduino\libraries\IRLibProtocols\IRLibSendBase.cpp: In member function ‘void IRsendBase::enableIROut(uint8_t)’:
C:\Program Files (x86)\Arduino\libraries\IRLibProtocols\IRLibESP32.h:23:37: error: ‘ledcSetup’ was not declared in this scope
23 | ledcSetup(1, val * 1000, 8); \
| ^~~~~~~~~
C:\Program Files (x86)\Arduino\libraries\IRLibProtocols\IRLibSendBase.cpp:80:2: note: in expansion of macro ‘IR_SEND_CONFIG_KHZ’
80 | IR_SEND_CONFIG_KHZ(khz);
| ^~~~~~~~~~~~~~~~~~
C:\Program Files (x86)\Arduino\libraries\IRLibProtocols\IRLibESP32.cpp: In function ‘void startESP32Timer()’:
C:\Program Files (x86)\Arduino\libraries\IRLibProtocols\IRLibESP32.cpp:21:9: error: ‘timerAlarmEnable’ was not declared in this scope; did you mean ‘timerAlarm’?
21 | timerAlarmEnable(esp32Timer);
| ^~~~~~~~~~~~~~~~
| timerAlarm
C:\Program Files (x86)\Arduino\libraries\IRLibProtocols\IRLibSendBase.cpp: In member function ‘void IRsendBase::mark(uint16_t)’:
C:\Program Files (x86)\Arduino\libraries\IRLibProtocols\IRLibESP32.h:17:33: error: ‘ledcAttachPin’ was not declared in this scope; did you mean ‘ledcAttach’?
17 | #define IR_SEND_PWM_START ledcAttachPin(IR_SEND_ESP32, 1);
| ^~~~~~~~~~~~~
C:\Program Files (x86)\Arduino\libraries\IRLibProtocols\IRLibSendBase.cpp:95:2: note: in expansion of macro ‘IR_SEND_PWM_START’
95 | IR_SEND_PWM_START;
| ^~~~~~~~~~~~~~~~~
C:\Program Files (x86)\Arduino\libraries\IRLibProtocols\IRLibSendBase.cpp: In member function ‘void IRsendBase::space(uint16_t)’:
C:\Program Files (x86)\Arduino\libraries\IRLibProtocols\IRLibESP32.h:19:33: error: ‘ledcDetachPin’ was not declared in this scope; did you mean ‘ledcDetach’?
19 | #define IR_SEND_PWM_STOP ledcDetachPin(IR_SEND_ESP32);
| ^~~~~~~~~~~~~
C:\Program Files (x86)\Arduino\libraries\IRLibProtocols\IRLibSendBase.cpp:101:2: note: in expansion of macro ‘IR_SEND_PWM_STOP’
101 | IR_SEND_PWM_STOP;
| ^~~~~~~~~~~~~~~~
C:\Program Files (x86)\Arduino\libraries\IRLibProtocols\IRLibESP32.cpp: In function ‘void stopESP32Timer()’:
C:\Program Files (x86)\Arduino\libraries\IRLibProtocols\IRLibESP32.cpp:27:9: error: ‘timerAlarmDisable’ was not declared in this scope
27 | timerAlarmDisable(esp32Timer);
| ^~~~~~~~~~~~~~~~~
C:\Program Files (x86)\Arduino\libraries\IRLibProtocols\IRLibESP32.cpp: In function ‘void initializeESP32TimerInterrupt()’:
C:\Program Files (x86)\Arduino\libraries\IRLibProtocols\IRLibESP32.cpp:34:28: error: too many arguments to function ‘hw_timer_t* timerBegin(uint32_t)’
34 | esp32Timer = timerBegin(1, (SYSCLOCK / 1000000), true);
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from C:\Users\John_2\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.7\cores\esp32/esp32-hal.h:84,
from C:\Users\John_2\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.7\cores\esp32/Arduino.h:36,
from C:\Program Files (x86)\Arduino\libraries\IRLibProtocols\IRLibHardware.h:21,
from C:\Program Files (x86)\Arduino\libraries\IRLibProtocols\IRLibESP32.cpp:14:
C:\Users\John_2\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.7\cores\esp32/esp32-hal-timer.h:35:13: note: declared here
35 | hw_timer_t *timerBegin(uint32_t frequency);
| ^~~~~~~~~~
C:\Program Files (x86)\Arduino\libraries\IRLibProtocols\IRLibESP32.cpp:36:25: error: too many arguments to function ‘void timerAttachInterrupt(hw_timer_t*, void (*)())’
36 | timerAttachInterrupt(esp32Timer, &onESP32Timer, true);
| ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\John_2\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.7\cores\esp32/esp32-hal-timer.h:50:6: note: declared here
50 | void timerAttachInterrupt(hw_timer_t *timer, void (*userFunc)(void));
| ^~~~~~~~~~~~~~~~~~~~
C:\Program Files (x86)\Arduino\libraries\IRLibProtocols\IRLibESP32.cpp:38:5: error: ‘timerAlarmWrite’ was not declared in this scope; did you mean ‘timerWrite’?
38 | timerAlarmWrite(esp32Timer, USEC_PER_TICK, true);
| ^~~~~~~~~~~~~~~
| timerWrite
Using library IRLibRecvPCI at version 2.0.19 in folder: C:\Program Files (x86)\Arduino\libraries\IRLibRecvPCI
Using library IRLib2 at version 2.0.19 in folder: C:\Program Files (x86)\Arduino\libraries\IRLib2
Using library IRLibProtocols at version 2.0.19 in folder: C:\Program Files (x86)\Arduino\libraries\IRLibProtocols
exit status 1
Error compiling for board ESP32 Dev Module.