Error with RadioHead library

Hi everyone, I would like to use a RadioHead library in my project with my Arduino Nano ESP32 but I had an error like this: .pio/libdeps/arduino_nano_esp32/RadioHead/RHGenericSPI.h:118:34: error: macro "attachInterrupt" requires 3 arguments, but only 1 given virtual void attachInterrupt() {};. I fixed it by changing the name of the function attachInterrupt with another name and the error no longer appeared. I want to know if this change a valid solution and also if there is another way to fix this problem without change the name of function.

Hi, @userarduino121
Welcome to the forum.

This may help;
https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

This will help you to post your code, which we need to see.

What model Arduino are you using?

Thanks.. Tom.... :smiley: :+1: :coffee: :australia:

well then the virtual function is no linked to the actual one anymore.

No it most likely isn't, and chances are the program no longer works as intended.

So, do you know how to fix the problem that appeared before?

Definitely not. A virtual function is intended to be redefined at runtime by a derived class.

I have no idea why the compiler/linker is complaining. However, the Espressif Corp. recently made major changes to ESP32 libraries and core support that broke a lot of existing code.

Consider posting on the RadioHead forum.

Without the complete code ?? no most definitely not.

If it is a Nano ESP32, the core is supported by the Arduino team, if it is any other ESP32 then espressif is maintaining the core and in that case rolling back to an older version of the core (something like 2.x.x )might fix the issue

ESP32 built using Arduino IDE 1.8.9 or later using the ESP32 toolchain installed per GitHub - espressif/arduino-esp32: Arduino core for the ESP32 or from the Arduino IDE Board Manager. Tested up to version 3.0.2. The internal 2.4GHz radio is not yet supported. Tested with RFM22 using SPI interface. Uses the VSPI SPI bus by default. You can enable use of the alternative HSPI bus for SPI by defining RH_ESP32_USE_HSPI in RadioHead.h.

I'm trying to use the RadioHead Library to see if it works in an empty works


and this is the error:

please do not post screenshots
check https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum/679966

Sorry, this is the code:

#include <Arduino.h>
#include <RadioHead.h>

void setup() {
  Serial.begin(115200);
}

void loop() {
  
}

And this is the error:

In file included from .pio/libdeps/arduino_nano_esp32/RadioHead/RHHardwareSPI.h:10,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RHNRFSPIDriver.h:10,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RH_CC110.h:17,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RH_CC110.cpp:8:
.pio/libdeps/arduino_nano_esp32/RadioHead/RHGenericSPI.h:118:34: error: macro "attachInterrupt" requires 3 arguments, but only 1 given
     virtual void attachInterrupt() {};
                                  ^
In file included from .pio/libdeps/arduino_nano_esp32/RadioHead/RHHardwareSPI.h:10,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RHNRFSPIDriver.h:10,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RH_MRF89.h:15,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RH_MRF89.cpp:6:
.pio/libdeps/arduino_nano_esp32/RadioHead/RHGenericSPI.h:118:34: error: macro "attachInterrupt" requires 3 arguments, but only 1 given
     virtual void attachInterrupt() {};
                                  ^
In file included from .pio/libdeps/arduino_nano_esp32/RadioHead/RHSoftwareSPI.h:9,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RHSoftwareSPI.cpp:6:
.pio/libdeps/arduino_nano_esp32/RadioHead/RHGenericSPI.h:118:34: error: macro "attachInterrupt" requires 3 arguments, but only 1 given
     virtual void attachInterrupt() {};
                                  ^
In file included from .pio/libdeps/arduino_nano_esp32/RadioHead/RHGenericSPI.cpp:7:
.pio/libdeps/arduino_nano_esp32/RadioHead/RHGenericSPI.h:118:34: error: macro "attachInterrupt" requires 3 arguments, but only 1 given
     virtual void attachInterrupt() {};
                                  ^
