RAK11300 - now with Arduino Pico Support and RadioLib!

Dear all,
thanks to the support of the Arduino Pico and RadioLib community, I got the RAK11300 now working under “plain” Arduino, meaning full dual core support and all normal libs. This should come in as a welcome alternative to the mbedOS BSP supplied by RAKwireless.
All information, example code and documentation here: https://www.nico-maas.de/?p=2607

Best regards,
Nico

Welcome back to the forum @nmaas87

Thanks for sharing this. I was looking into Earls BSP before, but never found the time to implement the LoRa/LoRaWAN functions.

Congrats!!!

1 Like

Thanks a lot @beegee - do you know by chance if the RAK3172 is already supported by alternative BSPs than the RAK ones? :slight_smile:
Thanks a lot

Hi @nmaas87 ,

For RAK3172, STM32duino now supports RAK3172 :slight_smile:

It is a good alternative for RUI3 if features/libraries is not yet supported. For example is the onewire library for DS18B20, it is still not supported by RUI3 at the moment but it is working on STM32Duino.

Uploading the sketch though via STM32duino requires you to manually set to BOOT mode. The good thing is that STM32CubeProgrammer v2.10.0 is integrated directly on STM32duino Arduino BSP so no need to open STM32CubeProgrammer application to upload the code.

I haven’t explored much on STM32duino other than running the DS18B20 library.

As for LoRa/LoRaWAN, RadioLib should be able to support it. I did preliminary run but I am having issues with it. Maybe you can have a look since you are more familiar to RadioLib. It is a wonderful library but it seems the LoRaWAN support is focused on LoRaWAN v1.1 implementation (which is good but still uncommon to be used these days).

HINT:
If you are going to use RAK3172 on RadioLib, please configure the table this way which supports only High Power output of STM32WL RF Out.

// no need to configure pins, signals are routed to the radio internally
STM32WLx radio = new STM32WLx_Module();

// set RF switch configuration for Nucleo WL55JC1
// NOTE: other boards may be different!
//       Some boards may not have either LP or HP.
//       For those, do not set the LP/HP entry in the table.
static const uint32_t rfswitch_pins[] = {PB8, PC13, RADIOLIB_NC};
static const Module::RfSwitchMode_t rfswitch_table[] = {
  {STM32WLx::MODE_IDLE,  {LOW,  LOW}},
  {STM32WLx::MODE_RX,    {HIGH, LOW}},
  {STM32WLx::MODE_TX_HP, {LOW,  HIGH}},
  END_OF_MODE_TABLE,
};

You also need to disable TXCO on radio begin since RAK3172 uses XTAL as clock source. Here, the last parameter 0 disable TXCO.

int state = radio.begin(915.0, 250.0, 7, 5, 0x34, 20, 8, 0);

Congrats again on your awesome great work on RAK11300!

If plan to dig deep on RAK3172 RadioLib support, just let us know what you need. But that should be on a different forum topic :ok_hand:

Thank you @carlrowan - I actually plan to look depper into the RAK3172 - but I first need to get hand on some modules. Actually I also plan on using the ones with TXCO as I need to run in a extreme environment, so I guess it would need to be

int state = radio.begin(915.0, 250.0, 7, 5, 0x34, 20, 8, 1);

, correct? Thanks :slight_smile:

Yes, that’s correct :+1:

But you have to do further test on it. It seems SX1262 support for LoRa/LoRaWAN is not yet mature on RadioLib

1 Like

That should have been improved quite a lot with the last release, they really did some wonders with overall LoRaWAN support and I found some errors myself, including wrong coding rates for EU868 which did deny any connection to a LoRaWAN gateway - which could already been solved. Now I am just missing some modules to test this :slight_smile:

@nmaas87
Can I ask for some help from you?
After having no success with RadioLib, I added support for Arduino Pico BSP (Earl’s BSP) to my SX126x-Arduino library.

I have tested it and it works (both LoRa P2P and LoRaWAN), but I need more testers :grin:

The library version is not published, so it needs manual installation from Github SX126x-Arduino.
On ArduinoIDE, the usual way with ZIP file.
On PIO by using

lib_deps = 
	https://github.com/beegee-tokyo/SX126x-Arduino.git
	khoih-prog/RPI_PICO_TimerInterrupt

Example code for both LoRa P2P and LoRaWAN is in the library examples folder RAK11310-Earl

Hey @beegee - sorry I am quite time limited right now, so I am sorry that I could not do much more than a quick look: I was able install the latest lib directly from Github for Arduino as well as the needed RPI_PICO_TimerInterrupt. Compiling with the latest Arduino Pico BSP set to RAK11300 worked.
I needed to change the LoRaWAN parameters to be more in line with my EU868 network:

// Define LoRa parameters
#define RF_FREQUENCY 868300000	// Hz
#define TX_OUTPUT_POWER 22		// dBm
#define LORA_BANDWIDTH 0		// [0: 125 kHz, 1: 250 kHz, 2: 500 kHz, 3: Reserved]
#define LORA_SPREADING_FACTOR 7 // [SF7..SF12]
#define LORA_CODINGRATE 1		// [1: 4/5, 2: 4/6,  3: 4/7,  4: 4/8]
#define LORA_PREAMBLE_LENGTH 8	// Same for Tx and Rx
#define LORA_SYMBOL_TIMEOUT 0	// Symbols
#define LORA_FIX_LENGTH_PAYLOAD_ON false
#define LORA_IQ_INVERSION_ON false
#define RX_TIMEOUT_VALUE 0
#define TX_TIMEOUT_VALUE 3000

as well as load the EU868 region:

		// Initialize LoRaWan
		uint32_t err_code = lmh_init(&lora_callbacks, lora_param_init, true, CLASS_A, LORAMAC_REGION_EU868);

with that changes I could see within ChirpStack that the node sent join requests and also got acknowledgements sent back.

For unknown reason however, it seems like the node does not see any acknowledgement:

Setup LoRaWAN
Join LoRaWAN
OVER_THE_AIR_ACTIVATION failed!
Check your EUI's and Keys's!
Check if a Gateway is in range!
Did not join network, skip sending frame
OVER_THE_AIR_ACTIVATION failed!
Check your EUI's and Keys's!
Check if a Gateway is in range!
Did not join network, skip sending frame
OVER_THE_AIR_ACTIVATION failed!
Check your EUI's and Keys's!
Check if a Gateway is in range!
Did not join network, skip sending frame
OVER_THE_AIR_ACTIVATION failed!
Check your EUI's and Keys's!
Check if a Gateway is in range!
Did not join network, skip sending frame

I do not know what happens here - I also wondered how to set the Network key in your lib, however as I had network key set the same as the application key, it seemed to be working fine.

As the gateway sends out JoinAccept, it looks promising, I am not sure why the node does not pick this up, however as I said that was all that I could do, I sadly will not have more time to look into it.

In regards to RadioLib I am a bit stunned that it did not work out for you. Most important thing is to use the latest Arduino Pico and latest RadioLib. The use of the lib is a bit complicated at the start and this is not yet communicated in the right way. Looking at my example posted at the end of my blog it does not show the whole reality.

On the first bootup, you have to setup like this. With that it will erase the virtual EEPROM and do an OTAA as well as save the OTAA information in said EEPROM.

  // first we need to initialize the device storage
  // this will reset all persistently stored parameters
  // NOTE: This should only be done once prior to first joining a network!
  //       After wiping persistent storage, you will also have to reset
  //       the end device in TTN and perform the join procedure again!
  // Here, a delay is added to make sure that during re-flashing
  // the .wipe() is not triggered and the session is lost
  delay(5000);
  node.wipe();

  // now we can start the activation
  // Serial.print(F("[LoRaWAN] Attempting over-the-air activation ... "));
  uint64_t joinEUI = 0x12AD1011B0C0FFEE;
  uint64_t devEUI = 0x70B3D57ED005E120;
  uint8_t nwkKey[] = { 0x74, 0x6F, 0x70, 0x53, 0x65, 0x63, 0x72, 0x65,
                        0x74, 0x4B, 0x65, 0x79, 0x31, 0x32, 0x33, 0x34 };
  uint8_t appKey[] = { 0x61, 0x44, 0x69, 0x66, 0x66, 0x65, 0x72, 0x65,
                        0x6E, 0x74, 0x4B, 0x65, 0x79, 0x41, 0x42, 0x43 };
  state = node.beginOTAA(joinEUI, devEUI, nwkKey, appKey);

  // after the device has been activated,
  // the session can be restored without rejoining after device power cycle
  // on EEPROM-enabled boards by calling "restore"
  //Serial.print(F("[LoRaWAN] Resuming previous session ... "));
  //state = node.restore();
  if(state == RADIOLIB_ERR_NONE) {
    Serial.println(F("success!"));
  } else {
    Serial.print(F("failed, code "));
    Serial.println(state);
    while(true);
  }

your session/join should work now, let it run for a bit so that it can save the info to the EEPROM. If you (in the future) do not want to OTAA on each boot up, you should shutdown your node, hold the boot button, connect it again to USB (with that the U2F bootloader will come up and the device will not boot - which is important - as it would erase the EEPROM again ;).
You then need to change the same code area again to following:

  // first we need to initialize the device storage
  // this will reset all persistently stored parameters
  // NOTE: This should only be done once prior to first joining a network!
  //       After wiping persistent storage, you will also have to reset
  //       the end device in TTN and perform the join procedure again!
  // Here, a delay is added to make sure that during re-flashing
  // the .wipe() is not triggered and the session is lost
  // delay(5000);
  // node.wipe();

  // now we can start the activation
  // Serial.print(F("[LoRaWAN] Attempting over-the-air activation ... "));
  // uint64_t joinEUI = 0x12AD1011B0C0FFEE;
  // uint64_t devEUI = 0x70B3D57ED005E120;
  // uint8_t nwkKey[] = { 0x74, 0x6F, 0x70, 0x53, 0x65, 0x63, 0x72, 0x65,
  //                      0x74, 0x4B, 0x65, 0x79, 0x31, 0x32, 0x33, 0x34 };
  // uint8_t appKey[] = { 0x61, 0x44, 0x69, 0x66, 0x66, 0x65, 0x72, 0x65,
  //                      0x6E, 0x74, 0x4B, 0x65, 0x79, 0x41, 0x42, 0x43 };
  // state = node.beginOTAA(joinEUI, devEUI, nwkKey, appKey);

  // after the device has been activated,
  // the session can be restored without rejoining after device power cycle
  // on EEPROM-enabled boards by calling "restore"
  Serial.print(F("[LoRaWAN] Resuming previous session ... "));
  state = node.restore();
  if(state == RADIOLIB_ERR_NONE) {
    Serial.println(F("success!"));
  } else {
    Serial.print(F("failed, code "));
    Serial.println(state);
    while(true);
  }

so that it will not do OTAA but just restore the saved session from the EEPROM and join with that info.

All the best :slight_smile:

@nmaas87
Thanks for the tests. I didn’t try EU868 yet. Your feedback is very helpful and I will look into it.

I think there is still some problem with the timers required. I am getting a failure when using confirmed packets and the ACK is not received.

Solved, the SX126x-Arduino library is now working with the Arduino-Pico BSP RAK11300. Just published the library.

For the RadioLib, I tried several ways, with and without wipe the virtual EEPROM. Still no success.
Can’t use RadioLib anyway here, even if it would work for me. There is no support for AS923-3 region. It is quite limited.

1 Like

Thats awesome to hear, congrats! :slight_smile: