Can't compile with RadioHead library on Nano 33 BLE

I am new to PlatformIO (I am running on VS.Code) and struggling with what I assume is a basic library management issue.

I have a bare-bones .cpp file that includes both RH_ASK.h and SPI.H. Both loop() and setup() are empty.

Not surprisingly the program compiles just fine with the Arduino IDE but fails under PlatformIO with numerous compilation errors (one example is below).

I have manually installed the RadioHead library, deleted/reinstalled it, forcefully deleted the /libdeps/…/RadioHead folder (and re-installed the library) and so on. But I can’t find a way get this to compile.

I have been researching (here and elsewhere) for a solution for quite some time. I have seen a few older posts are related to this, but none have helped to date.

Anyone care to put me out of my misery? Thank you.

.pio\build\nano33ble\libfcf\RadioHead\RHHardwareSPI.cpp.o
.pio\libdeps\nano33ble\RadioHead\RHHardwareSPI.cpp: In member function 'virtual void RHHardwareSPI::begin()':
.pio\libdeps\nano33ble\RadioHead\RHHardwareSPI.cpp:133:57: error: invalid conversion from 'uint8_t' {aka 'unsigned char'} to 'BitOrder' [-fpermissive]
    _settings = SPISettings(frequency, bitOrder, dataMode);
                                                         ^

In case it is relevant, here’s my platformio.ini

[env:nano33ble]
platform = nordicnrf52
board = nano33ble
framework = arduino
lib_deps = mikem/RadioHead@^1.113

and my main.cpp…

#include <Arduino.h>
#include <RH_ASK.h>
#include <SPI.h> // Not actually used but needed to compile
void setup()
{
}
void loop()
{
}

I see reports here (Error on compiling radiohead RF_ASK transmission example on Nano BLE - Programming Questions - Arduino Forum) of it failing compilation with the Nano 33 BLE in Arduino IDE too.

If we suppress the first error by allowing the unsafe conversion using build_flags = -fpermissive in the platformio.ini, there are just more build errors showing up.

.pio\libdeps\nano33ble\RadioHead\RH_ASK.cpp:17:1: error: 'HardwareTimer' does not name a type
 HardwareTimer timer(TIM1);
 ^~~~~~~~~~~~~
.pio\libdeps\nano33ble\RadioHead\RH_ASK.cpp: In member function 'uint8_t RH_ASK::timerCalc(uint16_t, uint16_t, uint16_t*)':
.pio\libdeps\nano33ble\RadioHead\RH_ASK.cpp:136:40: error: 'F_CPU' was not declared in this scope
         unsigned long inv_clock_time = F_CPU / ((unsigned long)prescalerValue);
                                        ^~~~~
.pio\libdeps\nano33ble\RadioHead\RH_ASK.cpp:136:40: note: suggested alternative: 'FPU'
         unsigned long inv_clock_time = F_CPU / ((unsigned long)prescalerValue);
                                        ^~~~~
                                        FPU
.pio\libdeps\nano33ble\RadioHead\RH_ASK.cpp: In member function 'void RH_ASK::timerSetup()':
.pio\libdeps\nano33ble\RadioHead\RH_ASK.cpp:394:5: error: 'TCCR1A' was not declared in this scope
     TCCR1A = 0; // Output Compare pins disconnected

The library tries to access a class only existant in the STM32 core (`HardwareTimer´) and then further down the lines tries to access timer registers from AVR chips – that doesn’t work ofc.

On top of it it doesn’t seem to know about the special Arduino-mbed-os core which also has some classes with the same names and must be accessed via arduino::<class name>, otherwise things are ambiguous.

.pio\libdeps\nano33ble\RadioHead/RH_Serial.h:237:5: error: reference to 'HardwareSerial' is ambiguous
     HardwareSerial& _serial;

Looking at the code of the RadioHead library, there is ARDUINO_ARCH_NRF52 which makes you think it supports the NRF52 chips but it still tries to do the things above and fails.

Can you state the exact download link to the RadioHead library, show a screenshot of the Arduino IDE settings (board etc.) in which it works and the version of the used Arduino-mbedos core in the Board manager?

Thank you so much for your response. I really appreciate it and, although I am not yet able to compile, I think you nailed the underlying cause.

First - I lied :slight_smile: I have been switching back and forth between a Mega and my Nano BLE 33 and didn’t notice that I had left the Arduino IDE compiling for the former. So, it wasn’t a fair fight!

I switched back to the Nano and this basic program also fails on the Arduino. I apologize for the misleading statement with that.

So, I think means that this is unrelated to RadioHead directly and, rather, seems to be a more basic conflict with the Nano itself (and, presumably, SPI support).

After playing with Arduino probably a decade ago, I am just now getting back into it and haven’t yet got my mind around the various architectures and dependencies. I am currently not really understanding all this yet and I am sure this will take me a while to figure out. But your response has been very helpful in refocusing my investigation and I appreciate that.

Onwards…

Any luck with solving this? I’m working on a school project with two 433hz transmitters and I don’t know if it’s better to try and roll my own library or fix this one?