I'm trying to upload a basic IR Remote code to an ESP32DEVKit_U4 modules but I keep getting this error:
In file included from %PATH%\libraries\IRremote\IRremote.h:24,
from %PATH%\libraries\IRremote\irSend.cpp:1:
%PATH%\libraries\IRremote\irSend.cpp: In member function 'void IRsend::mark(unsigned int)':
%PATH%\libraries\IRremote\IRremoteInt.h:220:30: error: 'TCCR2A' was not declared in this scope
220 | #define TIMER_ENABLE_PWM (TCCR2A |= _BV(COM2B1))
| ^~~~~~
%PATH%\libraries\IRremote\irSend.cpp:24:9: note: in expansion of macro 'TIMER_ENABLE_PWM'
24 | TIMER_ENABLE_PWM; // Enable pin 3 PWM output
| ^~~~~~~~~~~~~~~~
In file included from %PATH%\libraries\IRremote\IRremoteInt.h:24:
%PATH%\libraries\IRremote\IRremoteInt.h:220:44: error: 'COM2B1' was not declared in this scope
220 | #define TIMER_ENABLE_PWM (TCCR2A |= _BV(COM2B1))
| ^~~~~~
%PATH%\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.7\cores\esp32/Arduino.h:111:25: note: in definition of macro '_BV'
111 | #define _BV(b) (1UL << (b))
| ^
%PATH%\libraries\IRremote\irSend.cpp:24:9: note: in expansion of macro 'TIMER_ENABLE_PWM'
24 | TIMER_ENABLE_PWM; // Enable pin 3 PWM output
| ^~~~~~~~~~~~~~~~
%PATH%\libraries\IRremote\irSend.cpp: In member function 'void IRsend::space(unsigned int)':
%PATH%\libraries\IRremote\IRremoteInt.h:221:30: error: 'TCCR2A' was not declared in this scope
221 | #define TIMER_DISABLE_PWM (TCCR2A &= ~(_BV(COM2B1)))
| ^~~~~~
%PATH%\libraries\IRremote\irSend.cpp:35:9: note: in expansion of macro 'TIMER_DISABLE_PWM'
35 | TIMER_DISABLE_PWM; // Disable pin 3 PWM output
| ^~~~~~~~~~~~~~~~~
%PATH%\libraries\IRremote\IRremoteInt.h:221:46: error: 'COM2B1' was not declared in this scope
221 | #define TIMER_DISABLE_PWM (TCCR2A &= ~(_BV(COM2B1)))
| ^~~~~~
%PATH%\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.7\cores\esp32/Arduino.h:111:25: note: in definition of macro '_BV'
111 | #define _BV(b) (1UL << (b))
| ^
%PATH%\libraries\IRremote\irSend.cpp:35:9: note: in expansion of macro 'TIMER_DISABLE_PWM'
35 | TIMER_DISABLE_PWM; // Disable pin 3 PWM output
| ^~~~~~~~~~~~~~~~~
%PATH%\libraries\IRremote\irSend.cpp: In member function 'void IRsend::enableIROut(int)':
%PATH%\libraries\IRremote\IRremoteInt.h:223:30: error: 'TIMSK2' was not declared in this scope
223 | #define TIMER_DISABLE_INTR (TIMSK2 = 0)
| ^~~~~~
%PATH%\libraries\IRremote\irSend.cpp:58:9: note: in expansion of macro 'TIMER_DISABLE_INTR'
58 | TIMER_DISABLE_INTR; //Timer2 Overflow Interrupt
| ^~~~~~~~~~~~~~~~~~
%PATH%\libraries\IRremote\IRremoteInt.h:228:9: error: 'TCCR2A' was not declared in this scope
228 | TCCR2A = _BV(WGM20); \
| ^~~~~~
%PATH%\libraries\IRremote\irSend.cpp:68:9: note: in expansion of macro 'TIMER_CONFIG_KHZ'
68 | TIMER_CONFIG_KHZ(khz);
| ^~~~~~~~~~~~~~~~
%PATH%\libraries\IRremote\IRremoteInt.h:228:36: error: 'WGM20' was not declared in this scope
228 | TCCR2A = _BV(WGM20); \
| ^~~~~
%PATH%\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.7\cores\esp32/Arduino.h:111:25: note: in definition of macro '_BV'
111 | #define _BV(b) (1UL << (b))
| ^
%PATH%\libraries\IRremote\irSend.cpp:68:9: note: in expansion of macro 'TIMER_CONFIG_KHZ'
68 | TIMER_CONFIG_KHZ(khz);
| ^~~~~~~~~~~~~~~~
%PATH%\libraries\IRremote\IRremoteInt.h:229:9: error: 'TCCR2B' was not declared in this scope
229 | TCCR2B = _BV(WGM22) | _BV(CS20); \
| ^~~~~~
%PATH%\libraries\IRremote\irSend.cpp:68:9: note: in expansion of macro 'TIMER_CONFIG_KHZ'
68 | TIMER_CONFIG_KHZ(khz);
| ^~~~~~~~~~~~~~~~
%PATH%\libraries\IRremote\IRremoteInt.h:229:36: error: 'WGM22' was not declared in this scope
229 | TCCR2B = _BV(WGM22) | _BV(CS20); \
| ^~~~~
%PATH%\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.7\cores\esp32/Arduino.h:111:25: note: in definition of macro '_BV'
111 | #define _BV(b) (1UL << (b))
| ^
%PATH%\libraries\IRremote\irSend.cpp:68:9: note: in expansion of macro 'TIMER_CONFIG_KHZ'
68 | TIMER_CONFIG_KHZ(khz);
| ^~~~~~~~~~~~~~~~
%PATH%\libraries\IRremote\IRremoteInt.h:229:49: error: 'CS20' was not declared in this scope
229 | TCCR2B = _BV(WGM22) | _BV(CS20); \
| ^~~~
%PATH%\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.7\cores\esp32/Arduino.h:111:25: note: in definition of macro '_BV'
111 | #define _BV(b) (1UL << (b))
| ^
%PATH%\libraries\IRremote\irSend.cpp:68:9: note: in expansion of macro 'TIMER_CONFIG_KHZ'
68 | TIMER_CONFIG_KHZ(khz);
| ^~~~~~~~~~~~~~~~
%PATH%\libraries\IRremote\IRremoteInt.h:230:9: error: 'OCR2A' was not declared in this scope
230 | OCR2A = pwmval; \
| ^~~~~
%PATH%\libraries\IRremote\irSend.cpp:68:9: note: in expansion of macro 'TIMER_CONFIG_KHZ'
68 | TIMER_CONFIG_KHZ(khz);
| ^~~~~~~~~~~~~~~~
%PATH%\libraries\IRremote\IRremoteInt.h:231:9: error: 'OCR2B' was not declared in this scope
231 | OCR2B = pwmval / 3; \
| ^~~~~
%PATH%\libraries\IRremote\irSend.cpp:68:9: note: in expansion of macro 'TIMER_CONFIG_KHZ'
68 | TIMER_CONFIG_KHZ(khz);
| ^~~~~~~~~~~~~~~~
In file included from %PATH%\libraries\IRremote\IRremote.h:24,
from %PATH%\libraries\IRremote\irRecv.cpp:1:
%PATH%\libraries\IRremote\irRecv.cpp: In member function 'void IRrecv::enableIRIn()':
%PATH%\libraries\IRremote\IRremoteInt.h:246:17: error: 'TCCR2A' was not declared in this scope
246 | TCCR2A = _BV(WGM21); \
| ^~~~~~
%PATH%\libraries\IRremote\irRecv.cpp:120:9: note: in expansion of macro 'TIMER_CONFIG_NORMAL'
120 | TIMER_CONFIG_NORMAL();
| ^~~~~~~~~~~~~~~~~~~
In file included from %PATH%\libraries\IRremote\IRremoteInt.h:24:
%PATH%\libraries\IRremote\IRremoteInt.h:246:30: error: 'WGM21' was not declared in this scope
246 | TCCR2A = _BV(WGM21); \
| ^~~~~
%PATH%\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.7\cores\esp32/Arduino.h:111:25: note: in definition of macro '_BV'
111 | #define _BV(b) (1UL << (b))
| ^
%PATH%\libraries\IRremote\irRecv.cpp:120:9: note: in expansion of macro 'TIMER_CONFIG_NORMAL'
120 | TIMER_CONFIG_NORMAL();
| ^~~~~~~~~~~~~~~~~~~
%PATH%\libraries\IRremote\IRremoteInt.h:247:9: error: 'TCCR2B' was not declared in this scope
247 | TCCR2B = _BV(CS21); \
| ^~~~~~
%PATH%\libraries\IRremote\irRecv.cpp:120:9: note: in expansion of macro 'TIMER_CONFIG_NORMAL'
120 | TIMER_CONFIG_NORMAL();
| ^~~~~~~~~~~~~~~~~~~
%PATH%\libraries\IRremote\IRremoteInt.h:247:36: error: 'CS21' was not declared in this scope
247 | TCCR2B = _BV(CS21); \
| ^~~~
%PATH%\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.7\cores\esp32/Arduino.h:111:25: note: in definition of macro '_BV'
111 | #define _BV(b) (1UL << (b))
| ^
%PATH%\libraries\IRremote\irRecv.cpp:120:9: note: in expansion of macro 'TIMER_CONFIG_NORMAL'
120 | TIMER_CONFIG_NORMAL();
| ^~~~~~~~~~~~~~~~~~~
%PATH%\libraries\IRremote\IRremoteInt.h:248:9: error: 'OCR2A' was not declared in this scope
248 | OCR2A = pwmval; \
| ^~~~~
%PATH%\libraries\IRremote\irRecv.cpp:120:9: note: in expansion of macro 'TIMER_CONFIG_NORMAL'
120 | TIMER_CONFIG_NORMAL();
| ^~~~~~~~~~~~~~~~~~~
In file included from %PATH%\libraries\IRremote\IRremote.h:24,
from %PATH%\libraries\IRremote\irRecv.cpp:1:
%PATH%\libraries\IRremote\IRremoteInt.h:248:17: error: 'OCR2B' was not declared in this scope
248 | OCR2B = pwmval / 3; \
| ^~~~~
%PATH%\libraries\IRremote\irRecv.cpp:120:9: note: in expansion of macro 'TIMER_CONFIG_NORMAL'
120 | TIMER_CONFIG_NORMAL();
| ^~~~~~~~~~~~~~~~~~~
It may look long but to break it down it has to do with the IR Remote Library.
The library version I'm using is the 4.4.1 version.
Here is my code:
#include <IRremote.h>
const int recv_pin = 2; // The IR receiver pin
IRrecv irrecv(recv_pin);
decode_results results;
void setup() {
Serial.begin(115200);
irrecv.enableIRIn(); // Start the receiver
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
}
}
When I upload my code my port is selected as: