I followed the instructions…
Just over a week ago I purchased some gear from RAK Wireless, the shipping was reasonable, it arrived promptly, and was well packaged. I had ordered
- 1 x RAK7246G LPWAN Developer Gateway – AS923
- 1 x Power Adapter – AU Standard
- 5 x RAK811 LPWAN Module – AS923 for another project)
- 1 x RAK811 LPWAN Evaluation Board – AS923
- 1 x RAK811 LPWAN Breakout Module – AS923
I figured a good first project would be to get the evaluation board going with one of my older Arduino Uno R3 devices following the Interfacing your RAK811 LPWAN Evaluation Board with Arduino Boards instructions.
The evaluation board was in its own box along with a USB cable, some spare PCB jumpers, some jumper leads and an antenna labeled with the frequency band which was thoughtful.

I downloaded the specified library from the RAK Wireless Github repository extracted the contents and copied the V1.3 directory into the libraries folder of my Arduino IDE install.
I updated the module software to the latest using the tools provided in the github download and checked this with the RAK Serial Port tool over the Universal Serial Bus(USB) connection (make sure the jumpers next to the antenna connection are set correctly)

I created a new project based on JoinNetworkOTAA (Over the Air Activation) example.
/********************************************************
* This demo is only supported after RUI firmware version 3.0.0.13.X on RAK811
* Master Board Uart Receive buffer size at least 128 bytes.
********************************************************/
#include "RAK811.h"
#include "SoftwareSerial.h"
#define WORK_MODE LoRaWAN // LoRaWAN or LoRaP2P
#define JOIN_MODE OTAA // OTAA or ABP
#if JOIN_MODE == OTAA
String DevEui = "8680000000000001";
String AppEui = "70B3D57ED00285A7";
String AppKey = "DDDFB1023885FBFF74D3A55202EDF2B1";
#else JOIN_MODE == ABP
String NwkSKey = "69AF20AEA26C01B243945A28C9172B42";
String AppSKey = "841986913ACD00BBC2BE2479D70F3228";
String DevAddr = "260125D7";
#endif
#define TXpin 11 // Set the virtual serial port pins
#define RXpin 10
#define DebugSerial Serial
SoftwareSerial ATSerial(RXpin,TXpin); // Declare a virtual serial port
char buffer[]= "72616B776972656C657373";
bool InitLoRaWAN(void);
RAK811 RAKLoRa(ATSerial,DebugSerial);
void setup() {
DebugSerial.begin(115200);
while(DebugSerial.available())
{
DebugSerial.read();
}
ATSerial.begin(9600); //set ATSerial baudrate:This baud rate has to be consistent with the baud rate of the WisNode device.
while(ATSerial.available())
{
ATSerial.read();
}
if(!RAKLoRa.rk_setWorkingMode(0)) //set WisNode work_mode to LoRaWAN.
{
DebugSerial.println(F("set work_mode failed, please reset module."));
while(1);
}
RAKLoRa.rk_getVersion(); //get RAK811 firmware version
DebugSerial.println(RAKLoRa.rk_recvData()); //print version number
DebugSerial.println(F("Start init RAK811 parameters..."));
if (!InitLoRaWAN()) //init LoRaWAN
{
DebugSerial.println(F("Init error,please reset module."));
while(1);
}
DebugSerial.println(F("Start to join LoRaWAN..."));
while(!RAKLoRa.rk_joinLoRaNetwork(60)) //Joining LoRaNetwork timeout 60s
{
DebugSerial.println();
DebugSerial.println(F("Rejoin again after 5s..."));
delay(5000);
}
DebugSerial.println(F("Join LoRaWAN success"));
if(!RAKLoRa.rk_isConfirm(0)) //set LoRa data send package type:0->unconfirm, 1->confirm
{
DebugSerial.println(F("LoRa data send package set error,please reset module."));
while(1);
}
}
bool InitLoRaWAN(void)
{
if(RAKLoRa.rk_setJoinMode(JOIN_MODE)) //set join_mode:OTAA
{
if(RAKLoRa.rk_setRegion(0)) //set region EU868
{
if (RAKLoRa.rk_initOTAA(DevEui, AppEui, AppKey))
{
DebugSerial.println(F("RAK811 init OK!"));
return true;
}
}
}
return false;
}
void loop() {
DebugSerial.println(F("Start send data..."));
if (RAKLoRa.rk_sendData(1, buffer))
{
for (unsigned long start = millis(); millis() - start < 90000L;)
{
String ret = RAKLoRa.rk_recvData();
if(ret != NULL)
{
DebugSerial.println(ret);
}
if((ret.indexOf("OK")>0)||(ret.indexOf("ERROR")>0))
{
DebugSerial.println(F("Go to Sleep."));
RAKLoRa.rk_sleep(1); //Set RAK811 enter sleep mode
delay(10000); //delay 10s
RAKLoRa.rk_sleep(0); //Wakeup RAK811 from sleep mode
break;
}
}
}
}
I had to look at the library code to work out the value the rk_setRegion call needed for the AS932 band used in my region
bool RAK811::rk_setRegion(int region)
{
if (region > 9)
{
_serial1.println(F("Parameter error"));
return false;
}
String REGION;
switch (region)
{
case 0:REGION="AS923";
break;
case 1:REGION="AU915";
break;
case 2:REGION="CN470";
break;
case 3:REGION="CN779";
break;
case 4:REGION="EU433";
break;
case 5:REGION="EU868";
break;
case 6:REGION="KR920";
break;
case 7:REGION="IN865";
break;
case 8:REGION="US915";
break;
case 9:REGION="US915_Hybrid";
break;
}
_serial1.println("Current work region: "+REGION);
sendRawCommand("at+set_config=lora:region:" + REGION);
ret = rk_recvData();
#if defined DEBUG_MODE
_serial1.println(ret);
#endif
if (ret.indexOf("OK") >= 0)
{
return true;
}
else
{
return false;
}
}
I compiled the code, uploaded it to my device and it didn’t work…

I then had a look at the Arduino library code and enabled some of the commented out diagnostic println statements. At the time it did seem odd there were no responses from the module.

I had noticed some odd characters in the RAK Serial Port Tool while checking version numbers etc.

It looked like maybe the serial port was having some issues, so I double checked my modification of the HardwareSerial.h file and began to wonder (as the binary size wasn’t changing) if I had the right file. After some research I found there are several copies of that file and I wasn’t modifying the correct one.

Then I realised that the port sending AT Commands to the module was actually a SoftwareSerial port not a hardware one. I then tried changing the size of the software serial buffers but still was having problems.


I then tried recompiling with different settings to see if the serial port issues would stop. The global variables size changed which showed I had the right files/settings but the code still didn’t work.
Going back over my settings I tried the command used in the rk_setWorkingMode call in the RAK Serial Port Tool and it worked.

I then then went for a walk and when I came back I realised the module speed was set to 115200 baud by default (which it is). I then used at+set_config=device:uart:1:9600 (don’t forget to press <enter> at end of the line) to set baud rate to match the code.

I then changed the jumpers and ran the software again…

So, it looks like the RAK811 module was set to 115200 baud (web based setup instructions), but the later library versions were 9600 baud, but the instructions didn’t mention the need to change the speed with the RAK Serial port tool.

Now that my device is trying to connect to a network I need to configure the LoRaWAN network settings. I’m going to use the RAK7246G LPWAN Developer Gateway and the nationwide LoRaWAN network operated by Spark in New Zealand.