In file included from .pio/libdeps/arduino_nano_esp32/RadioHead/RHHardwareSPI.h:10,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RHSPIDriver.h:10,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RHSPIDriver.cpp:6:
.pio/libdeps/arduino_nano_esp32/RadioHead/RHGenericSPI.h:118:34: error: macro "attachInterrupt" requires 3 arguments, but only 1 given
     virtual void attachInterrupt() {};
                                  ^
In file included from .pio/libdeps/arduino_nano_esp32/RadioHead/RHHardwareSPI.h:10,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RHNRFSPIDriver.h:10,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RHNRFSPIDriver.cpp:6:
.pio/libdeps/arduino_nano_esp32/RadioHead/RHGenericSPI.h:118:34: error: macro "attachInterrupt" requires 3 arguments, but only 1 given
     virtual void attachInterrupt() {};
                                  ^
In file included from .pio/libdeps/arduino_nano_esp32/RadioHead/RHHardwareSPI.h:10,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RHHardwareSPI.cpp:7:
.pio/libdeps/arduino_nano_esp32/RadioHead/RHGenericSPI.h:118:34: error: macro "attachInterrupt" requires 3 arguments, but only 1 given
     virtual void attachInterrupt() {};
                                  ^
.pio/libdeps/arduino_nano_esp32/RadioHead/RHHardwareSPI.cpp:74:37: error: macro "attachInterrupt" requires 3 arguments, but only 1 given
 void RHHardwareSPI::attachInterrupt()
                                     ^
.pio/libdeps/arduino_nano_esp32/RadioHead/RHGenericSPI.h:118:37: error: variable or field 'attachInterrupt' declared void
     virtual void attachInterrupt() {};
                                     ^
In file included from /Users/andreaamaru/.platformio/packages/framework-arduinoespressif32/cores/esp32/Arduino.h:235,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RadioHead.h:1540,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RHGenericDriver.h:9,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RHNRFSPIDriver.h:9,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RHNRFSPIDriver.cpp:6:
/Users/andreaamaru/.platformio/packages/framework-arduinoespressif32/cores/esp32/io_pin_remap.h:45:69: error: 'digitalPinToGPIONumber' is not a type
 #define detachInterrupt(pin)                        detachInterrupt(digitalPinToGPIONumber(pin))
                                                                     ^~~~~~~~~~~~~~~~~~~~~~
.pio/libdeps/arduino_nano_esp32/RadioHead/RHGenericSPI.h:124:18: note: in expansion of macro 'detachInterrupt'
     virtual void detachInterrupt() {};
                  ^~~~~~~~~~~~~~~
.pio/libdeps/arduino_nano_esp32/RadioHead/RHGenericSPI.h:118:37: error: variable or field 'attachInterrupt' declared void
     virtual void attachInterrupt() {};
                                     ^
.pio/libdeps/arduino_nano_esp32/RadioHead/RHGenericSPI.h:118:37: error: variable or field 'attachInterrupt' declared void
     virtual void attachInterrupt() {};
                                     ^
In file included from /Users/andreaamaru/.platformio/packages/framework-arduinoespressif32/cores/esp32/Arduino.h:235,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RadioHead.h:1540,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RHGenericDriver.h:9,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RHNRFSPIDriver.h:9,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RH_MRF89.h:15,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RH_MRF89.cpp:6:
/Users/andreaamaru/.platformio/packages/framework-arduinoespressif32/cores/esp32/io_pin_remap.h:45:69: error: 'digitalPinToGPIONumber' is not a type
 #define detachInterrupt(pin)                        detachInterrupt(digitalPinToGPIONumber(pin))
                                                                     ^~~~~~~~~~~~~~~~~~~~~~
.pio/libdeps/arduino_nano_esp32/RadioHead/RHGenericSPI.h:124:18: note: in expansion of macro 'detachInterrupt'
     virtual void detachInterrupt() {};
                  ^~~~~~~~~~~~~~~
In file included from /Users/andreaamaru/.platformio/packages/framework-arduinoespressif32/cores/esp32/Arduino.h:235,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RadioHead.h:1540,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RHGenericSPI.h:10,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RHSoftwareSPI.h:9,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RHSoftwareSPI.cpp:6:
/Users/andreaamaru/.platformio/packages/framework-arduinoespressif32/cores/esp32/io_pin_remap.h:45:69: error: 'digitalPinToGPIONumber' is not a type
 #define detachInterrupt(pin)                        detachInterrupt(digitalPinToGPIONumber(pin))
                                                                     ^~~~~~~~~~~~~~~~~~~~~~
.pio/libdeps/arduino_nano_esp32/RadioHead/RHGenericSPI.h:124:18: note: in expansion of macro 'detachInterrupt'
     virtual void detachInterrupt() {};
                  ^~~~~~~~~~~~~~~
In file included from .pio/libdeps/arduino_nano_esp32/RadioHead/RHHardwareSPI.h:10,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RHHardwareSPI.cpp:7:
.pio/libdeps/arduino_nano_esp32/RadioHead/RHGenericSPI.h:118:37: error: variable or field 'attachInterrupt' declared void
     virtual void attachInterrupt() {};
                                     ^
In file included from /Users/andreaamaru/.platformio/packages/framework-arduinoespressif32/cores/esp32/Arduino.h:235,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RadioHead.h:1540,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RHGenericSPI.h:10,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RHHardwareSPI.h:10,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RHHardwareSPI.cpp:7:
/Users/andreaamaru/.platformio/packages/framework-arduinoespressif32/cores/esp32/io_pin_remap.h:45:69: error: 'digitalPinToGPIONumber' is not a type
 #define detachInterrupt(pin)                        detachInterrupt(digitalPinToGPIONumber(pin))
                                                                     ^~~~~~~~~~~~~~~~~~~~~~
.pio/libdeps/arduino_nano_esp32/RadioHead/RHGenericSPI.h:124:18: note: in expansion of macro 'detachInterrupt'
     virtual void detachInterrupt() {};
                  ^~~~~~~~~~~~~~~
.pio/libdeps/arduino_nano_esp32/RadioHead/RHHardwareSPI.cpp:74:21: error: variable or field 'attachInterrupt' declared void
 void RHHardwareSPI::attachInterrupt()
                     ^~~~~~~~~~~~~~~
.pio/libdeps/arduino_nano_esp32/RadioHead/RHGenericSPI.h:118:37: error: variable or field 'attachInterrupt' declared void
     virtual void attachInterrupt() {};
                                     ^
In file included from /Users/andreaamaru/.platformio/packages/framework-arduinoespressif32/cores/esp32/Arduino.h:235,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RadioHead.h:1540,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RHGenericDriver.h:9,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RHNRFSPIDriver.h:9,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RH_CC110.h:17,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RH_CC110.cpp:8:
/Users/andreaamaru/.platformio/packages/framework-arduinoespressif32/cores/esp32/io_pin_remap.h:45:69: error: 'digitalPinToGPIONumber' is not a type
 #define detachInterrupt(pin)                        detachInterrupt(digitalPinToGPIONumber(pin))
                                                                     ^~~~~~~~~~~~~~~~~~~~~~
.pio/libdeps/arduino_nano_esp32/RadioHead/RHGenericSPI.h:124:18: note: in expansion of macro 'detachInterrupt'
     virtual void detachInterrupt() {};
                  ^~~~~~~~~~~~~~~
.pio/libdeps/arduino_nano_esp32/RadioHead/RHGenericSPI.h:118:37: error: variable or field 'attachInterrupt' declared void
     virtual void attachInterrupt() {};
                                     ^
In file included from /Users/andreaamaru/.platformio/packages/framework-arduinoespressif32/cores/esp32/Arduino.h:235,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RadioHead.h:1540,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RHGenericSPI.h:10,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RHGenericSPI.cpp:7:
/Users/andreaamaru/.platformio/packages/framework-arduinoespressif32/cores/esp32/io_pin_remap.h:45:69: error: 'digitalPinToGPIONumber' is not a type
 #define detachInterrupt(pin)                        detachInterrupt(digitalPinToGPIONumber(pin))
                                                                     ^~~~~~~~~~~~~~~~~~~~~~
.pio/libdeps/arduino_nano_esp32/RadioHead/RHGenericSPI.h:124:18: note: in expansion of macro 'detachInterrupt'
     virtual void detachInterrupt() {};
                  ^~~~~~~~~~~~~~~
.pio/libdeps/arduino_nano_esp32/RadioHead/RHGenericSPI.h:118:37: error: variable or field 'attachInterrupt' declared void
     virtual void attachInterrupt() {};
                                     ^
In file included from /Users/andreaamaru/.platformio/packages/framework-arduinoespressif32/cores/esp32/Arduino.h:235,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RadioHead.h:1540,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RHGenericDriver.h:9,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RHSPIDriver.h:9,
                 from .pio/libdeps/arduino_nano_esp32/RadioHead/RHSPIDriver.cpp:6:
/Users/andreaamaru/.platformio/packages/framework-arduinoespressif32/cores/esp32/io_pin_remap.h:45:69: error: 'digitalPinToGPIONumber' is not a type
 #define detachInterrupt(pin)                        detachInterrupt(digitalPinToGPIONumber(pin))
                                                                     ^~~~~~~~~~~~~~~~~~~~~~
.pio/libdeps/arduino_nano_esp32/RadioHead/RHGenericSPI.h:124:18: note: in expansion of macro 'detachInterrupt'
     virtual void detachInterrupt() {};
                  ^~~~~~~~~~~~~~~
*** [.pio/build/arduino_nano_esp32/libc93/RadioHead/RHGenericSPI.cpp.o] Error 1
*** [.pio/build/arduino_nano_esp32/libc93/RadioHead/RH_MRF89.cpp.o] Error 1
*** [.pio/build/arduino_nano_esp32/libc93/RadioHead/RHSPIDriver.cpp.o] Error 1
*** [.pio/build/arduino_nano_esp32/libc93/RadioHead/RHHardwareSPI.cpp.o] Error 1
*** [.pio/build/arduino_nano_esp32/libc93/RadioHead/RH_CC110.cpp.o] Error 1
*** [.pio/build/arduino_nano_esp32/libc93/RadioHead/RHNRFSPIDriver.cpp.o] Error 1
*** [.pio/build/arduino_nano_esp32/libc93/RadioHead/RHSoftwareSPI.cpp.o] Error 1

Here is a page I found useful for working with interrupts on the ESP32 platform:

Yes i managed to re-create your issue. A compile for the NanoESP32 fails on a conflict with the radiohead library.

I also did a compile for an ESP32 devboard and that works without issues.

This is therefore not relevant since it is specific to 'normal' ESP32 boards where the issue does not exist.

First of all you have posted in the wrong category. There is a category specific for the NanoESP32.

There was an earlier topic which was also posted here also unresolved

I will flag it for the moderators to move, and since it is a conflict/ error specific to official Arduino boards i think it may be relevant to bring it to the attention of someone from the Arduino team, where @ptillisch seems to be the most active member on the forum, maybe he/she can delve a little deeper, and a solution can be found.

If i understand correctly, there are actually multiple radiohead libraries on github (and probably some more that have a different name but do the same) and my best advice would be to try them and see if any of those do work, since this one clearly doesn't and an easy solution is not available at this time.

2 Likes

Your topic was moved to its current location as it is more suitable.

Could you also take a few moments to Learn How To Use The Forum.

It will help you get the best out of the forum in the future.

Thank you

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.