├── Arduino-RAK811-Library ├── RAK811.cpp ├── RAK811.h ├── examples │ ├── JoinNetworkABP │ │ └── JoinNetworkABP.ino │ ├── JoinNetworkOTAA │ │ └── JoinNetworkOTAA.ino │ └── LoRaP2P │ │ ├── LoRaP2P_Receiver │ │ └── LoRaP2P_Receiver.ino │ │ └── LoRaP2P_Sender │ │ └── LoRaP2P_Sender.ino └── keywords.txt ├── Documents and tools ├── RAL LoRaButton Upgrade Tool V1.0.exe ├── SchematIC │ ├── Arduino_Uno_Rev3-schematic.pdf │ ├── WisNode LoRaV1.1.pdf │ ├── WisNode LoRaV1.2.pdf │ └── arduino-mega2560_R3-sch.pdf ├── WisNode-Arduino version-Firmware │ ├── WisNode-Arduino version-H.hex │ └── WisNode-Arduino version-L.hex ├── WisNodeV1.1 Arduino Library │ ├── Arduino-RAK811-Library │ │ ├── RAK811.cpp │ │ ├── RAK811.h │ │ ├── examples │ │ │ ├── JoinNetworkABP │ │ │ │ └── JoinNetworkABP.ino │ │ │ ├── JoinNetworkOTAA │ │ │ │ └── JoinNetworkOTAA.ino │ │ │ └── LoRaP2P │ │ │ │ ├── LoRaP2P_Receiver │ │ │ │ └── LoRaP2P_Receiver.ino │ │ │ │ └── LoRaP2P_Sender │ │ │ │ └── LoRaP2P_Sender.ino │ │ └── keywords.txt │ └── RAK811 WisNode V1.1 Hardware.md ├── WisNodeV1.2 Arduino Library │ ├── Arduino-RAK811-Library │ │ ├── RAK811.cpp │ │ ├── RAK811.h │ │ ├── examples │ │ │ ├── JoinNetworkABP │ │ │ │ └── JoinNetworkABP.ino │ │ │ ├── JoinNetworkOTAA │ │ │ │ └── JoinNetworkOTAA.ino │ │ │ └── LoRaP2P │ │ │ │ ├── LoRaP2P_Receiver │ │ │ │ └── LoRaP2P_Receiver.ino │ │ │ │ └── LoRaP2P_Sender │ │ │ │ └── LoRaP2P_Sender.ino │ │ └── keywords.txt │ └── RAK811 WisNode V1.2 Hardware.md ├── WisNode_Arduino_Library API Manual V1.1.pdf └── image │ ├── Arduino_mode_v1.1.png │ ├── Arduino_mode_v1.2.png │ ├── Arduino_mode_v1.3.png │ ├── Download_Firmware.png │ ├── Library_directory.png │ ├── Library_in_the_menu.png │ ├── LoRaWAN_log.png │ ├── RAK811_jump_line.png │ ├── Serial_port_configuration_modification.png │ ├── TTN_log.png │ ├── V1.1_log.png │ ├── V1.2_jump.png │ ├── arduino_connect_RAK811.jpg │ ├── burn_firmware.png │ ├── connect_STM32cubeprogrammer.png │ ├── jump_boot.png │ └── merge_connect.png └── README.md /Arduino-RAK811-Library/RAK811.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * A library for controlling RAK811 LoRa radio. 3 | * 4 | * @Author Leopold.wang 5 | * @Date 14/01/2020 6 | * 7 | */ 8 | 9 | #include "Arduino.h" 10 | #include "RAK811.h" 11 | 12 | extern "C" 13 | { 14 | #include "string.h" 15 | #include "stdlib.h" 16 | } 17 | String ret = ""; 18 | String command = ""; 19 | /* 20 | @param serial Needs to be an already opened Stream ({Software/Hardware}Serial) to write to and read from. 21 | */ 22 | RAK811::RAK811(Stream &serial, Stream &serial1) : _serial(serial), _serial1(serial1) 23 | { 24 | _serial.setTimeout(2000); 25 | _serial1.setTimeout(1000); 26 | } 27 | 28 | bool RAK811::rk_getVersion() 29 | { 30 | return sendRawCommand(F("at+version")); 31 | } 32 | 33 | String RAK811::rk_getLoRaStatus() 34 | { 35 | sendRawCommand(F("at+get_config=lora:status")); 36 | ret = rk_recvData(); 37 | ret.trim(); 38 | return ret; 39 | } 40 | 41 | String RAK811::rk_getChannelList() 42 | { 43 | sendRawCommand(F("at+get_config=lora:channel")); 44 | ret = rk_recvData(); 45 | ret.trim(); 46 | return ret; 47 | } 48 | 49 | bool RAK811::rk_setRate(int rate) 50 | { 51 | sendRawCommand("at+set_config=lora:dr:" + (String)rate); 52 | ret = rk_recvData(); 53 | if (ret.indexOf("OK") >= 0) 54 | { 55 | return true; 56 | } 57 | else 58 | { 59 | return false; 60 | } 61 | } 62 | 63 | bool RAK811::rk_setClass(int classMode) 64 | { 65 | if (classMode > 2) 66 | { 67 | _serial1.println(F("Parameter error")); 68 | return false; 69 | } 70 | command = "at+set_config=lora:class:" + (String)classMode; 71 | sendRawCommand(command); 72 | ret = rk_recvData(); 73 | #if defined DEBUG_MODE 74 | _serial1.println(ret); 75 | #endif 76 | if (ret.indexOf("OK") >= 0) 77 | { 78 | return true; 79 | } 80 | else 81 | { 82 | return false; 83 | } 84 | } 85 | 86 | bool RAK811::rk_setRegion(int region) 87 | { 88 | if (region > 9) 89 | { 90 | _serial1.println(F("Parameter error")); 91 | return false; 92 | } 93 | String REGION; 94 | switch (region) 95 | { 96 | case 0:REGION="AS923"; 97 | 98 | break; 99 | case 1:REGION="AU915"; 100 | break; 101 | case 2:REGION="CN470"; 102 | break; 103 | case 3:REGION="CN779"; 104 | break; 105 | case 4:REGION="EU433"; 106 | break; 107 | case 5:REGION="EU868"; 108 | break; 109 | case 6:REGION="KR920"; 110 | break; 111 | case 7:REGION="IN865"; 112 | break; 113 | case 8:REGION="US915"; 114 | break; 115 | case 9:REGION="US915_Hybrid"; 116 | break; 117 | } 118 | _serial1.println("Current work region: "+REGION); 119 | sendRawCommand("at+set_config=lora:region:" + REGION); 120 | ret = rk_recvData(); 121 | #if defined DEBUG_MODE 122 | _serial1.println(ret); 123 | #endif 124 | if (ret.indexOf("OK") >= 0) 125 | { 126 | return true; 127 | } 128 | else 129 | { 130 | return false; 131 | } 132 | } 133 | 134 | void RAK811::rk_sleep(int mode) 135 | { 136 | switch (mode) 137 | { 138 | case 1: 139 | sendRawCommand(F("at+set_config=device:sleep:1")); 140 | break; 141 | case 0: 142 | sendRawCommand(F("at+set_config=device:sleep:0")); 143 | break; 144 | default: 145 | _serial1.println(F("Parameter error")); 146 | break; 147 | } 148 | } 149 | 150 | bool RAK811::rk_setSendinterval(int mode, int value) 151 | { 152 | if (mode > 2) 153 | { 154 | _serial1.println("The mode set Error,the mode is '0','1' or '2'."); 155 | return false; 156 | } 157 | 158 | sendRawCommand("at+set_config=lora:send_interval:" + (String)mode + ":" + (String)value); 159 | ret = rk_recvData(); 160 | if (ret.indexOf("OK") >= 0) 161 | { 162 | return true; 163 | } 164 | else 165 | { 166 | return false; 167 | } 168 | } 169 | 170 | void RAK811::rk_reset(void) 171 | { 172 | sendRawCommand(F("at+set_config=device:restart")); 173 | } 174 | 175 | bool RAK811::rk_setWorkingMode(int mode) 176 | { 177 | switch (mode) 178 | { 179 | case 0: 180 | sendRawCommand(F("at+set_config=lora:work_mode:0")); //Set LoRaWAN Mode. 181 | break; 182 | case 1: 183 | sendRawCommand(F("at+set_config=lora:work_mode:1")); //Set LoRaP2P Mode. 184 | break; 185 | default: 186 | return false; 187 | } 188 | 189 | for(int i=0; i<10; i++) 190 | { 191 | ret = rk_recvData(); 192 | // _serial1.println(ret); 193 | if ((ret.indexOf("Initialization OK") >= 0) || (ret.indexOf("No switch work_mode") >= 0)) 194 | { 195 | return true; 196 | } 197 | } 198 | 199 | return false; 200 | 201 | } 202 | 203 | bool RAK811::rk_setJoinMode(int mode) 204 | { 205 | switch (mode) 206 | { 207 | case 0: 208 | sendRawCommand(F("at+set_config=lora:join_mode:0")); //join Network through OTAA mode. 209 | break; 210 | case 1: 211 | sendRawCommand(F("at+set_config=lora:join_mode:1")); //join Network through ABP mode. 212 | break; 213 | default: 214 | return false; 215 | } 216 | ret = rk_recvData(); 217 | if (ret.indexOf("OK") >= 0) 218 | { 219 | return true; 220 | } 221 | else 222 | { 223 | return false; 224 | } 225 | } 226 | 227 | bool RAK811::rk_joinLoRaNetwork(int timeout) 228 | { 229 | String command = "at+join"; 230 | // _serial1.println(command); 231 | sendRawCommand(command); 232 | ret = rk_recvData(); 233 | if (ret != NULL) 234 | { 235 | if (ret.indexOf("OK") >= 0) 236 | return true; 237 | else if(ret.indexOf("ERROR") >= 0) 238 | return false; 239 | } 240 | for (int i = 0; i <= timeout/2; i++) 241 | { 242 | ret = rk_recvData(); 243 | if (ret != NULL) 244 | { 245 | _serial1.print("<- " + ret); 246 | if (ret.indexOf("OK") >= 0) 247 | return true; 248 | // else if(ret.indexOf("ERROR") >= 0) 249 | // return false; 250 | } 251 | } 252 | 253 | return false; 254 | } 255 | 256 | bool RAK811::rk_initOTAA(String devEUI, String appEUI, String appKEY) 257 | { 258 | // String command = ""; 259 | if (devEUI.length() == 16) 260 | { 261 | _devEUI = devEUI; 262 | } 263 | else 264 | { 265 | _serial1.println("The parameter devEUI is set incorrectly!"); 266 | } 267 | if (appEUI.length() == 16) 268 | { 269 | _appEUI = appEUI; 270 | } 271 | else 272 | { 273 | _serial1.println("The parameter appEUI is set incorrectly!"); 274 | } 275 | if (appKEY.length() == 32) 276 | { 277 | _appKEY = appKEY; 278 | } 279 | else 280 | { 281 | _serial1.println("The parameter appKEY is set incorrectly!"); 282 | } 283 | 284 | command = "at+set_config=lora:dev_eui:" + _devEUI; 285 | // _serial1.println(command); 286 | sendRawCommand(command); 287 | ret = rk_recvData(); 288 | if (ret.indexOf("OK") >= 0) 289 | { 290 | command = "at+set_config=lora:app_eui:" + _appEUI; 291 | // _serial1.println(command); 292 | sendRawCommand(command); 293 | 294 | ret = rk_recvData(); 295 | if (ret.indexOf("OK") >= 0) 296 | { 297 | command = "at+set_config=lora:app_key:" + _appKEY; 298 | // _serial1.println(command); 299 | sendRawCommand(command); 300 | 301 | ret = rk_recvData(); 302 | if (ret.indexOf("OK") >= 0) 303 | { 304 | return true; 305 | } 306 | } 307 | } 308 | 309 | return false; 310 | } 311 | 312 | bool RAK811::rk_initABP(String devADDR, String nwksKEY, String appsKEY) 313 | { 314 | // String command = ""; 315 | if (devADDR.length() == 8) 316 | { 317 | _devADDR = devADDR; 318 | } 319 | else 320 | { 321 | _serial1.println(F("The parameter devADDR is set incorrectly!")); 322 | } 323 | if (nwksKEY.length() == 32) 324 | { 325 | _nwksKEY = nwksKEY; 326 | } 327 | else 328 | { 329 | _serial1.println(F("The parameter nwksKEY is set incorrectly!")); 330 | } 331 | if (appsKEY.length() == 32) 332 | { 333 | _appsKEY = appsKEY; 334 | } 335 | else 336 | { 337 | _serial1.println(F("The parameter appsKEY is set incorrectly!")); 338 | } 339 | command = "at+set_config=lora:dev_addr:" + _devADDR; 340 | sendRawCommand(command); 341 | ret = rk_recvData(); 342 | // _serial1.println(ret); 343 | if (ret.indexOf("OK") >= 0) 344 | { 345 | command = "at+set_config=lora:nwks_key:" + _nwksKEY; 346 | sendRawCommand(command); 347 | ret = rk_recvData(); 348 | if (ret.indexOf("OK") >= 0) 349 | { 350 | command = "at+set_config=lora:apps_key:" + _appsKEY; 351 | sendRawCommand(command); 352 | ret = rk_recvData(); 353 | if (ret.indexOf("OK") >= 0) 354 | { 355 | return true; 356 | } 357 | } 358 | } 359 | return false; 360 | } 361 | 362 | bool RAK811::rk_isConfirm(int type) 363 | { 364 | switch (type) 365 | { 366 | case 0: 367 | sendRawCommand(F("at+set_config=lora:confirm:0")); //LoRa data send with unconfirm. 368 | break; 369 | case 1: 370 | sendRawCommand(F("at+set_config=lora:confirm:1")); //LoRa data send with confirm. 371 | break; 372 | default: 373 | return false; 374 | } 375 | ret = rk_recvData(); 376 | if (ret.indexOf("OK") >= 0) 377 | { 378 | return true; 379 | } 380 | else 381 | { 382 | return false; 383 | } 384 | } 385 | 386 | bool RAK811::rk_sendData(int port, char *datahex) 387 | { 388 | // String command = ""; 389 | command = "at+send=lora:" + (String)port + ":" + datahex; 390 | // _serial1.println(command); 391 | sendRawCommand(command); 392 | 393 | return true; 394 | } 395 | 396 | String RAK811::rk_recvData(void) 397 | { 398 | _serial.setTimeout(2000); 399 | ret = _serial.readStringUntil('\0'); 400 | // ret.trim(); 401 | // _serial1.println(ret); 402 | return ret; 403 | } 404 | 405 | bool RAK811::rk_initP2P(String FREQ, int SF, int BW, int CR, int PRlen, int PWR) 406 | { 407 | // String command = ""; 408 | command = "at+set_config=lorap2p:" + FREQ + "," + SF + "," + BW + "," + CR + "," + PRlen + "," + PWR; 409 | // _serial1.println(command); 410 | sendRawCommand(command); 411 | ret = rk_recvP2PData(); 412 | if (ret.indexOf("OK") >= 0) 413 | { 414 | return true; 415 | } 416 | else 417 | { 418 | return false; 419 | } 420 | } 421 | 422 | String RAK811::rk_recvP2PData(void) 423 | { 424 | ret = _serial.readStringUntil('\0'); 425 | ret.trim(); 426 | // delay(500); 427 | return ret; 428 | } 429 | 430 | bool RAK811::rk_sendP2PData(char *datahex) 431 | { 432 | String DATAHEX = datahex; 433 | String command = "at+send=lorap2p:" + DATAHEX; 434 | // _serial1.println(command); 435 | sendRawCommand(command); 436 | // ret = rk_recvP2PData(); 437 | // if (ret.indexOf("OK") > 0) 438 | // { 439 | // return true; 440 | // } 441 | // else 442 | // { 443 | // return false; 444 | // } 445 | return true; 446 | } 447 | 448 | String RAK811::rk_checkDeviceStatus(void) 449 | { 450 | sendRawCommand(F("at+get_config=device:status")); 451 | ret = rk_recvP2PData(); 452 | return ret; 453 | } 454 | 455 | bool RAK811::rk_setUARTConfig(int UartPort, int Baud) 456 | { 457 | // String command = ""; 458 | command = "at+set_config=device:uart:" + (String)UartPort + ":" + (String)Baud; 459 | // _serial1.println(command); 460 | sendRawCommand(command); 461 | 462 | return true; 463 | } 464 | 465 | bool RAK811::sendRawCommand(String cmd) 466 | { 467 | while (_serial.available()) 468 | { 469 | _serial.read(); 470 | } 471 | //_serial1.println(cmd); 472 | _serial.println(cmd); 473 | delay(200); 474 | return true; 475 | } 476 | -------------------------------------------------------------------------------- /Arduino-RAK811-Library/RAK811.h: -------------------------------------------------------------------------------- 1 | /* 2 | * A library for controlling RAK811 LoRa radio. 3 | * 4 | * @Author Leopold.wang 5 | * @Date 14/01/2020 6 | * 7 | */ 8 | 9 | 10 | #ifndef RAK811_h 11 | #define RAK811_h 12 | #define LoRaWAN 0 13 | #define LoRaP2P 1 14 | #define OTAA 0 15 | #define ABP 1 16 | 17 | #include "Arduino.h" 18 | 19 | // #define DEBUG_MODE 20 | 21 | class RAK811 22 | { 23 | public: 24 | 25 | /* 26 | * A simplified constructor taking only a Stream ({Software/Hardware}Serial) object. 27 | * The serial port should already be initialised when initialising this library. 28 | */ 29 | RAK811(Stream& serial,Stream& serial1); 30 | 31 | /* 32 | * Gets the firmware version number of the module. 33 | * Only applies to the firmware that the module programmed for the RAK811 AT command. 34 | * AT commands refer to: https://downloads.rakwireless.com/en/LoRa/RAK811/Application_Notes/Get_Start_with_RAK811_WisNode-LoRa.pdf 35 | */ 36 | bool rk_getVersion(void); 37 | 38 | /*STDB 39 | * Get the frequency band of the module. 40 | * This feature request to receive at least 800 bytes buffer size. 41 | */ 42 | String rk_getLoRaStatus(void); 43 | 44 | /* 45 | * Let the module enter the ultra low power sleep mode. 46 | * When the module is in sleep mode, the host can send any character to wake it up. 47 | * mode :0->wakeup, 1-> sleep 48 | * When the module is awakened, the event response will automatically return through the serial information. 49 | */ 50 | void rk_sleep(int mode); 51 | 52 | /* 53 | * Reset the module. 54 | */ 55 | void rk_reset(void); 56 | 57 | /* 58 | * This command is used to set the interval time of sending data. 59 | * This feature can't use on RAK811,manually close the feature before user APP. 60 | */ 61 | bool rk_setSendinterval(int mode,int value ); 62 | 63 | /* 64 | * Use to change the next send data rate temporary when adr function is off. 65 | * It will not be save to internal flash. 66 | * rate : If your Band is EU868 from 0 to 7. 67 | * If your Band is US915 from 0 to 4. 68 | */ 69 | bool rk_setRate(int rate); 70 | 71 | /* 72 | * Use to change the LoRaWAN class. 73 | * classMode->ClassA, 74 | * 1->ClassB, 75 | * 2->ClassC 76 | * It will be save to internal flash. 77 | */ 78 | bool rk_setClass(int classMode); 79 | 80 | /* 81 | * Use to change the LoRaWAN region. 82 | * region:0->AS923, 83 | * 1->AU915, 84 | * 2->CN470, 85 | * 3->CN779, 86 | * 4->EU433, 87 | * 5->EU868, 88 | * 6->KR920, 89 | * 7->IN865, 90 | * 8->US915, 91 | * 9->US915_Hybrid, 92 | * It will be save to internal flash. 93 | */ 94 | bool rk_setRegion(int region); 95 | 96 | /* 97 | * Set the module work mode, the module defaults to LoRaWAN mode.. 98 | * mode = 0: Set the module to LoRaWAN mode. 99 | * mode = 1: Set the module to LoRaP2P mode. 100 | * This command could cause modual reset,so this function must only be executed once 101 | */ 102 | bool rk_setWorkingMode(int mode); 103 | 104 | /* 105 | * Initialize the module parameter, which is the parameter that the module must use when adding the OTAA to the network. 106 | * devEUI : Device EUI as a HEX string. Example "60C5A8FFFE000001" 107 | * appEUI : Application EUI as a HEX string. Example "70B3D57EF00047C0" 108 | * appKEY : Application key as a HEX string. Example "5D833B4696D5E01E2F8DC880E30BA5FE" 109 | */ 110 | bool rk_initOTAA(String devEUI, String appEUI, String appKEY); 111 | 112 | /* 113 | * Initialize the module parameter, which is the parameter that the module must use when adding the ABP to the network. 114 | * devADDR : The device address as a HEX string. Example "00112233" 115 | * nwksKEY : Network Session Key as a HEX string. Example "3432567afde4525e7890cfea234a5821" 116 | * appsKEY : Application Session Key as a HEX string. Example "a48adfc393a0de458319236537a11d90" 117 | */ 118 | bool rk_initABP(String devADDR, String nwksKEY, String appsKEY); 119 | 120 | /* 121 | * Set the activation mode to join the network.And join the network. 122 | * mode = 0: join a network using over the air activation.. 123 | * mode = 1: join a network using personalization. 124 | * Before using this command, you must call one of the rk_initOTAA or rk_initABP functions 125 | */ 126 | bool rk_setJoinMode(int mode); 127 | 128 | /* 129 | * Join the network. 130 | * timeout: timeout value (unit:s) 131 | * Before using this command, you must call one of the rk_setJoinMode functions 132 | */ 133 | bool rk_joinLoRaNetwork(int timeout); 134 | 135 | /*STDB 136 | * Get the Channels list at current region. 137 | * This feature request to receive at least 800 bytes buffer size if work at Region US915,AU915 or CN470 138 | */ 139 | String rk_getChannelList(void); 140 | 141 | /* 142 | * After joining the network, send the packet at the specified application port. 143 | * port : The port number.(1-223) 144 | * datahex : hex value(no space). max 64 byte. 145 | * This function can only be used in module work in LoRaWAN mode. 146 | */ 147 | bool rk_sendData( int port, char* datahex); 148 | 149 | /* 150 | * LoRa data send package type. 151 | * type : 0->unconfirm, 1->confirm 152 | * This function can only be used in module work in LoRaWAN mode. 153 | */ 154 | bool rk_isConfirm(int type); 155 | 156 | /* 157 | * Returns the data or event information received by the module. 158 | * 159 | */ 160 | String rk_recvData(void); 161 | 162 | 163 | /* 164 | * Initialize the required parameters in LoRaP2P mode. 165 | * You must first switch the module operating mode to LoRaP2P mode 166 | * FREQ : frequency, default 860000000 range: (860000000 ~1020000000) 167 | * SF : spread factor, default 7 ( 6-10) more low more fast datarate 168 | * BW : Band-with, default 0 ( 0:125KHz, 1:250KHz, 2:500KHz) 169 | * CR : coding Rate, default 1 (1:4/5, 2:4/6, 3:4/7, 4:4/8) 170 | * PRlen : Preamlen, default 8 (8-65535) 171 | * PWR : Tx power, default 14 (5-20) 172 | * User can use this command to build their point to point communication or RFtest command. It will save to flash. 173 | */ 174 | bool rk_initP2P(String FREQ, int SF, int BW, int CR, int PRlen, int PWR); 175 | 176 | /* 177 | * This function is used to LoRaP2P send data 178 | * datahex : hex value ( no space) . 179 | */ 180 | bool rk_sendP2PData(char* datahex); 181 | 182 | /* 183 | * Set LoRaP2P Rx continues,module will receive packets with rfconfig until receive the rk_stopRecvP2PData command or rk_reset. 184 | */ 185 | String rk_recvP2PData(void); 186 | 187 | 188 | /*STDB 189 | * Check the device statistics. 190 | */ 191 | String rk_checkDeviceStatus(void); 192 | 193 | 194 | /*STDB 195 | * Set the module serial port parameters.Module restart effective 196 | * UartPort :UART Port number 197 | * Band : Serial baud rate.Supports baud rate: 9600 19200 38400 57600 115200 230400 460800 921600. 198 | */ 199 | bool rk_setUARTConfig(int UartPort,int Baud); 200 | 201 | /* 202 | * Send a raw command to the RAK811 module. 203 | * //Returns the raw string as received back from the RAK811. 204 | * Return true,send OK 205 | * If the RAK811 replies with multiple line, only the first line will be returned. 206 | */ 207 | bool sendRawCommand(String command); 208 | 209 | private: 210 | Stream& _serial; 211 | 212 | Stream& _serial1; 213 | 214 | String _devADDR = "00112233"; 215 | 216 | String _devEUI = "60C5A8FFFE000001"; 217 | 218 | String _appEUI = ""; 219 | 220 | String _nwksKEY = ""; 221 | 222 | String _appKEY = ""; 223 | 224 | String _appsKEY = ""; 225 | 226 | }; 227 | #endif 228 | -------------------------------------------------------------------------------- /Arduino-RAK811-Library/examples/JoinNetworkABP/JoinNetworkABP.ino: -------------------------------------------------------------------------------- 1 | /******************************************************** 2 | * This demo is only supported after RUI firmware version 3.0.0.13.X on RAK811 3 | * Master Board Uart Receive buffer size at least 128 bytes. 4 | ********************************************************/ 5 | 6 | #include "RAK811.h" 7 | #include "SoftwareSerial.h" 8 | #define WORK_MODE LoRaWAN // LoRaWAN or LoRaP2P 9 | #define JOIN_MODE ABP // OTAA or ABP 10 | #if JOIN_MODE == OTAA 11 | String DevEui = "8680000000000001"; 12 | String AppEui = "70B3D57ED00285A7"; 13 | String AppKey = "DDDFB1023885FBFF74D3A55202EDF2B1"; 14 | #else JOIN_MODE == ABP 15 | String NwkSKey = "69AF20AEA26C01B243945A28C9172B42"; 16 | 17 | String AppSKey = "841986913ACD00BBC2BE2479D70F3228"; 18 | String DevAddr = "260125D7"; 19 | #endif 20 | #define TXpin 11 // Set the virtual serial port pins 21 | #define RXpin 10 22 | #define DebugSerial Serial 23 | SoftwareSerial ATSerial(RXpin,TXpin); // Declare a virtual serial port 24 | char buffer[]= "72616B776972656C657373"; 25 | 26 | bool InitLoRaWAN(void); 27 | RAK811 RAKLoRa(ATSerial,DebugSerial); 28 | 29 | 30 | void setup() { 31 | DebugSerial.begin(115200); 32 | while(DebugSerial.available()) 33 | { 34 | DebugSerial.read(); 35 | } 36 | ATSerial.begin(9600); //set ATSerial baudrate:This baud rate has to be consistent with the baud rate of the WisNode device. 37 | while(ATSerial.available()) 38 | { 39 | ATSerial.read(); 40 | } 41 | 42 | if(!RAKLoRa.rk_setWorkingMode(0)) //set WisNode work_mode to LoRaWAN. 43 | { 44 | DebugSerial.println(F("set work_mode failed, please reset module.")); 45 | while(1); 46 | } 47 | 48 | RAKLoRa.rk_getVersion(); //get RAK811 firmware version 49 | DebugSerial.println(RAKLoRa.rk_recvData()); //print version number 50 | 51 | DebugSerial.println(F("Start init RAK811 parameters...")); 52 | 53 | if (!InitLoRaWAN()) //init LoRaWAN 54 | { 55 | DebugSerial.println(F("Init error,please reset module.")); 56 | while(1); 57 | } 58 | 59 | DebugSerial.println(F("Start to join LoRaWAN...")); 60 | while(!RAKLoRa.rk_joinLoRaNetwork(60)) //Joining LoRaNetwork timeout 60s 61 | { 62 | DebugSerial.println(); 63 | DebugSerial.println(F("Rejoin again after 5s...")); 64 | delay(5000); 65 | } 66 | DebugSerial.println(F("Join LoRaWAN success")); 67 | 68 | if(!RAKLoRa.rk_isConfirm(0)) //set LoRa data send package type:0->unconfirm, 1->confirm 69 | { 70 | DebugSerial.println(F("LoRa data send package set error,please reset module.")); 71 | while(1); 72 | } 73 | } 74 | 75 | bool InitLoRaWAN(void) 76 | { 77 | if(RAKLoRa.rk_setJoinMode(JOIN_MODE)) //set join_mode:ABP 78 | { 79 | if(RAKLoRa.rk_setRegion(5)) //set region EU868 80 | { 81 | if (RAKLoRa.rk_initABP(DevAddr, NwkSKey, AppSKey)) //set ABP mode parameters 82 | { 83 | DebugSerial.println(F("RAK811 init OK!")); 84 | return true; 85 | } 86 | } 87 | } 88 | return false; 89 | } 90 | 91 | void loop() { 92 | DebugSerial.println(F("Start send data...")); 93 | if (RAKLoRa.rk_sendData(1, buffer)) 94 | { 95 | for (unsigned long start = millis(); millis() - start < 90000L;) 96 | { 97 | String ret = RAKLoRa.rk_recvData(); 98 | if(ret != NULL) 99 | { 100 | DebugSerial.println(ret); 101 | } 102 | if((ret.indexOf("OK")>0)||(ret.indexOf("ERROR")>0)) 103 | { 104 | DebugSerial.println(F("Go to Sleep.")); 105 | RAKLoRa.rk_sleep(1); //Set RAK811 enter sleep mode 106 | delay(10000); //delay 10s 107 | RAKLoRa.rk_sleep(0); //Wakeup RAK811 from sleep mode 108 | break; 109 | } 110 | } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /Arduino-RAK811-Library/examples/JoinNetworkOTAA/JoinNetworkOTAA.ino: -------------------------------------------------------------------------------- 1 | /******************************************************** 2 | * This demo is only supported after RUI firmware version 3.0.0.13.X on RAK811 3 | * Master Board Uart Receive buffer size at least 128 bytes. 4 | ********************************************************/ 5 | 6 | #include "RAK811.h" 7 | #include "SoftwareSerial.h" 8 | #define WORK_MODE LoRaWAN // LoRaWAN or LoRaP2P 9 | #define JOIN_MODE OTAA // OTAA or ABP 10 | #if JOIN_MODE == OTAA 11 | String DevEui = "8680000000000001"; 12 | String AppEui = "70B3D57ED00285A7"; 13 | String AppKey = "DDDFB1023885FBFF74D3A55202EDF2B1"; 14 | #else JOIN_MODE == ABP 15 | String NwkSKey = "69AF20AEA26C01B243945A28C9172B42"; 16 | String AppSKey = "841986913ACD00BBC2BE2479D70F3228"; 17 | String DevAddr = "260125D7"; 18 | #endif 19 | #define TXpin 11 // Set the virtual serial port pins 20 | #define RXpin 10 21 | #define DebugSerial Serial 22 | SoftwareSerial ATSerial(RXpin,TXpin); // Declare a virtual serial port 23 | char buffer[]= "72616B776972656C657373"; 24 | 25 | bool InitLoRaWAN(void); 26 | RAK811 RAKLoRa(ATSerial,DebugSerial); 27 | 28 | 29 | void setup() { 30 | DebugSerial.begin(115200); 31 | while(DebugSerial.available()) 32 | { 33 | DebugSerial.read(); 34 | } 35 | 36 | ATSerial.begin(9600); //set ATSerial baudrate:This baud rate has to be consistent with the baud rate of the WisNode device. 37 | while(ATSerial.available()) 38 | { 39 | ATSerial.read(); 40 | } 41 | 42 | if(!RAKLoRa.rk_setWorkingMode(0)) //set WisNode work_mode to LoRaWAN. 43 | { 44 | DebugSerial.println(F("set work_mode failed, please reset module.")); 45 | while(1); 46 | } 47 | 48 | RAKLoRa.rk_getVersion(); //get RAK811 firmware version 49 | DebugSerial.println(RAKLoRa.rk_recvData()); //print version number 50 | 51 | DebugSerial.println(F("Start init RAK811 parameters...")); 52 | 53 | if (!InitLoRaWAN()) //init LoRaWAN 54 | { 55 | DebugSerial.println(F("Init error,please reset module.")); 56 | while(1); 57 | } 58 | 59 | DebugSerial.println(F("Start to join LoRaWAN...")); 60 | while(!RAKLoRa.rk_joinLoRaNetwork(60)) //Joining LoRaNetwork timeout 60s 61 | { 62 | DebugSerial.println(); 63 | DebugSerial.println(F("Rejoin again after 5s...")); 64 | delay(5000); 65 | } 66 | DebugSerial.println(F("Join LoRaWAN success")); 67 | 68 | if(!RAKLoRa.rk_isConfirm(0)) //set LoRa data send package type:0->unconfirm, 1->confirm 69 | { 70 | DebugSerial.println(F("LoRa data send package set error,please reset module.")); 71 | while(1); 72 | } 73 | } 74 | 75 | bool InitLoRaWAN(void) 76 | { 77 | if(RAKLoRa.rk_setJoinMode(JOIN_MODE)) //set join_mode:OTAA 78 | { 79 | if(RAKLoRa.rk_setRegion(5)) //set region EU868 80 | { 81 | if (RAKLoRa.rk_initOTAA(DevEui, AppEui, AppKey)) 82 | { 83 | DebugSerial.println(F("RAK811 init OK!")); 84 | return true; 85 | } 86 | } 87 | } 88 | return false; 89 | } 90 | 91 | void loop() { 92 | DebugSerial.println(F("Start send data...")); 93 | if (RAKLoRa.rk_sendData(1, buffer)) 94 | { 95 | for (unsigned long start = millis(); millis() - start < 90000L;) 96 | { 97 | String ret = RAKLoRa.rk_recvData(); 98 | if(ret != NULL) 99 | { 100 | DebugSerial.println(ret); 101 | } 102 | if((ret.indexOf("OK")>0)||(ret.indexOf("ERROR")>0)) 103 | { 104 | DebugSerial.println(F("Go to Sleep.")); 105 | RAKLoRa.rk_sleep(1); //Set RAK811 enter sleep mode 106 | delay(10000); //delay 10s 107 | RAKLoRa.rk_sleep(0); //Wakeup RAK811 from sleep mode 108 | break; 109 | } 110 | } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /Arduino-RAK811-Library/examples/LoRaP2P/LoRaP2P_Receiver/LoRaP2P_Receiver.ino: -------------------------------------------------------------------------------- 1 | /******************************************************** 2 | * This demo is only supported after RUI firmware version 3.0.0.13.X on RAK811 3 | * Master Board Uart Receive buffer size at least 128 bytes. 4 | ********************************************************/ 5 | 6 | #include "RAK811.h" 7 | #include "SoftwareSerial.h" 8 | #define WORK_MODE LoRaP2P // LoRaWAN or LoRaP2P 9 | 10 | #define TXpin 11 // Set the virtual serial port pins 11 | #define RXpin 10 12 | #define DebugSerial Serial 13 | SoftwareSerial ATSerial(RXpin,TXpin); // Declare a virtual serial port 14 | char buffer[]= "72616B776972656C657373"; 15 | 16 | RAK811 RAKLoRa(ATSerial,DebugSerial); 17 | 18 | 19 | void setup() { 20 | DebugSerial.begin(115200); 21 | while(DebugSerial.available()) 22 | { 23 | DebugSerial.read(); 24 | } 25 | 26 | ATSerial.begin(9600); //set ATSerial baudrate:This baud rate has to be consistent with the baud rate of the WisNode device. 27 | while(ATSerial.available()) 28 | { 29 | ATSerial.read(); 30 | } 31 | 32 | if(!RAKLoRa.rk_setWorkingMode(WORK_MODE)) //set WisNode work_mode to LoRaP2P. 33 | { 34 | DebugSerial.println(F("set work_mode failed, please reset module.")); 35 | while(1); 36 | } 37 | 38 | RAKLoRa.rk_getVersion(); //get RAK811 firmware version 39 | DebugSerial.println(RAKLoRa.rk_recvData()); //print version number 40 | 41 | DebugSerial.println(F("Start init LoRaP2P parameters...")); 42 | if (!RAKLoRa.rk_initP2P("869525000",12,0,1,8,20)) //init LoRaP2P 43 | { 44 | DebugSerial.println(F("Init error,please reset module.")); 45 | while(1); 46 | }else DebugSerial.println(F("Init OK")); 47 | } 48 | 49 | void loop() { 50 | String ret = RAKLoRa.rk_recvP2PData(); 51 | if(ret != NULL) 52 | { 53 | DebugSerial.println(ret); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Arduino-RAK811-Library/examples/LoRaP2P/LoRaP2P_Sender/LoRaP2P_Sender.ino: -------------------------------------------------------------------------------- 1 | /******************************************************** 2 | * This demo is only supported after RUI firmware version 3.0.0.13.X on RAK811 3 | * Master Board Uart Receive buffer size at least 128 bytes. 4 | ********************************************************/ 5 | 6 | #include "RAK811.h" 7 | #include "SoftwareSerial.h" 8 | #define WORK_MODE LoRaP2P // LoRaWAN or LoRaP2P 9 | 10 | #define TXpin 11 // Set the virtual serial port pins 11 | #define RXpin 10 12 | #define DebugSerial Serial 13 | SoftwareSerial ATSerial(RXpin,TXpin); // Declare a virtual serial port 14 | char buffer[]= "72616B776972656C657373"; 15 | 16 | RAK811 RAKLoRa(ATSerial,DebugSerial); 17 | 18 | 19 | void setup() { 20 | DebugSerial.begin(115200); 21 | while(DebugSerial.available()) 22 | { 23 | DebugSerial.read(); 24 | } 25 | 26 | ATSerial.begin(9600); //set ATSerial baudrate:This baud rate has to be consistent with the baud rate of the WisNode device. 27 | while(ATSerial.available()) 28 | { 29 | ATSerial.read(); 30 | } 31 | 32 | if(!RAKLoRa.rk_setWorkingMode(WORK_MODE)) //set WisNode work_mode to LoRaP2P. 33 | { 34 | DebugSerial.println(F("set work_mode failed, please reset module.")); 35 | while(1); 36 | } 37 | 38 | RAKLoRa.rk_getVersion(); //get RAK811 firmware version 39 | DebugSerial.println(RAKLoRa.rk_recvData()); //print version number 40 | 41 | DebugSerial.println(F("Start init LoRaP2P parameters...")); 42 | 43 | if (!RAKLoRa.rk_initP2P("869525000",12,0,1,8,20)) //init LoRaP2P 44 | { 45 | DebugSerial.println(F("Init error,please reset module.")); 46 | while(1); 47 | }else DebugSerial.println(F("Init OK")); 48 | } 49 | 50 | void loop() { 51 | DebugSerial.println(F("Start send data...")); 52 | if (RAKLoRa.rk_sendP2PData(buffer)) 53 | { 54 | String ret = RAKLoRa.rk_recvP2PData(); 55 | if(ret != NULL) 56 | { 57 | DebugSerial.println(ret); 58 | } 59 | } 60 | delay(10000); //delay 10s 61 | } 62 | -------------------------------------------------------------------------------- /Arduino-RAK811-Library/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For RAK811 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | RAK811 KEYWORD1 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | rk_recvData KEYWORD2 15 | rk_getVersion KEYWORD2 16 | rk_getLoRaStatus KEYWORD2 17 | rk_sleep KEYWORD2 18 | rk_reset KEYWORD2 19 | rk_setSendinterval KEYWORD2 20 | rk_setRate KEYWORD2 21 | rk_setClass KEYWORD2 22 | rk_setRegion KEYWORD2 23 | rk_setWorkingMode KEYWORD2 24 | isUidValid KEYWORD2 25 | rk_initOTAA KEYWORD2 26 | rk_initABP KEYWORD2 27 | rk_setJoinMode KEYWORD2 28 | rk_joinLoRaNetwork KEYWORD2 29 | rk_getChannelList KEYWORD2 30 | rk_sendData KEYWORD2 31 | rk_isConfirm KEYWORD2 32 | rk_initP2P KEYWORD2 33 | rk_sendP2PData KEYWORD2 34 | rk_recvP2PData KEYWORD2 35 | rk_checkDeviceStatus KEYWORD2 36 | rk_setUARTConfig KEYWORD2 37 | sendRawCommand KEYWORD2 38 | 39 | ####################################### 40 | # Instances (KEYWORD2) 41 | ####################################### 42 | 43 | ####################################### 44 | # Constants (LITERAL1) 45 | ####################################### 46 | LoRaWAN LITERAL1 47 | LoRaP2P LITERAL1 48 | OTAA LITERAL1 49 | ABP LITERAL1 50 | STATUS_RECV_DATA LITERAL1 51 | STATUS_TX_COMFIRMED LITERAL1 52 | STATUS_TX_UNCOMFIRMED LITERAL1 53 | STATUS_JOINED_SUCCESS LITERAL1 54 | STATUS_JOINED_FAILED LITERAL1 55 | STATUS_TX_TIMEOUT LITERAL1 56 | STATUS_RX2_TIMEOUT LITERAL1 57 | STATUS_DOWNLINK_REPEATED LITERAL1 58 | STATUS_WAKE_UP LITERAL1 59 | STATUS_P2PTX_COMPLETE LITERAL1 60 | STATUS_UNKNOWN LITERAL1 -------------------------------------------------------------------------------- /Documents and tools/RAL LoRaButton Upgrade Tool V1.0.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RAKWireless/WisNode-Arduino-Library/29b9c1c63f2e666c5706f4cec2f3e404fe664630/Documents and tools/RAL LoRaButton Upgrade Tool V1.0.exe -------------------------------------------------------------------------------- /Documents and tools/SchematIC/Arduino_Uno_Rev3-schematic.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RAKWireless/WisNode-Arduino-Library/29b9c1c63f2e666c5706f4cec2f3e404fe664630/Documents and tools/SchematIC/Arduino_Uno_Rev3-schematic.pdf -------------------------------------------------------------------------------- /Documents and tools/SchematIC/WisNode LoRaV1.1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RAKWireless/WisNode-Arduino-Library/29b9c1c63f2e666c5706f4cec2f3e404fe664630/Documents and tools/SchematIC/WisNode LoRaV1.1.pdf -------------------------------------------------------------------------------- /Documents and tools/SchematIC/WisNode LoRaV1.2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RAKWireless/WisNode-Arduino-Library/29b9c1c63f2e666c5706f4cec2f3e404fe664630/Documents and tools/SchematIC/WisNode LoRaV1.2.pdf -------------------------------------------------------------------------------- /Documents and tools/SchematIC/arduino-mega2560_R3-sch.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RAKWireless/WisNode-Arduino-Library/29b9c1c63f2e666c5706f4cec2f3e404fe664630/Documents and tools/SchematIC/arduino-mega2560_R3-sch.pdf -------------------------------------------------------------------------------- /Documents and tools/WisNodeV1.1 Arduino Library/Arduino-RAK811-Library/RAK811.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * A library for controlling RAK811 LoRa radio. 3 | * 4 | * @Author Leopold.wang 5 | * @Date 14/01/2020 6 | * 7 | */ 8 | 9 | #include "Arduino.h" 10 | #include "RAK811.h" 11 | 12 | extern "C" 13 | { 14 | #include "string.h" 15 | #include "stdlib.h" 16 | } 17 | String ret = ""; 18 | String command = ""; 19 | /* 20 | @param serial Needs to be an already opened Stream ({Software/Hardware}Serial) to write to and read from. 21 | */ 22 | RAK811::RAK811(Stream &serial, Stream &serial1) : _serial(serial), _serial1(serial1) 23 | { 24 | _serial.setTimeout(2000); 25 | _serial1.setTimeout(1000); 26 | } 27 | 28 | bool RAK811::rk_getVersion() 29 | { 30 | return sendRawCommand(F("at+version")); 31 | } 32 | 33 | String RAK811::rk_getLoRaStatus() 34 | { 35 | sendRawCommand(F("at+get_config=lora:status")); 36 | ret = rk_recvData(); 37 | ret.trim(); 38 | return ret; 39 | } 40 | 41 | String RAK811::rk_getChannelList() 42 | { 43 | sendRawCommand(F("at+get_config=lora:channel")); 44 | ret = rk_recvData(); 45 | ret.trim(); 46 | return ret; 47 | } 48 | 49 | bool RAK811::rk_setRate(int rate) 50 | { 51 | sendRawCommand("at+set_config=lora:dr:" + (String)rate); 52 | ret = rk_recvData(); 53 | if (ret.indexOf("OK") >= 0) 54 | { 55 | return true; 56 | } 57 | else 58 | { 59 | return false; 60 | } 61 | } 62 | 63 | bool RAK811::rk_setClass(int classMode) 64 | { 65 | if (classMode > 2) 66 | { 67 | _serial1.println(F("Parameter error")); 68 | return false; 69 | } 70 | command = "at+set_config=lora:class:" + (String)classMode; 71 | sendRawCommand(command); 72 | ret = rk_recvData(); 73 | #if defined DEBUG_MODE 74 | _serial1.println(ret); 75 | #endif 76 | if (ret.indexOf("OK") >= 0) 77 | { 78 | return true; 79 | } 80 | else 81 | { 82 | return false; 83 | } 84 | } 85 | 86 | bool RAK811::rk_setRegion(int region) 87 | { 88 | if (region > 9) 89 | { 90 | _serial1.println(F("Parameter error")); 91 | return false; 92 | } 93 | String REGION; 94 | switch (region) 95 | { 96 | case 0:REGION="AS923"; 97 | 98 | break; 99 | case 1:REGION="AU915"; 100 | break; 101 | case 2:REGION="CN470"; 102 | break; 103 | case 3:REGION="CN779"; 104 | break; 105 | case 4:REGION="EU433"; 106 | break; 107 | case 5:REGION="EU868"; 108 | break; 109 | case 6:REGION="KR920"; 110 | break; 111 | case 7:REGION="IN865"; 112 | break; 113 | case 8:REGION="US915"; 114 | break; 115 | case 9:REGION="US915_Hybrid"; 116 | break; 117 | } 118 | _serial1.println("Current work region: "+REGION); 119 | sendRawCommand("at+set_config=lora:region:" + REGION); 120 | ret = rk_recvData(); 121 | #if defined DEBUG_MODE 122 | _serial1.println(ret); 123 | #endif 124 | if (ret.indexOf("OK") >= 0) 125 | { 126 | return true; 127 | } 128 | else 129 | { 130 | return false; 131 | } 132 | } 133 | 134 | void RAK811::rk_sleep(int mode) 135 | { 136 | switch (mode) 137 | { 138 | case 1: 139 | sendRawCommand(F("at+set_config=device:sleep:1")); 140 | break; 141 | case 0: 142 | sendRawCommand(F("at+set_config=device:sleep:0")); 143 | break; 144 | default: 145 | _serial1.println(F("Parameter error")); 146 | break; 147 | } 148 | } 149 | 150 | bool RAK811::rk_setSendinterval(int mode, int value) 151 | { 152 | if (mode > 2) 153 | { 154 | _serial1.println("The mode set Error,the mode is '0','1' or '2'."); 155 | return false; 156 | } 157 | 158 | sendRawCommand("at+set_config=lora:send_interval:" + (String)mode + ":" + (String)value); 159 | ret = rk_recvData(); 160 | if (ret.indexOf("OK") >= 0) 161 | { 162 | return true; 163 | } 164 | else 165 | { 166 | return false; 167 | } 168 | } 169 | 170 | void RAK811::rk_reset(void) 171 | { 172 | sendRawCommand(F("at+set_config=device:restart")); 173 | } 174 | 175 | bool RAK811::rk_setWorkingMode(int mode) 176 | { 177 | switch (mode) 178 | { 179 | case 0: 180 | sendRawCommand(F("at+set_config=lora:work_mode:0")); //Set LoRaWAN Mode. 181 | break; 182 | case 1: 183 | sendRawCommand(F("at+set_config=lora:work_mode:1")); //Set LoRaP2P Mode. 184 | break; 185 | default: 186 | return false; 187 | } 188 | 189 | for(int i=0; i<10; i++) 190 | { 191 | ret = rk_recvData(); 192 | // _serial1.println(ret); 193 | if ((ret.indexOf("Initialization OK") >= 0) || (ret.indexOf("No switch work_mode") >= 0)) 194 | { 195 | return true; 196 | } 197 | } 198 | 199 | return false; 200 | 201 | } 202 | 203 | bool RAK811::rk_setJoinMode(int mode) 204 | { 205 | switch (mode) 206 | { 207 | case 0: 208 | sendRawCommand(F("at+set_config=lora:join_mode:0")); //join Network through OTAA mode. 209 | break; 210 | case 1: 211 | sendRawCommand(F("at+set_config=lora:join_mode:1")); //join Network through ABP mode. 212 | break; 213 | default: 214 | return false; 215 | } 216 | ret = rk_recvData(); 217 | if (ret.indexOf("OK") >= 0) 218 | { 219 | return true; 220 | } 221 | else 222 | { 223 | return false; 224 | } 225 | } 226 | 227 | bool RAK811::rk_joinLoRaNetwork(int timeout) 228 | { 229 | String command = "at+join"; 230 | // _serial1.println(command); 231 | sendRawCommand(command); 232 | ret = rk_recvData(); 233 | if (ret != NULL) 234 | { 235 | if (ret.indexOf("OK") >= 0) 236 | return true; 237 | else if(ret.indexOf("ERROR") >= 0) 238 | return false; 239 | } 240 | for (int i = 0; i <= timeout/2; i++) 241 | { 242 | ret = rk_recvData(); 243 | if (ret != NULL) 244 | { 245 | _serial1.print("<- " + ret); 246 | if (ret.indexOf("OK") >= 0) 247 | return true; 248 | // else if(ret.indexOf("ERROR") >= 0) 249 | // return false; 250 | } 251 | } 252 | 253 | return false; 254 | } 255 | 256 | bool RAK811::rk_initOTAA(String devEUI, String appEUI, String appKEY) 257 | { 258 | // String command = ""; 259 | if (devEUI.length() == 16) 260 | { 261 | _devEUI = devEUI; 262 | } 263 | else 264 | { 265 | _serial1.println("The parameter devEUI is set incorrectly!"); 266 | } 267 | if (appEUI.length() == 16) 268 | { 269 | _appEUI = appEUI; 270 | } 271 | else 272 | { 273 | _serial1.println("The parameter appEUI is set incorrectly!"); 274 | } 275 | if (appKEY.length() == 32) 276 | { 277 | _appKEY = appKEY; 278 | } 279 | else 280 | { 281 | _serial1.println("The parameter appKEY is set incorrectly!"); 282 | } 283 | 284 | command = "at+set_config=lora:dev_eui:" + _devEUI; 285 | // _serial1.println(command); 286 | sendRawCommand(command); 287 | ret = rk_recvData(); 288 | if (ret.indexOf("OK") >= 0) 289 | { 290 | command = "at+set_config=lora:app_eui:" + _appEUI; 291 | // _serial1.println(command); 292 | sendRawCommand(command); 293 | 294 | ret = rk_recvData(); 295 | if (ret.indexOf("OK") >= 0) 296 | { 297 | command = "at+set_config=lora:app_key:" + _appKEY; 298 | // _serial1.println(command); 299 | sendRawCommand(command); 300 | 301 | ret = rk_recvData(); 302 | if (ret.indexOf("OK") >= 0) 303 | { 304 | return true; 305 | } 306 | } 307 | } 308 | 309 | return false; 310 | } 311 | 312 | bool RAK811::rk_initABP(String devADDR, String nwksKEY, String appsKEY) 313 | { 314 | // String command = ""; 315 | if (devADDR.length() == 8) 316 | { 317 | _devADDR = devADDR; 318 | } 319 | else 320 | { 321 | _serial1.println(F("The parameter devADDR is set incorrectly!")); 322 | } 323 | if (nwksKEY.length() == 32) 324 | { 325 | _nwksKEY = nwksKEY; 326 | } 327 | else 328 | { 329 | _serial1.println(F("The parameter nwksKEY is set incorrectly!")); 330 | } 331 | if (appsKEY.length() == 32) 332 | { 333 | _appsKEY = appsKEY; 334 | } 335 | else 336 | { 337 | _serial1.println(F("The parameter appsKEY is set incorrectly!")); 338 | } 339 | command = "at+set_config=lora:dev_addr:" + _devADDR; 340 | sendRawCommand(command); 341 | ret = rk_recvData(); 342 | // _serial1.println(ret); 343 | if (ret.indexOf("OK") >= 0) 344 | { 345 | command = "at+set_config=lora:nwks_key:" + _nwksKEY; 346 | sendRawCommand(command); 347 | ret = rk_recvData(); 348 | if (ret.indexOf("OK") >= 0) 349 | { 350 | command = "at+set_config=lora:apps_key:" + _appsKEY; 351 | sendRawCommand(command); 352 | ret = rk_recvData(); 353 | if (ret.indexOf("OK") >= 0) 354 | { 355 | return true; 356 | } 357 | } 358 | } 359 | return false; 360 | } 361 | 362 | bool RAK811::rk_isConfirm(int type) 363 | { 364 | switch (type) 365 | { 366 | case 0: 367 | sendRawCommand(F("at+set_config=lora:confirm:0")); //LoRa data send with unconfirm. 368 | break; 369 | case 1: 370 | sendRawCommand(F("at+set_config=lora:confirm:1")); //LoRa data send with confirm. 371 | break; 372 | default: 373 | return false; 374 | } 375 | ret = rk_recvData(); 376 | if (ret.indexOf("OK") >= 0) 377 | { 378 | return true; 379 | } 380 | else 381 | { 382 | return false; 383 | } 384 | } 385 | 386 | bool RAK811::rk_sendData(int port, char *datahex) 387 | { 388 | // String command = ""; 389 | command = "at+send=lora:" + (String)port + ":" + datahex; 390 | // _serial1.println(command); 391 | sendRawCommand(command); 392 | 393 | return true; 394 | } 395 | 396 | String RAK811::rk_recvData(void) 397 | { 398 | _serial.setTimeout(2000); 399 | ret = _serial.readStringUntil('\0'); 400 | // ret.trim(); 401 | // _serial1.println(ret); 402 | return ret; 403 | } 404 | 405 | bool RAK811::rk_initP2P(String FREQ, int SF, int BW, int CR, int PRlen, int PWR) 406 | { 407 | // String command = ""; 408 | command = "at+set_config=lorap2p:" + FREQ + "," + SF + "," + BW + "," + CR + "," + PRlen + "," + PWR; 409 | // _serial1.println(command); 410 | sendRawCommand(command); 411 | ret = rk_recvP2PData(); 412 | if (ret.indexOf("OK") >= 0) 413 | { 414 | return true; 415 | } 416 | else 417 | { 418 | return false; 419 | } 420 | } 421 | 422 | String RAK811::rk_recvP2PData(void) 423 | { 424 | ret = _serial.readStringUntil('\0'); 425 | ret.trim(); 426 | // delay(500); 427 | return ret; 428 | } 429 | 430 | bool RAK811::rk_sendP2PData(char *datahex) 431 | { 432 | String DATAHEX = datahex; 433 | String command = "at+send=lorap2p:" + DATAHEX; 434 | // _serial1.println(command); 435 | sendRawCommand(command); 436 | // ret = rk_recvP2PData(); 437 | // if (ret.indexOf("OK") > 0) 438 | // { 439 | // return true; 440 | // } 441 | // else 442 | // { 443 | // return false; 444 | // } 445 | return true; 446 | } 447 | 448 | String RAK811::rk_checkDeviceStatus(void) 449 | { 450 | sendRawCommand(F("at+get_config=device:status")); 451 | ret = rk_recvP2PData(); 452 | return ret; 453 | } 454 | 455 | bool RAK811::rk_setUARTConfig(int UartPort, int Baud) 456 | { 457 | // String command = ""; 458 | command = "at+set_config=device:uart:" + (String)UartPort + ":" + (String)Baud; 459 | // _serial1.println(command); 460 | sendRawCommand(command); 461 | 462 | return true; 463 | } 464 | 465 | bool RAK811::sendRawCommand(String cmd) 466 | { 467 | while (_serial.available()) 468 | { 469 | _serial.read(); 470 | } 471 | //_serial1.println(cmd); 472 | _serial.println(cmd); 473 | delay(200); 474 | return true; 475 | } 476 | -------------------------------------------------------------------------------- /Documents and tools/WisNodeV1.1 Arduino Library/Arduino-RAK811-Library/RAK811.h: -------------------------------------------------------------------------------- 1 | /* 2 | * A library for controlling RAK811 LoRa radio. 3 | * 4 | * @Author Leopold.wang 5 | * @Date 14/01/2020 6 | * 7 | */ 8 | 9 | 10 | #ifndef RAK811_h 11 | #define RAK811_h 12 | #define LoRaWAN 0 13 | #define LoRaP2P 1 14 | #define OTAA 0 15 | #define ABP 1 16 | 17 | #include "Arduino.h" 18 | 19 | // #define DEBUG_MODE 20 | 21 | class RAK811 22 | { 23 | public: 24 | 25 | /* 26 | * A simplified constructor taking only a Stream ({Software/Hardware}Serial) object. 27 | * The serial port should already be initialised when initialising this library. 28 | */ 29 | RAK811(Stream& serial,Stream& serial1); 30 | 31 | /* 32 | * Gets the firmware version number of the module. 33 | * Only applies to the firmware that the module programmed for the RAK811 AT command. 34 | * AT commands refer to: https://downloads.rakwireless.com/en/LoRa/RAK811/Application_Notes/Get_Start_with_RAK811_WisNode-LoRa.pdf 35 | */ 36 | bool rk_getVersion(void); 37 | 38 | /*STDB 39 | * Get the frequency band of the module. 40 | * This feature request to receive at least 800 bytes buffer size. 41 | */ 42 | String rk_getLoRaStatus(void); 43 | 44 | /* 45 | * Let the module enter the ultra low power sleep mode. 46 | * When the module is in sleep mode, the host can send any character to wake it up. 47 | * mode :0->wakeup, 1-> sleep 48 | * When the module is awakened, the event response will automatically return through the serial information. 49 | */ 50 | void rk_sleep(int mode); 51 | 52 | /* 53 | * Reset the module. 54 | */ 55 | void rk_reset(void); 56 | 57 | /* 58 | * This command is used to set the interval time of sending data. 59 | * This feature can't use on RAK811,manually close the feature before user APP. 60 | */ 61 | bool rk_setSendinterval(int mode,int value ); 62 | 63 | /* 64 | * Use to change the next send data rate temporary when adr function is off. 65 | * It will not be save to internal flash. 66 | * rate : If your Band is EU868 from 0 to 7. 67 | * If your Band is US915 from 0 to 4. 68 | */ 69 | bool rk_setRate(int rate); 70 | 71 | /* 72 | * Use to change the LoRaWAN class. 73 | * classMode->ClassA, 74 | * 1->ClassB, 75 | * 2->ClassC 76 | * It will be save to internal flash. 77 | */ 78 | bool rk_setClass(int classMode); 79 | 80 | /* 81 | * Use to change the LoRaWAN region. 82 | * region:0->AS923, 83 | * 1->AU915, 84 | * 2->CN470, 85 | * 3->CN779, 86 | * 4->EU433, 87 | * 5->EU868, 88 | * 6->KR920, 89 | * 7->IN865, 90 | * 8->US915, 91 | * 9->US915_Hybrid, 92 | * It will be save to internal flash. 93 | */ 94 | bool rk_setRegion(int region); 95 | 96 | /* 97 | * Set the module work mode, the module defaults to LoRaWAN mode.. 98 | * mode = 0: Set the module to LoRaWAN mode. 99 | * mode = 1: Set the module to LoRaP2P mode. 100 | * This command could cause modual reset,so this function must only be executed once 101 | */ 102 | bool rk_setWorkingMode(int mode); 103 | 104 | /* 105 | * Initialize the module parameter, which is the parameter that the module must use when adding the OTAA to the network. 106 | * devEUI : Device EUI as a HEX string. Example "60C5A8FFFE000001" 107 | * appEUI : Application EUI as a HEX string. Example "70B3D57EF00047C0" 108 | * appKEY : Application key as a HEX string. Example "5D833B4696D5E01E2F8DC880E30BA5FE" 109 | */ 110 | bool rk_initOTAA(String devEUI, String appEUI, String appKEY); 111 | 112 | /* 113 | * Initialize the module parameter, which is the parameter that the module must use when adding the ABP to the network. 114 | * devADDR : The device address as a HEX string. Example "00112233" 115 | * nwksKEY : Network Session Key as a HEX string. Example "3432567afde4525e7890cfea234a5821" 116 | * appsKEY : Application Session Key as a HEX string. Example "a48adfc393a0de458319236537a11d90" 117 | */ 118 | bool rk_initABP(String devADDR, String nwksKEY, String appsKEY); 119 | 120 | /* 121 | * Set the activation mode to join the network.And join the network. 122 | * mode = 0: join a network using over the air activation.. 123 | * mode = 1: join a network using personalization. 124 | * Before using this command, you must call one of the rk_initOTAA or rk_initABP functions 125 | */ 126 | bool rk_setJoinMode(int mode); 127 | 128 | /* 129 | * Join the network. 130 | * timeout: timeout value (unit:s) 131 | * Before using this command, you must call one of the rk_setJoinMode functions 132 | */ 133 | bool rk_joinLoRaNetwork(int timeout); 134 | 135 | /*STDB 136 | * Get the Channels list at current region. 137 | * This feature request to receive at least 800 bytes buffer size if work at Region US915,AU915 or CN470 138 | */ 139 | String rk_getChannelList(void); 140 | 141 | /* 142 | * After joining the network, send the packet at the specified application port. 143 | * port : The port number.(1-223) 144 | * datahex : hex value(no space). max 64 byte. 145 | * This function can only be used in module work in LoRaWAN mode. 146 | */ 147 | bool rk_sendData( int port, char* datahex); 148 | 149 | /* 150 | * LoRa data send package type. 151 | * type : 0->unconfirm, 1->confirm 152 | * This function can only be used in module work in LoRaWAN mode. 153 | */ 154 | bool rk_isConfirm(int type); 155 | 156 | /* 157 | * Returns the data or event information received by the module. 158 | * 159 | */ 160 | String rk_recvData(void); 161 | 162 | 163 | /* 164 | * Initialize the required parameters in LoRaP2P mode. 165 | * You must first switch the module operating mode to LoRaP2P mode 166 | * FREQ : frequency, default 860000000 range: (860000000 ~1020000000) 167 | * SF : spread factor, default 7 ( 6-10) more low more fast datarate 168 | * BW : Band-with, default 0 ( 0:125KHz, 1:250KHz, 2:500KHz) 169 | * CR : coding Rate, default 1 (1:4/5, 2:4/6, 3:4/7, 4:4/8) 170 | * PRlen : Preamlen, default 8 (8-65535) 171 | * PWR : Tx power, default 14 (5-20) 172 | * User can use this command to build their point to point communication or RFtest command. It will save to flash. 173 | */ 174 | bool rk_initP2P(String FREQ, int SF, int BW, int CR, int PRlen, int PWR); 175 | 176 | /* 177 | * This function is used to LoRaP2P send data 178 | * datahex : hex value ( no space) . 179 | */ 180 | bool rk_sendP2PData(char* datahex); 181 | 182 | /* 183 | * Set LoRaP2P Rx continues,module will receive packets with rfconfig until receive the rk_stopRecvP2PData command or rk_reset. 184 | */ 185 | String rk_recvP2PData(void); 186 | 187 | 188 | /*STDB 189 | * Check the device statistics. 190 | */ 191 | String rk_checkDeviceStatus(void); 192 | 193 | 194 | /*STDB 195 | * Set the module serial port parameters.Module restart effective 196 | * UartPort :UART Port number 197 | * Band : Serial baud rate.Supports baud rate: 9600 19200 38400 57600 115200 230400 460800 921600. 198 | */ 199 | bool rk_setUARTConfig(int UartPort,int Baud); 200 | 201 | /* 202 | * Send a raw command to the RAK811 module. 203 | * //Returns the raw string as received back from the RAK811. 204 | * Return true,send OK 205 | * If the RAK811 replies with multiple line, only the first line will be returned. 206 | */ 207 | bool sendRawCommand(String command); 208 | 209 | private: 210 | Stream& _serial; 211 | 212 | Stream& _serial1; 213 | 214 | String _devADDR = "00112233"; 215 | 216 | String _devEUI = "60C5A8FFFE000001"; 217 | 218 | String _appEUI = ""; 219 | 220 | String _nwksKEY = ""; 221 | 222 | String _appKEY = ""; 223 | 224 | String _appsKEY = ""; 225 | 226 | }; 227 | #endif 228 | -------------------------------------------------------------------------------- /Documents and tools/WisNodeV1.1 Arduino Library/Arduino-RAK811-Library/examples/JoinNetworkABP/JoinNetworkABP.ino: -------------------------------------------------------------------------------- 1 | /******************************************************** 2 | * This demo is only supported after RUI firmware version 3.0.0.13.X on RAK811 3 | * Master Board Uart Receive buffer size at least 128 bytes. 4 | ********************************************************/ 5 | 6 | #include "RAK811.h" 7 | #include "SoftwareSerial.h" 8 | #define WORK_MODE LoRaWAN // LoRaWAN or LoRaP2P 9 | #define JOIN_MODE ABP // OTAA or ABP 10 | #if JOIN_MODE == OTAA 11 | String DevEui = "8680000000000001"; 12 | String AppEui = "70B3D57ED00285A7"; 13 | String AppKey = "DDDFB1023885FBFF74D3A55202EDF2B1"; 14 | #else JOIN_MODE == ABP 15 | String NwkSKey = "69AF20AEA26C01B243945A28C9172B42"; 16 | 17 | String AppSKey = "841986913ACD00BBC2BE2479D70F3228"; 18 | String DevAddr = "260125D7"; 19 | #endif 20 | #define TXpin 11 // Set the virtual serial port pins 21 | #define RXpin 10 22 | #define ATSerial Serial 23 | SoftwareSerial DebugSerial(RXpin,TXpin); // Declare a virtual serial port 24 | char buffer[]= "72616B776972656C657373"; 25 | 26 | bool InitLoRaWAN(void); 27 | RAK811 RAKLoRa(ATSerial,DebugSerial); 28 | 29 | 30 | void setup() { 31 | DebugSerial.begin(115200); 32 | while(DebugSerial.available()) 33 | { 34 | DebugSerial.read(); 35 | } 36 | ATSerial.begin(9600); //set ATSerial baudrate:This baud rate has to be consistent with the baud rate of the WisNode device. 37 | while(ATSerial.available()) 38 | { 39 | ATSerial.read(); 40 | } 41 | 42 | if(!RAKLoRa.rk_setWorkingMode(0)) //set WisNode work_mode to LoRaWAN. 43 | { 44 | DebugSerial.println(F("set work_mode failed, please reset module.")); 45 | while(1); 46 | } 47 | 48 | RAKLoRa.rk_getVersion(); //get RAK811 firmware version 49 | DebugSerial.println(RAKLoRa.rk_recvData()); //print version number 50 | 51 | DebugSerial.println(F("Start init RAK811 parameters...")); 52 | 53 | if (!InitLoRaWAN()) //init LoRaWAN 54 | { 55 | DebugSerial.println(F("Init error,please reset module.")); 56 | while(1); 57 | } 58 | 59 | DebugSerial.println(F("Start to join LoRaWAN...")); 60 | while(!RAKLoRa.rk_joinLoRaNetwork(60)) //Joining LoRaNetwork timeout 60s 61 | { 62 | DebugSerial.println(); 63 | DebugSerial.println(F("Rejoin again after 5s...")); 64 | delay(5000); 65 | } 66 | DebugSerial.println(F("Join LoRaWAN success")); 67 | 68 | if(!RAKLoRa.rk_isConfirm(0)) //set LoRa data send package type:0->unconfirm, 1->confirm 69 | { 70 | DebugSerial.println(F("LoRa data send package set error,please reset module.")); 71 | while(1); 72 | } 73 | } 74 | 75 | bool InitLoRaWAN(void) 76 | { 77 | if(RAKLoRa.rk_setJoinMode(JOIN_MODE)) //set join_mode:ABP 78 | { 79 | if(RAKLoRa.rk_setRegion(5)) //set region EU868 80 | { 81 | if (RAKLoRa.rk_initABP(DevAddr, NwkSKey, AppSKey)) //set ABP mode parameters 82 | { 83 | DebugSerial.println(F("RAK811 init OK!")); 84 | return true; 85 | } 86 | } 87 | } 88 | return false; 89 | } 90 | 91 | void loop() { 92 | DebugSerial.println(F("Start send data...")); 93 | if (RAKLoRa.rk_sendData(1, buffer)) 94 | { 95 | for (unsigned long start = millis(); millis() - start < 90000L;) 96 | { 97 | String ret = RAKLoRa.rk_recvData(); 98 | if(ret != NULL) 99 | { 100 | DebugSerial.println(ret); 101 | } 102 | if((ret.indexOf("OK")>0)||(ret.indexOf("ERROR")>0)) 103 | { 104 | DebugSerial.println(F("Go to Sleep.")); 105 | RAKLoRa.rk_sleep(1); //Set RAK811 enter sleep mode 106 | delay(10000); //delay 10s 107 | RAKLoRa.rk_sleep(0); //Wakeup RAK811 from sleep mode 108 | break; 109 | } 110 | } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /Documents and tools/WisNodeV1.1 Arduino Library/Arduino-RAK811-Library/examples/JoinNetworkOTAA/JoinNetworkOTAA.ino: -------------------------------------------------------------------------------- 1 | /******************************************************** 2 | * This demo is only supported after RUI firmware version 3.0.0.13.X on RAK811 3 | * Master Board Uart Receive buffer size at least 128 bytes. 4 | ********************************************************/ 5 | 6 | #include "RAK811.h" 7 | #include "SoftwareSerial.h" 8 | #define WORK_MODE LoRaWAN // LoRaWAN or LoRaP2P 9 | #define JOIN_MODE OTAA // OTAA or ABP 10 | #if JOIN_MODE == OTAA 11 | String DevEui = "8680000000000001"; 12 | String AppEui = "70B3D57ED00285A7"; 13 | String AppKey = "DDDFB1023885FBFF74D3A55202EDF2B1"; 14 | #else JOIN_MODE == ABP 15 | String NwkSKey = "69AF20AEA26C01B243945A28C9172B42"; 16 | String AppSKey = "841986913ACD00BBC2BE2479D70F3228"; 17 | String DevAddr = "260125D7"; 18 | #endif 19 | #define TXpin 11 // Set the virtual serial port pins 20 | #define RXpin 10 21 | #define ATSerial Serial 22 | SoftwareSerial DebugSerial(RXpin,TXpin); // Declare a virtual serial port 23 | char buffer[]= "72616B776972656C657373"; 24 | 25 | bool InitLoRaWAN(void); 26 | RAK811 RAKLoRa(ATSerial,DebugSerial); 27 | 28 | 29 | void setup() { 30 | DebugSerial.begin(115200); 31 | while(DebugSerial.available()) 32 | { 33 | DebugSerial.read(); 34 | } 35 | 36 | ATSerial.begin(9600); //set ATSerial baudrate:This baud rate has to be consistent with the baud rate of the WisNode device. 37 | while(ATSerial.available()) 38 | { 39 | ATSerial.read(); 40 | } 41 | 42 | if(!RAKLoRa.rk_setWorkingMode(0)) //set WisNode work_mode to LoRaWAN. 43 | { 44 | DebugSerial.println(F("set work_mode failed, please reset module.")); 45 | while(1); 46 | } 47 | 48 | RAKLoRa.rk_getVersion(); //get RAK811 firmware version 49 | DebugSerial.println(RAKLoRa.rk_recvData()); //print version number 50 | 51 | DebugSerial.println(F("Start init RAK811 parameters...")); 52 | 53 | if (!InitLoRaWAN()) //init LoRaWAN 54 | { 55 | DebugSerial.println(F("Init error,please reset module.")); 56 | while(1); 57 | } 58 | 59 | DebugSerial.println(F("Start to join LoRaWAN...")); 60 | while(!RAKLoRa.rk_joinLoRaNetwork(60)) //Joining LoRaNetwork timeout 60s 61 | { 62 | DebugSerial.println(); 63 | DebugSerial.println(F("Rejoin again after 5s...")); 64 | delay(5000); 65 | } 66 | DebugSerial.println(F("Join LoRaWAN success")); 67 | 68 | if(!RAKLoRa.rk_isConfirm(0)) //set LoRa data send package type:0->unconfirm, 1->confirm 69 | { 70 | DebugSerial.println(F("LoRa data send package set error,please reset module.")); 71 | while(1); 72 | } 73 | } 74 | 75 | bool InitLoRaWAN(void) 76 | { 77 | if(RAKLoRa.rk_setJoinMode(JOIN_MODE)) //set join_mode:OTAA 78 | { 79 | if(RAKLoRa.rk_setRegion(5)) //set region EU868 80 | { 81 | if (RAKLoRa.rk_initOTAA(DevEui, AppEui, AppKey)) 82 | { 83 | DebugSerial.println(F("RAK811 init OK!")); 84 | return true; 85 | } 86 | } 87 | } 88 | return false; 89 | } 90 | 91 | void loop() { 92 | DebugSerial.println(F("Start send data...")); 93 | if (RAKLoRa.rk_sendData(1, buffer)) 94 | { 95 | for (unsigned long start = millis(); millis() - start < 90000L;) 96 | { 97 | String ret = RAKLoRa.rk_recvData(); 98 | if(ret != NULL) 99 | { 100 | DebugSerial.println(ret); 101 | } 102 | if((ret.indexOf("OK")>0)||(ret.indexOf("ERROR")>0)) 103 | { 104 | DebugSerial.println(F("Go to Sleep.")); 105 | RAKLoRa.rk_sleep(1); //Set RAK811 enter sleep mode 106 | delay(10000); //delay 10s 107 | RAKLoRa.rk_sleep(0); //Wakeup RAK811 from sleep mode 108 | break; 109 | } 110 | } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /Documents and tools/WisNodeV1.1 Arduino Library/Arduino-RAK811-Library/examples/LoRaP2P/LoRaP2P_Receiver/LoRaP2P_Receiver.ino: -------------------------------------------------------------------------------- 1 | /******************************************************** 2 | * This demo is only supported after RUI firmware version 3.0.0.13.X on RAK811 3 | * Master Board Uart Receive buffer size at least 128 bytes. 4 | ********************************************************/ 5 | 6 | #include "RAK811.h" 7 | #include "SoftwareSerial.h" 8 | #define WORK_MODE LoRaP2P // LoRaWAN or LoRaP2P 9 | 10 | #define TXpin 11 // Set the virtual serial port pins 11 | #define RXpin 10 12 | #define ATSerial Serial 13 | SoftwareSerial DebugSerial(RXpin,TXpin); // Declare a virtual serial port 14 | char buffer[]= "72616B776972656C657373"; 15 | 16 | RAK811 RAKLoRa(ATSerial,DebugSerial); 17 | 18 | 19 | void setup() { 20 | DebugSerial.begin(115200); 21 | while(DebugSerial.available()) 22 | { 23 | DebugSerial.read(); 24 | } 25 | 26 | ATSerial.begin(9600); //set ATSerial baudrate:This baud rate has to be consistent with the baud rate of the WisNode device. 27 | while(ATSerial.available()) 28 | { 29 | ATSerial.read(); 30 | } 31 | 32 | if(!RAKLoRa.rk_setWorkingMode(WORK_MODE)) //set WisNode work_mode to LoRaP2P. 33 | { 34 | DebugSerial.println(F("set work_mode failed, please reset module.")); 35 | while(1); 36 | } 37 | 38 | RAKLoRa.rk_getVersion(); //get RAK811 firmware version 39 | DebugSerial.println(RAKLoRa.rk_recvData()); //print version number 40 | 41 | DebugSerial.println(F("Start init LoRaP2P parameters...")); 42 | if (!RAKLoRa.rk_initP2P("869525000",12,0,1,8,20)) //init LoRaP2P 43 | { 44 | DebugSerial.println(F("Init error,please reset module.")); 45 | while(1); 46 | }else DebugSerial.println(F("Init OK")); 47 | } 48 | 49 | void loop() { 50 | String ret = RAKLoRa.rk_recvP2PData(); 51 | if(ret != NULL) 52 | { 53 | DebugSerial.println(ret); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Documents and tools/WisNodeV1.1 Arduino Library/Arduino-RAK811-Library/examples/LoRaP2P/LoRaP2P_Sender/LoRaP2P_Sender.ino: -------------------------------------------------------------------------------- 1 | /******************************************************** 2 | * This demo is only supported after RUI firmware version 3.0.0.13.X on RAK811 3 | * Master Board Uart Receive buffer size at least 128 bytes. 4 | ********************************************************/ 5 | 6 | #include "RAK811.h" 7 | #include "SoftwareSerial.h" 8 | #define WORK_MODE LoRaP2P // LoRaWAN or LoRaP2P 9 | 10 | #define TXpin 11 // Set the virtual serial port pins 11 | #define RXpin 10 12 | #define ATSerial Serial 13 | SoftwareSerial DebugSerial(RXpin,TXpin); // Declare a virtual serial port 14 | char buffer[]= "72616B776972656C657373"; 15 | 16 | RAK811 RAKLoRa(ATSerial,DebugSerial); 17 | 18 | 19 | void setup() { 20 | DebugSerial.begin(115200); 21 | while(DebugSerial.available()) 22 | { 23 | DebugSerial.read(); 24 | } 25 | 26 | ATSerial.begin(9600); //set ATSerial baudrate:This baud rate has to be consistent with the baud rate of the WisNode device. 27 | while(ATSerial.available()) 28 | { 29 | ATSerial.read(); 30 | } 31 | 32 | if(!RAKLoRa.rk_setWorkingMode(WORK_MODE)) //set WisNode work_mode to LoRaP2P. 33 | { 34 | DebugSerial.println(F("set work_mode failed, please reset module.")); 35 | while(1); 36 | } 37 | 38 | RAKLoRa.rk_getVersion(); //get RAK811 firmware version 39 | DebugSerial.println(RAKLoRa.rk_recvData()); //print version number 40 | 41 | DebugSerial.println(F("Start init LoRaP2P parameters...")); 42 | 43 | if (!RAKLoRa.rk_initP2P("869525000",12,0,1,8,20)) //init LoRaP2P 44 | { 45 | DebugSerial.println(F("Init error,please reset module.")); 46 | while(1); 47 | }else DebugSerial.println(F("Init OK")); 48 | } 49 | 50 | void loop() { 51 | DebugSerial.println(F("Start send data...")); 52 | if (RAKLoRa.rk_sendP2PData(buffer)) 53 | { 54 | String ret = RAKLoRa.rk_recvP2PData(); 55 | if(ret != NULL) 56 | { 57 | DebugSerial.println(ret); 58 | } 59 | } 60 | delay(10000); //delay 10s 61 | } 62 | -------------------------------------------------------------------------------- /Documents and tools/WisNodeV1.1 Arduino Library/Arduino-RAK811-Library/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For RAK811 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | RAK811 KEYWORD1 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | rk_recvData KEYWORD2 15 | rk_getVersion KEYWORD2 16 | rk_getLoRaStatus KEYWORD2 17 | rk_sleep KEYWORD2 18 | rk_reset KEYWORD2 19 | rk_setSendinterval KEYWORD2 20 | rk_setRate KEYWORD2 21 | rk_setClass KEYWORD2 22 | rk_setRegion KEYWORD2 23 | rk_setWorkingMode KEYWORD2 24 | isUidValid KEYWORD2 25 | rk_initOTAA KEYWORD2 26 | rk_initABP KEYWORD2 27 | rk_setJoinMode KEYWORD2 28 | rk_joinLoRaNetwork KEYWORD2 29 | rk_getChannelList KEYWORD2 30 | rk_sendData KEYWORD2 31 | rk_isConfirm KEYWORD2 32 | rk_initP2P KEYWORD2 33 | rk_sendP2PData KEYWORD2 34 | rk_recvP2PData KEYWORD2 35 | rk_checkDeviceStatus KEYWORD2 36 | rk_setUARTConfig KEYWORD2 37 | sendRawCommand KEYWORD2 38 | 39 | ####################################### 40 | # Instances (KEYWORD2) 41 | ####################################### 42 | 43 | ####################################### 44 | # Constants (LITERAL1) 45 | ####################################### 46 | LoRaWAN LITERAL1 47 | LoRaP2P LITERAL1 48 | OTAA LITERAL1 49 | ABP LITERAL1 50 | STATUS_RECV_DATA LITERAL1 51 | STATUS_TX_COMFIRMED LITERAL1 52 | STATUS_TX_UNCOMFIRMED LITERAL1 53 | STATUS_JOINED_SUCCESS LITERAL1 54 | STATUS_JOINED_FAILED LITERAL1 55 | STATUS_TX_TIMEOUT LITERAL1 56 | STATUS_RX2_TIMEOUT LITERAL1 57 | STATUS_DOWNLINK_REPEATED LITERAL1 58 | STATUS_WAKE_UP LITERAL1 59 | STATUS_P2PTX_COMPLETE LITERAL1 60 | STATUS_UNKNOWN LITERAL1 -------------------------------------------------------------------------------- /Documents and tools/WisNodeV1.1 Arduino Library/RAK811 WisNode V1.1 Hardware.md: -------------------------------------------------------------------------------- 1 | ## RAK811 WisNode V1.1 2 | 3 | ### Hardware Configuration 4 | 5 | After completing the above steps, connect RAK WisNode to Arduino Uno, and connect RAK WisNode to the jumper as shown in the figure below. 6 | 7 |
8 | 9 |
10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | ### Test LoRa Node with LoRaWAN 18 | 19 | Server and serial console log: 20 | 21 |
22 | 23 |
24 | 25 | If the log does not display properly, it can be resolved by restarting the board. -------------------------------------------------------------------------------- /Documents and tools/WisNodeV1.2 Arduino Library/Arduino-RAK811-Library/RAK811.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * A library for controlling RAK811 LoRa radio. 3 | * 4 | * @Author Leopold.wang 5 | * @Date 14/01/2020 6 | * 7 | */ 8 | 9 | #include "Arduino.h" 10 | #include "RAK811.h" 11 | 12 | extern "C" 13 | { 14 | #include "string.h" 15 | #include "stdlib.h" 16 | } 17 | String ret = ""; 18 | String command = ""; 19 | /* 20 | @param serial Needs to be an already opened Stream ({Software/Hardware}Serial) to write to and read from. 21 | */ 22 | RAK811::RAK811(Stream &serial, Stream &serial1) : _serial(serial), _serial1(serial1) 23 | { 24 | _serial.setTimeout(2000); 25 | _serial1.setTimeout(1000); 26 | } 27 | 28 | bool RAK811::rk_getVersion() 29 | { 30 | return sendRawCommand(F("at+version")); 31 | } 32 | 33 | String RAK811::rk_getLoRaStatus() 34 | { 35 | sendRawCommand(F("at+get_config=lora:status")); 36 | ret = rk_recvData(); 37 | ret.trim(); 38 | return ret; 39 | } 40 | 41 | String RAK811::rk_getChannelList() 42 | { 43 | sendRawCommand(F("at+get_config=lora:channel")); 44 | ret = rk_recvData(); 45 | ret.trim(); 46 | return ret; 47 | } 48 | 49 | bool RAK811::rk_setRate(int rate) 50 | { 51 | sendRawCommand("at+set_config=lora:dr:" + (String)rate); 52 | ret = rk_recvData(); 53 | if (ret.indexOf("OK") >= 0) 54 | { 55 | return true; 56 | } 57 | else 58 | { 59 | return false; 60 | } 61 | } 62 | 63 | bool RAK811::rk_setClass(int classMode) 64 | { 65 | if (classMode > 2) 66 | { 67 | _serial1.println(F("Parameter error")); 68 | return false; 69 | } 70 | command = "at+set_config=lora:class:" + (String)classMode; 71 | sendRawCommand(command); 72 | ret = rk_recvData(); 73 | #if defined DEBUG_MODE 74 | _serial1.println(ret); 75 | #endif 76 | if (ret.indexOf("OK") >= 0) 77 | { 78 | return true; 79 | } 80 | else 81 | { 82 | return false; 83 | } 84 | } 85 | 86 | bool RAK811::rk_setRegion(int region) 87 | { 88 | if (region > 9) 89 | { 90 | _serial1.println(F("Parameter error")); 91 | return false; 92 | } 93 | String REGION; 94 | switch (region) 95 | { 96 | case 0:REGION="AS923"; 97 | 98 | break; 99 | case 1:REGION="AU915"; 100 | break; 101 | case 2:REGION="CN470"; 102 | break; 103 | case 3:REGION="CN779"; 104 | break; 105 | case 4:REGION="EU433"; 106 | break; 107 | case 5:REGION="EU868"; 108 | break; 109 | case 6:REGION="KR920"; 110 | break; 111 | case 7:REGION="IN865"; 112 | break; 113 | case 8:REGION="US915"; 114 | break; 115 | case 9:REGION="US915_Hybrid"; 116 | break; 117 | } 118 | _serial1.println("Current work region: "+REGION); 119 | sendRawCommand("at+set_config=lora:region:" + REGION); 120 | ret = rk_recvData(); 121 | #if defined DEBUG_MODE 122 | _serial1.println(ret); 123 | #endif 124 | if (ret.indexOf("OK") >= 0) 125 | { 126 | return true; 127 | } 128 | else 129 | { 130 | return false; 131 | } 132 | } 133 | 134 | void RAK811::rk_sleep(int mode) 135 | { 136 | switch (mode) 137 | { 138 | case 1: 139 | sendRawCommand(F("at+set_config=device:sleep:1")); 140 | break; 141 | case 0: 142 | sendRawCommand(F("at+set_config=device:sleep:0")); 143 | break; 144 | default: 145 | _serial1.println(F("Parameter error")); 146 | break; 147 | } 148 | } 149 | 150 | bool RAK811::rk_setSendinterval(int mode, int value) 151 | { 152 | if (mode > 2) 153 | { 154 | _serial1.println("The mode set Error,the mode is '0','1' or '2'."); 155 | return false; 156 | } 157 | 158 | sendRawCommand("at+set_config=lora:send_interval:" + (String)mode + ":" + (String)value); 159 | ret = rk_recvData(); 160 | if (ret.indexOf("OK") >= 0) 161 | { 162 | return true; 163 | } 164 | else 165 | { 166 | return false; 167 | } 168 | } 169 | 170 | void RAK811::rk_reset(void) 171 | { 172 | sendRawCommand(F("at+set_config=device:restart")); 173 | } 174 | 175 | bool RAK811::rk_setWorkingMode(int mode) 176 | { 177 | switch (mode) 178 | { 179 | case 0: 180 | sendRawCommand(F("at+set_config=lora:work_mode:0")); //Set LoRaWAN Mode. 181 | break; 182 | case 1: 183 | sendRawCommand(F("at+set_config=lora:work_mode:1")); //Set LoRaP2P Mode. 184 | break; 185 | default: 186 | return false; 187 | } 188 | 189 | for(int i=0; i<10; i++) 190 | { 191 | ret = rk_recvData(); 192 | // _serial1.println(ret); 193 | if ((ret.indexOf("Initialization OK") >= 0) || (ret.indexOf("No switch work_mode") >= 0)) 194 | { 195 | return true; 196 | } 197 | } 198 | 199 | return false; 200 | 201 | } 202 | 203 | bool RAK811::rk_setJoinMode(int mode) 204 | { 205 | switch (mode) 206 | { 207 | case 0: 208 | sendRawCommand(F("at+set_config=lora:join_mode:0")); //join Network through OTAA mode. 209 | break; 210 | case 1: 211 | sendRawCommand(F("at+set_config=lora:join_mode:1")); //join Network through ABP mode. 212 | break; 213 | default: 214 | return false; 215 | } 216 | ret = rk_recvData(); 217 | if (ret.indexOf("OK") >= 0) 218 | { 219 | return true; 220 | } 221 | else 222 | { 223 | return false; 224 | } 225 | } 226 | 227 | bool RAK811::rk_joinLoRaNetwork(int timeout) 228 | { 229 | String command = "at+join"; 230 | // _serial1.println(command); 231 | sendRawCommand(command); 232 | ret = rk_recvData(); 233 | if (ret != NULL) 234 | { 235 | if (ret.indexOf("OK") >= 0) 236 | return true; 237 | else if(ret.indexOf("ERROR") >= 0) 238 | return false; 239 | } 240 | for (int i = 0; i <= timeout/2; i++) 241 | { 242 | ret = rk_recvData(); 243 | if (ret != NULL) 244 | { 245 | _serial1.print("<- " + ret); 246 | if (ret.indexOf("OK") >= 0) 247 | return true; 248 | // else if(ret.indexOf("ERROR") >= 0) 249 | // return false; 250 | } 251 | } 252 | 253 | return false; 254 | } 255 | 256 | bool RAK811::rk_initOTAA(String devEUI, String appEUI, String appKEY) 257 | { 258 | // String command = ""; 259 | if (devEUI.length() == 16) 260 | { 261 | _devEUI = devEUI; 262 | } 263 | else 264 | { 265 | _serial1.println("The parameter devEUI is set incorrectly!"); 266 | } 267 | if (appEUI.length() == 16) 268 | { 269 | _appEUI = appEUI; 270 | } 271 | else 272 | { 273 | _serial1.println("The parameter appEUI is set incorrectly!"); 274 | } 275 | if (appKEY.length() == 32) 276 | { 277 | _appKEY = appKEY; 278 | } 279 | else 280 | { 281 | _serial1.println("The parameter appKEY is set incorrectly!"); 282 | } 283 | 284 | command = "at+set_config=lora:dev_eui:" + _devEUI; 285 | // _serial1.println(command); 286 | sendRawCommand(command); 287 | ret = rk_recvData(); 288 | if (ret.indexOf("OK") >= 0) 289 | { 290 | command = "at+set_config=lora:app_eui:" + _appEUI; 291 | // _serial1.println(command); 292 | sendRawCommand(command); 293 | 294 | ret = rk_recvData(); 295 | if (ret.indexOf("OK") >= 0) 296 | { 297 | command = "at+set_config=lora:app_key:" + _appKEY; 298 | // _serial1.println(command); 299 | sendRawCommand(command); 300 | 301 | ret = rk_recvData(); 302 | if (ret.indexOf("OK") >= 0) 303 | { 304 | return true; 305 | } 306 | } 307 | } 308 | 309 | return false; 310 | } 311 | 312 | bool RAK811::rk_initABP(String devADDR, String nwksKEY, String appsKEY) 313 | { 314 | // String command = ""; 315 | if (devADDR.length() == 8) 316 | { 317 | _devADDR = devADDR; 318 | } 319 | else 320 | { 321 | _serial1.println(F("The parameter devADDR is set incorrectly!")); 322 | } 323 | if (nwksKEY.length() == 32) 324 | { 325 | _nwksKEY = nwksKEY; 326 | } 327 | else 328 | { 329 | _serial1.println(F("The parameter nwksKEY is set incorrectly!")); 330 | } 331 | if (appsKEY.length() == 32) 332 | { 333 | _appsKEY = appsKEY; 334 | } 335 | else 336 | { 337 | _serial1.println(F("The parameter appsKEY is set incorrectly!")); 338 | } 339 | command = "at+set_config=lora:dev_addr:" + _devADDR; 340 | sendRawCommand(command); 341 | ret = rk_recvData(); 342 | // _serial1.println(ret); 343 | if (ret.indexOf("OK") >= 0) 344 | { 345 | command = "at+set_config=lora:nwks_key:" + _nwksKEY; 346 | sendRawCommand(command); 347 | ret = rk_recvData(); 348 | if (ret.indexOf("OK") >= 0) 349 | { 350 | command = "at+set_config=lora:apps_key:" + _appsKEY; 351 | sendRawCommand(command); 352 | ret = rk_recvData(); 353 | if (ret.indexOf("OK") >= 0) 354 | { 355 | return true; 356 | } 357 | } 358 | } 359 | return false; 360 | } 361 | 362 | bool RAK811::rk_isConfirm(int type) 363 | { 364 | switch (type) 365 | { 366 | case 0: 367 | sendRawCommand(F("at+set_config=lora:confirm:0")); //LoRa data send with unconfirm. 368 | break; 369 | case 1: 370 | sendRawCommand(F("at+set_config=lora:confirm:1")); //LoRa data send with confirm. 371 | break; 372 | default: 373 | return false; 374 | } 375 | ret = rk_recvData(); 376 | if (ret.indexOf("OK") >= 0) 377 | { 378 | return true; 379 | } 380 | else 381 | { 382 | return false; 383 | } 384 | } 385 | 386 | bool RAK811::rk_sendData(int port, char *datahex) 387 | { 388 | // String command = ""; 389 | command = "at+send=lora:" + (String)port + ":" + datahex; 390 | // _serial1.println(command); 391 | sendRawCommand(command); 392 | 393 | return true; 394 | } 395 | 396 | String RAK811::rk_recvData(void) 397 | { 398 | _serial.setTimeout(2000); 399 | ret = _serial.readStringUntil('\0'); 400 | // ret.trim(); 401 | // _serial1.println(ret); 402 | return ret; 403 | } 404 | 405 | bool RAK811::rk_initP2P(String FREQ, int SF, int BW, int CR, int PRlen, int PWR) 406 | { 407 | // String command = ""; 408 | command = "at+set_config=lorap2p:" + FREQ + "," + SF + "," + BW + "," + CR + "," + PRlen + "," + PWR; 409 | // _serial1.println(command); 410 | sendRawCommand(command); 411 | ret = rk_recvP2PData(); 412 | if (ret.indexOf("OK") >= 0) 413 | { 414 | return true; 415 | } 416 | else 417 | { 418 | return false; 419 | } 420 | } 421 | 422 | String RAK811::rk_recvP2PData(void) 423 | { 424 | ret = _serial.readStringUntil('\0'); 425 | ret.trim(); 426 | // delay(500); 427 | return ret; 428 | } 429 | 430 | bool RAK811::rk_sendP2PData(char *datahex) 431 | { 432 | String DATAHEX = datahex; 433 | String command = "at+send=lorap2p:" + DATAHEX; 434 | // _serial1.println(command); 435 | sendRawCommand(command); 436 | // ret = rk_recvP2PData(); 437 | // if (ret.indexOf("OK") > 0) 438 | // { 439 | // return true; 440 | // } 441 | // else 442 | // { 443 | // return false; 444 | // } 445 | return true; 446 | } 447 | 448 | String RAK811::rk_checkDeviceStatus(void) 449 | { 450 | sendRawCommand(F("at+get_config=device:status")); 451 | ret = rk_recvP2PData(); 452 | return ret; 453 | } 454 | 455 | bool RAK811::rk_setUARTConfig(int UartPort, int Baud) 456 | { 457 | // String command = ""; 458 | command = "at+set_config=device:uart:" + (String)UartPort + ":" + (String)Baud; 459 | // _serial1.println(command); 460 | sendRawCommand(command); 461 | 462 | return true; 463 | } 464 | 465 | bool RAK811::sendRawCommand(String cmd) 466 | { 467 | while (_serial.available()) 468 | { 469 | _serial.read(); 470 | } 471 | //_serial1.println(cmd); 472 | _serial.println(cmd); 473 | delay(200); 474 | return true; 475 | } 476 | -------------------------------------------------------------------------------- /Documents and tools/WisNodeV1.2 Arduino Library/Arduino-RAK811-Library/RAK811.h: -------------------------------------------------------------------------------- 1 | /* 2 | * A library for controlling RAK811 LoRa radio. 3 | * 4 | * @Author Leopold.wang 5 | * @Date 14/01/2020 6 | * 7 | */ 8 | 9 | 10 | #ifndef RAK811_h 11 | #define RAK811_h 12 | #define LoRaWAN 0 13 | #define LoRaP2P 1 14 | #define OTAA 0 15 | #define ABP 1 16 | 17 | #include "Arduino.h" 18 | 19 | // #define DEBUG_MODE 20 | 21 | class RAK811 22 | { 23 | public: 24 | 25 | /* 26 | * A simplified constructor taking only a Stream ({Software/Hardware}Serial) object. 27 | * The serial port should already be initialised when initialising this library. 28 | */ 29 | RAK811(Stream& serial,Stream& serial1); 30 | 31 | /* 32 | * Gets the firmware version number of the module. 33 | * Only applies to the firmware that the module programmed for the RAK811 AT command. 34 | * AT commands refer to: https://downloads.rakwireless.com/en/LoRa/RAK811/Application_Notes/Get_Start_with_RAK811_WisNode-LoRa.pdf 35 | */ 36 | bool rk_getVersion(void); 37 | 38 | /*STDB 39 | * Get the frequency band of the module. 40 | * This feature request to receive at least 800 bytes buffer size. 41 | */ 42 | String rk_getLoRaStatus(void); 43 | 44 | /* 45 | * Let the module enter the ultra low power sleep mode. 46 | * When the module is in sleep mode, the host can send any character to wake it up. 47 | * mode :0->wakeup, 1-> sleep 48 | * When the module is awakened, the event response will automatically return through the serial information. 49 | */ 50 | void rk_sleep(int mode); 51 | 52 | /* 53 | * Reset the module. 54 | */ 55 | void rk_reset(void); 56 | 57 | /* 58 | * This command is used to set the interval time of sending data. 59 | * This feature can't use on RAK811,manually close the feature before user APP. 60 | */ 61 | bool rk_setSendinterval(int mode,int value ); 62 | 63 | /* 64 | * Use to change the next send data rate temporary when adr function is off. 65 | * It will not be save to internal flash. 66 | * rate : If your Band is EU868 from 0 to 7. 67 | * If your Band is US915 from 0 to 4. 68 | */ 69 | bool rk_setRate(int rate); 70 | 71 | /* 72 | * Use to change the LoRaWAN class. 73 | * classMode->ClassA, 74 | * 1->ClassB, 75 | * 2->ClassC 76 | * It will be save to internal flash. 77 | */ 78 | bool rk_setClass(int classMode); 79 | 80 | /* 81 | * Use to change the LoRaWAN region. 82 | * region:0->AS923, 83 | * 1->AU915, 84 | * 2->CN470, 85 | * 3->CN779, 86 | * 4->EU433, 87 | * 5->EU868, 88 | * 6->KR920, 89 | * 7->IN865, 90 | * 8->US915, 91 | * 9->US915_Hybrid, 92 | * It will be save to internal flash. 93 | */ 94 | bool rk_setRegion(int region); 95 | 96 | /* 97 | * Set the module work mode, the module defaults to LoRaWAN mode.. 98 | * mode = 0: Set the module to LoRaWAN mode. 99 | * mode = 1: Set the module to LoRaP2P mode. 100 | * This command could cause modual reset,so this function must only be executed once 101 | */ 102 | bool rk_setWorkingMode(int mode); 103 | 104 | /* 105 | * Initialize the module parameter, which is the parameter that the module must use when adding the OTAA to the network. 106 | * devEUI : Device EUI as a HEX string. Example "60C5A8FFFE000001" 107 | * appEUI : Application EUI as a HEX string. Example "70B3D57EF00047C0" 108 | * appKEY : Application key as a HEX string. Example "5D833B4696D5E01E2F8DC880E30BA5FE" 109 | */ 110 | bool rk_initOTAA(String devEUI, String appEUI, String appKEY); 111 | 112 | /* 113 | * Initialize the module parameter, which is the parameter that the module must use when adding the ABP to the network. 114 | * devADDR : The device address as a HEX string. Example "00112233" 115 | * nwksKEY : Network Session Key as a HEX string. Example "3432567afde4525e7890cfea234a5821" 116 | * appsKEY : Application Session Key as a HEX string. Example "a48adfc393a0de458319236537a11d90" 117 | */ 118 | bool rk_initABP(String devADDR, String nwksKEY, String appsKEY); 119 | 120 | /* 121 | * Set the activation mode to join the network.And join the network. 122 | * mode = 0: join a network using over the air activation.. 123 | * mode = 1: join a network using personalization. 124 | * Before using this command, you must call one of the rk_initOTAA or rk_initABP functions 125 | */ 126 | bool rk_setJoinMode(int mode); 127 | 128 | /* 129 | * Join the network. 130 | * timeout: timeout value (unit:s) 131 | * Before using this command, you must call one of the rk_setJoinMode functions 132 | */ 133 | bool rk_joinLoRaNetwork(int timeout); 134 | 135 | /*STDB 136 | * Get the Channels list at current region. 137 | * This feature request to receive at least 800 bytes buffer size if work at Region US915,AU915 or CN470 138 | */ 139 | String rk_getChannelList(void); 140 | 141 | /* 142 | * After joining the network, send the packet at the specified application port. 143 | * port : The port number.(1-223) 144 | * datahex : hex value(no space). max 64 byte. 145 | * This function can only be used in module work in LoRaWAN mode. 146 | */ 147 | bool rk_sendData( int port, char* datahex); 148 | 149 | /* 150 | * LoRa data send package type. 151 | * type : 0->unconfirm, 1->confirm 152 | * This function can only be used in module work in LoRaWAN mode. 153 | */ 154 | bool rk_isConfirm(int type); 155 | 156 | /* 157 | * Returns the data or event information received by the module. 158 | * 159 | */ 160 | String rk_recvData(void); 161 | 162 | 163 | /* 164 | * Initialize the required parameters in LoRaP2P mode. 165 | * You must first switch the module operating mode to LoRaP2P mode 166 | * FREQ : frequency, default 860000000 range: (860000000 ~1020000000) 167 | * SF : spread factor, default 7 ( 6-10) more low more fast datarate 168 | * BW : Band-with, default 0 ( 0:125KHz, 1:250KHz, 2:500KHz) 169 | * CR : coding Rate, default 1 (1:4/5, 2:4/6, 3:4/7, 4:4/8) 170 | * PRlen : Preamlen, default 8 (8-65535) 171 | * PWR : Tx power, default 14 (5-20) 172 | * User can use this command to build their point to point communication or RFtest command. It will save to flash. 173 | */ 174 | bool rk_initP2P(String FREQ, int SF, int BW, int CR, int PRlen, int PWR); 175 | 176 | /* 177 | * This function is used to LoRaP2P send data 178 | * datahex : hex value ( no space) . 179 | */ 180 | bool rk_sendP2PData(char* datahex); 181 | 182 | /* 183 | * Set LoRaP2P Rx continues,module will receive packets with rfconfig until receive the rk_stopRecvP2PData command or rk_reset. 184 | */ 185 | String rk_recvP2PData(void); 186 | 187 | 188 | /*STDB 189 | * Check the device statistics. 190 | */ 191 | String rk_checkDeviceStatus(void); 192 | 193 | 194 | /*STDB 195 | * Set the module serial port parameters.Module restart effective 196 | * UartPort :UART Port number 197 | * Band : Serial baud rate.Supports baud rate: 9600 19200 38400 57600 115200 230400 460800 921600. 198 | */ 199 | bool rk_setUARTConfig(int UartPort,int Baud); 200 | 201 | /* 202 | * Send a raw command to the RAK811 module. 203 | * //Returns the raw string as received back from the RAK811. 204 | * Return true,send OK 205 | * If the RAK811 replies with multiple line, only the first line will be returned. 206 | */ 207 | bool sendRawCommand(String command); 208 | 209 | private: 210 | Stream& _serial; 211 | 212 | Stream& _serial1; 213 | 214 | String _devADDR = "00112233"; 215 | 216 | String _devEUI = "60C5A8FFFE000001"; 217 | 218 | String _appEUI = ""; 219 | 220 | String _nwksKEY = ""; 221 | 222 | String _appKEY = ""; 223 | 224 | String _appsKEY = ""; 225 | 226 | }; 227 | #endif 228 | -------------------------------------------------------------------------------- /Documents and tools/WisNodeV1.2 Arduino Library/Arduino-RAK811-Library/examples/JoinNetworkABP/JoinNetworkABP.ino: -------------------------------------------------------------------------------- 1 | /******************************************************** 2 | * This demo is only supported after RUI firmware version 3.0.0.13.X on RAK811 3 | * Master Board Uart Receive buffer size at least 128 bytes. 4 | ********************************************************/ 5 | 6 | #include "RAK811.h" 7 | #include "SoftwareSerial.h" 8 | #define WORK_MODE LoRaWAN // LoRaWAN or LoRaP2P 9 | #define JOIN_MODE ABP // OTAA or ABP 10 | #if JOIN_MODE == OTAA 11 | String DevEui = "8680000000000001"; 12 | String AppEui = "70B3D57ED00285A7"; 13 | String AppKey = "DDDFB1023885FBFF74D3A55202EDF2B1"; 14 | #else JOIN_MODE == ABP 15 | String NwkSKey = "69AF20AEA26C01B243945A28C9172B42"; 16 | 17 | String AppSKey = "841986913ACD00BBC2BE2479D70F3228"; 18 | String DevAddr = "260125D7"; 19 | #endif 20 | #define TXpin 11 // Set the virtual serial port pins 21 | #define RXpin 10 22 | #define DebugSerial Serial 23 | SoftwareSerial ATSerial(RXpin,TXpin); // Declare a virtual serial port 24 | char buffer[]= "72616B776972656C657373"; 25 | 26 | bool InitLoRaWAN(void); 27 | RAK811 RAKLoRa(ATSerial,DebugSerial); 28 | 29 | 30 | void setup() { 31 | DebugSerial.begin(115200); 32 | while(DebugSerial.available()) 33 | { 34 | DebugSerial.read(); 35 | } 36 | ATSerial.begin(9600); //set ATSerial baudrate:This baud rate has to be consistent with the baud rate of the WisNode device. 37 | while(ATSerial.available()) 38 | { 39 | ATSerial.read(); 40 | } 41 | 42 | if(!RAKLoRa.rk_setWorkingMode(0)) //set WisNode work_mode to LoRaWAN. 43 | { 44 | DebugSerial.println(F("set work_mode failed, please reset module.")); 45 | while(1); 46 | } 47 | 48 | RAKLoRa.rk_getVersion(); //get RAK811 firmware version 49 | DebugSerial.println(RAKLoRa.rk_recvData()); //print version number 50 | 51 | DebugSerial.println(F("Start init RAK811 parameters...")); 52 | 53 | if (!InitLoRaWAN()) //init LoRaWAN 54 | { 55 | DebugSerial.println(F("Init error,please reset module.")); 56 | while(1); 57 | } 58 | 59 | DebugSerial.println(F("Start to join LoRaWAN...")); 60 | while(!RAKLoRa.rk_joinLoRaNetwork(60)) //Joining LoRaNetwork timeout 60s 61 | { 62 | DebugSerial.println(); 63 | DebugSerial.println(F("Rejoin again after 5s...")); 64 | delay(5000); 65 | } 66 | DebugSerial.println(F("Join LoRaWAN success")); 67 | 68 | if(!RAKLoRa.rk_isConfirm(0)) //set LoRa data send package type:0->unconfirm, 1->confirm 69 | { 70 | DebugSerial.println(F("LoRa data send package set error,please reset module.")); 71 | while(1); 72 | } 73 | } 74 | 75 | bool InitLoRaWAN(void) 76 | { 77 | if(RAKLoRa.rk_setJoinMode(JOIN_MODE)) //set join_mode:ABP 78 | { 79 | if(RAKLoRa.rk_setRegion(5)) //set region EU868 80 | { 81 | if (RAKLoRa.rk_initABP(DevAddr, NwkSKey, AppSKey)) //set ABP mode parameters 82 | { 83 | DebugSerial.println(F("RAK811 init OK!")); 84 | return true; 85 | } 86 | } 87 | } 88 | return false; 89 | } 90 | 91 | void loop() { 92 | DebugSerial.println(F("Start send data...")); 93 | if (RAKLoRa.rk_sendData(1, buffer)) 94 | { 95 | for (unsigned long start = millis(); millis() - start < 90000L;) 96 | { 97 | String ret = RAKLoRa.rk_recvData(); 98 | if(ret != NULL) 99 | { 100 | DebugSerial.println(ret); 101 | } 102 | if((ret.indexOf("OK")>0)||(ret.indexOf("ERROR")>0)) 103 | { 104 | DebugSerial.println(F("Go to Sleep.")); 105 | RAKLoRa.rk_sleep(1); //Set RAK811 enter sleep mode 106 | delay(10000); //delay 10s 107 | RAKLoRa.rk_sleep(0); //Wakeup RAK811 from sleep mode 108 | break; 109 | } 110 | } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /Documents and tools/WisNodeV1.2 Arduino Library/Arduino-RAK811-Library/examples/JoinNetworkOTAA/JoinNetworkOTAA.ino: -------------------------------------------------------------------------------- 1 | /******************************************************** 2 | * This demo is only supported after RUI firmware version 3.0.0.13.X on RAK811 3 | * Master Board Uart Receive buffer size at least 128 bytes. 4 | ********************************************************/ 5 | 6 | #include "RAK811.h" 7 | #include "SoftwareSerial.h" 8 | #define WORK_MODE LoRaWAN // LoRaWAN or LoRaP2P 9 | #define JOIN_MODE OTAA // OTAA or ABP 10 | #if JOIN_MODE == OTAA 11 | String DevEui = "8680000000000001"; 12 | String AppEui = "70B3D57ED00285A7"; 13 | String AppKey = "DDDFB1023885FBFF74D3A55202EDF2B1"; 14 | #else JOIN_MODE == ABP 15 | String NwkSKey = "69AF20AEA26C01B243945A28C9172B42"; 16 | String AppSKey = "841986913ACD00BBC2BE2479D70F3228"; 17 | String DevAddr = "260125D7"; 18 | #endif 19 | #define TXpin 11 // Set the virtual serial port pins 20 | #define RXpin 10 21 | #define DebugSerial Serial 22 | SoftwareSerial ATSerial(RXpin,TXpin); // Declare a virtual serial port 23 | char buffer[]= "72616B776972656C657373"; 24 | 25 | bool InitLoRaWAN(void); 26 | RAK811 RAKLoRa(ATSerial,DebugSerial); 27 | 28 | 29 | void setup() { 30 | DebugSerial.begin(115200); 31 | while(DebugSerial.available()) 32 | { 33 | DebugSerial.read(); 34 | } 35 | 36 | ATSerial.begin(9600); //set ATSerial baudrate:This baud rate has to be consistent with the baud rate of the WisNode device. 37 | while(ATSerial.available()) 38 | { 39 | ATSerial.read(); 40 | } 41 | 42 | if(!RAKLoRa.rk_setWorkingMode(0)) //set WisNode work_mode to LoRaWAN. 43 | { 44 | DebugSerial.println(F("set work_mode failed, please reset module.")); 45 | while(1); 46 | } 47 | 48 | RAKLoRa.rk_getVersion(); //get RAK811 firmware version 49 | DebugSerial.println(RAKLoRa.rk_recvData()); //print version number 50 | 51 | DebugSerial.println(F("Start init RAK811 parameters...")); 52 | 53 | if (!InitLoRaWAN()) //init LoRaWAN 54 | { 55 | DebugSerial.println(F("Init error,please reset module.")); 56 | while(1); 57 | } 58 | 59 | DebugSerial.println(F("Start to join LoRaWAN...")); 60 | while(!RAKLoRa.rk_joinLoRaNetwork(60)) //Joining LoRaNetwork timeout 60s 61 | { 62 | DebugSerial.println(); 63 | DebugSerial.println(F("Rejoin again after 5s...")); 64 | delay(5000); 65 | } 66 | DebugSerial.println(F("Join LoRaWAN success")); 67 | 68 | if(!RAKLoRa.rk_isConfirm(0)) //set LoRa data send package type:0->unconfirm, 1->confirm 69 | { 70 | DebugSerial.println(F("LoRa data send package set error,please reset module.")); 71 | while(1); 72 | } 73 | } 74 | 75 | bool InitLoRaWAN(void) 76 | { 77 | if(RAKLoRa.rk_setJoinMode(JOIN_MODE)) //set join_mode:OTAA 78 | { 79 | if(RAKLoRa.rk_setRegion(5)) //set region EU868 80 | { 81 | if (RAKLoRa.rk_initOTAA(DevEui, AppEui, AppKey)) 82 | { 83 | DebugSerial.println(F("RAK811 init OK!")); 84 | return true; 85 | } 86 | } 87 | } 88 | return false; 89 | } 90 | 91 | void loop() { 92 | DebugSerial.println(F("Start send data...")); 93 | if (RAKLoRa.rk_sendData(1, buffer)) 94 | { 95 | for (unsigned long start = millis(); millis() - start < 90000L;) 96 | { 97 | String ret = RAKLoRa.rk_recvData(); 98 | if(ret != NULL) 99 | { 100 | DebugSerial.println(ret); 101 | } 102 | if((ret.indexOf("OK")>0)||(ret.indexOf("ERROR")>0)) 103 | { 104 | DebugSerial.println(F("Go to Sleep.")); 105 | RAKLoRa.rk_sleep(1); //Set RAK811 enter sleep mode 106 | delay(10000); //delay 10s 107 | RAKLoRa.rk_sleep(0); //Wakeup RAK811 from sleep mode 108 | break; 109 | } 110 | } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /Documents and tools/WisNodeV1.2 Arduino Library/Arduino-RAK811-Library/examples/LoRaP2P/LoRaP2P_Receiver/LoRaP2P_Receiver.ino: -------------------------------------------------------------------------------- 1 | /******************************************************** 2 | * This demo is only supported after RUI firmware version 3.0.0.13.X on RAK811 3 | * Master Board Uart Receive buffer size at least 128 bytes. 4 | ********************************************************/ 5 | 6 | #include "RAK811.h" 7 | #include "SoftwareSerial.h" 8 | #define WORK_MODE LoRaP2P // LoRaWAN or LoRaP2P 9 | 10 | #define TXpin 11 // Set the virtual serial port pins 11 | #define RXpin 10 12 | #define DebugSerial Serial 13 | SoftwareSerial ATSerial(RXpin,TXpin); // Declare a virtual serial port 14 | char buffer[]= "72616B776972656C657373"; 15 | 16 | RAK811 RAKLoRa(ATSerial,DebugSerial); 17 | 18 | 19 | void setup() { 20 | DebugSerial.begin(115200); 21 | while(DebugSerial.available()) 22 | { 23 | DebugSerial.read(); 24 | } 25 | 26 | ATSerial.begin(9600); //set ATSerial baudrate:This baud rate has to be consistent with the baud rate of the WisNode device. 27 | while(ATSerial.available()) 28 | { 29 | ATSerial.read(); 30 | } 31 | 32 | if(!RAKLoRa.rk_setWorkingMode(WORK_MODE)) //set WisNode work_mode to LoRaP2P. 33 | { 34 | DebugSerial.println(F("set work_mode failed, please reset module.")); 35 | while(1); 36 | } 37 | 38 | RAKLoRa.rk_getVersion(); //get RAK811 firmware version 39 | DebugSerial.println(RAKLoRa.rk_recvData()); //print version number 40 | 41 | DebugSerial.println(F("Start init LoRaP2P parameters...")); 42 | if (!RAKLoRa.rk_initP2P("869525000",12,0,1,8,20)) //init LoRaP2P 43 | { 44 | DebugSerial.println(F("Init error,please reset module.")); 45 | while(1); 46 | }else DebugSerial.println(F("Init OK")); 47 | } 48 | 49 | void loop() { 50 | String ret = RAKLoRa.rk_recvP2PData(); 51 | if(ret != NULL) 52 | { 53 | DebugSerial.println(ret); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Documents and tools/WisNodeV1.2 Arduino Library/Arduino-RAK811-Library/examples/LoRaP2P/LoRaP2P_Sender/LoRaP2P_Sender.ino: -------------------------------------------------------------------------------- 1 | /******************************************************** 2 | * This demo is only supported after RUI firmware version 3.0.0.13.X on RAK811 3 | * Master Board Uart Receive buffer size at least 128 bytes. 4 | ********************************************************/ 5 | 6 | #include "RAK811.h" 7 | #include "SoftwareSerial.h" 8 | #define WORK_MODE LoRaP2P // LoRaWAN or LoRaP2P 9 | 10 | #define TXpin 11 // Set the virtual serial port pins 11 | #define RXpin 10 12 | #define DebugSerial Serial 13 | SoftwareSerial ATSerial(RXpin,TXpin); // Declare a virtual serial port 14 | char buffer[]= "72616B776972656C657373"; 15 | 16 | RAK811 RAKLoRa(ATSerial,DebugSerial); 17 | 18 | 19 | void setup() { 20 | DebugSerial.begin(115200); 21 | while(DebugSerial.available()) 22 | { 23 | DebugSerial.read(); 24 | } 25 | 26 | ATSerial.begin(9600); //set ATSerial baudrate:This baud rate has to be consistent with the baud rate of the WisNode device. 27 | while(ATSerial.available()) 28 | { 29 | ATSerial.read(); 30 | } 31 | 32 | if(!RAKLoRa.rk_setWorkingMode(WORK_MODE)) //set WisNode work_mode to LoRaP2P. 33 | { 34 | DebugSerial.println(F("set work_mode failed, please reset module.")); 35 | while(1); 36 | } 37 | 38 | RAKLoRa.rk_getVersion(); //get RAK811 firmware version 39 | DebugSerial.println(RAKLoRa.rk_recvData()); //print version number 40 | 41 | DebugSerial.println(F("Start init LoRaP2P parameters...")); 42 | 43 | if (!RAKLoRa.rk_initP2P("869525000",12,0,1,8,20)) //init LoRaP2P 44 | { 45 | DebugSerial.println(F("Init error,please reset module.")); 46 | while(1); 47 | }else DebugSerial.println(F("Init OK")); 48 | } 49 | 50 | void loop() { 51 | DebugSerial.println(F("Start send data...")); 52 | if (RAKLoRa.rk_sendP2PData(buffer)) 53 | { 54 | String ret = RAKLoRa.rk_recvP2PData(); 55 | if(ret != NULL) 56 | { 57 | DebugSerial.println(ret); 58 | } 59 | } 60 | delay(10000); //delay 10s 61 | } 62 | -------------------------------------------------------------------------------- /Documents and tools/WisNodeV1.2 Arduino Library/Arduino-RAK811-Library/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For RAK811 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | RAK811 KEYWORD1 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | rk_recvData KEYWORD2 15 | rk_getVersion KEYWORD2 16 | rk_getLoRaStatus KEYWORD2 17 | rk_sleep KEYWORD2 18 | rk_reset KEYWORD2 19 | rk_setSendinterval KEYWORD2 20 | rk_setRate KEYWORD2 21 | rk_setClass KEYWORD2 22 | rk_setRegion KEYWORD2 23 | rk_setWorkingMode KEYWORD2 24 | isUidValid KEYWORD2 25 | rk_initOTAA KEYWORD2 26 | rk_initABP KEYWORD2 27 | rk_setJoinMode KEYWORD2 28 | rk_joinLoRaNetwork KEYWORD2 29 | rk_getChannelList KEYWORD2 30 | rk_sendData KEYWORD2 31 | rk_isConfirm KEYWORD2 32 | rk_initP2P KEYWORD2 33 | rk_sendP2PData KEYWORD2 34 | rk_recvP2PData KEYWORD2 35 | rk_checkDeviceStatus KEYWORD2 36 | rk_setUARTConfig KEYWORD2 37 | sendRawCommand KEYWORD2 38 | 39 | ####################################### 40 | # Instances (KEYWORD2) 41 | ####################################### 42 | 43 | ####################################### 44 | # Constants (LITERAL1) 45 | ####################################### 46 | LoRaWAN LITERAL1 47 | LoRaP2P LITERAL1 48 | OTAA LITERAL1 49 | ABP LITERAL1 50 | STATUS_RECV_DATA LITERAL1 51 | STATUS_TX_COMFIRMED LITERAL1 52 | STATUS_TX_UNCOMFIRMED LITERAL1 53 | STATUS_JOINED_SUCCESS LITERAL1 54 | STATUS_JOINED_FAILED LITERAL1 55 | STATUS_TX_TIMEOUT LITERAL1 56 | STATUS_RX2_TIMEOUT LITERAL1 57 | STATUS_DOWNLINK_REPEATED LITERAL1 58 | STATUS_WAKE_UP LITERAL1 59 | STATUS_P2PTX_COMPLETE LITERAL1 60 | STATUS_UNKNOWN LITERAL1 -------------------------------------------------------------------------------- /Documents and tools/WisNodeV1.2 Arduino Library/RAK811 WisNode V1.2 Hardware.md: -------------------------------------------------------------------------------- 1 | ## RAK811 WisNode V1.2 2 | 3 | ### Hardware Configuration 4 | 5 | After completing the above steps, connect RAK WisNode to Arduino Uno, and connect RAK WisNode to the jumper as shown in the figure below. 6 | 7 |
8 | 9 |
10 | 11 | ### Test LoRa Node with LoRaWAN 12 | 13 | Server and serial console log: 14 | 15 |
16 | 17 | If the log does not display properly, it can be resolved by restarting the board. -------------------------------------------------------------------------------- /Documents and tools/WisNode_Arduino_Library API Manual V1.1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RAKWireless/WisNode-Arduino-Library/29b9c1c63f2e666c5706f4cec2f3e404fe664630/Documents and tools/WisNode_Arduino_Library API Manual V1.1.pdf -------------------------------------------------------------------------------- /Documents and tools/image/Arduino_mode_v1.1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RAKWireless/WisNode-Arduino-Library/29b9c1c63f2e666c5706f4cec2f3e404fe664630/Documents and tools/image/Arduino_mode_v1.1.png -------------------------------------------------------------------------------- /Documents and tools/image/Arduino_mode_v1.2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RAKWireless/WisNode-Arduino-Library/29b9c1c63f2e666c5706f4cec2f3e404fe664630/Documents and tools/image/Arduino_mode_v1.2.png -------------------------------------------------------------------------------- /Documents and tools/image/Arduino_mode_v1.3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RAKWireless/WisNode-Arduino-Library/29b9c1c63f2e666c5706f4cec2f3e404fe664630/Documents and tools/image/Arduino_mode_v1.3.png -------------------------------------------------------------------------------- /Documents and tools/image/Download_Firmware.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RAKWireless/WisNode-Arduino-Library/29b9c1c63f2e666c5706f4cec2f3e404fe664630/Documents and tools/image/Download_Firmware.png -------------------------------------------------------------------------------- /Documents and tools/image/Library_directory.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RAKWireless/WisNode-Arduino-Library/29b9c1c63f2e666c5706f4cec2f3e404fe664630/Documents and tools/image/Library_directory.png -------------------------------------------------------------------------------- /Documents and tools/image/Library_in_the_menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RAKWireless/WisNode-Arduino-Library/29b9c1c63f2e666c5706f4cec2f3e404fe664630/Documents and tools/image/Library_in_the_menu.png -------------------------------------------------------------------------------- /Documents and tools/image/LoRaWAN_log.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RAKWireless/WisNode-Arduino-Library/29b9c1c63f2e666c5706f4cec2f3e404fe664630/Documents and tools/image/LoRaWAN_log.png -------------------------------------------------------------------------------- /Documents and tools/image/RAK811_jump_line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RAKWireless/WisNode-Arduino-Library/29b9c1c63f2e666c5706f4cec2f3e404fe664630/Documents and tools/image/RAK811_jump_line.png -------------------------------------------------------------------------------- /Documents and tools/image/Serial_port_configuration_modification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RAKWireless/WisNode-Arduino-Library/29b9c1c63f2e666c5706f4cec2f3e404fe664630/Documents and tools/image/Serial_port_configuration_modification.png -------------------------------------------------------------------------------- /Documents and tools/image/TTN_log.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RAKWireless/WisNode-Arduino-Library/29b9c1c63f2e666c5706f4cec2f3e404fe664630/Documents and tools/image/TTN_log.png -------------------------------------------------------------------------------- /Documents and tools/image/V1.1_log.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RAKWireless/WisNode-Arduino-Library/29b9c1c63f2e666c5706f4cec2f3e404fe664630/Documents and tools/image/V1.1_log.png -------------------------------------------------------------------------------- /Documents and tools/image/V1.2_jump.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RAKWireless/WisNode-Arduino-Library/29b9c1c63f2e666c5706f4cec2f3e404fe664630/Documents and tools/image/V1.2_jump.png -------------------------------------------------------------------------------- /Documents and tools/image/arduino_connect_RAK811.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RAKWireless/WisNode-Arduino-Library/29b9c1c63f2e666c5706f4cec2f3e404fe664630/Documents and tools/image/arduino_connect_RAK811.jpg -------------------------------------------------------------------------------- /Documents and tools/image/burn_firmware.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RAKWireless/WisNode-Arduino-Library/29b9c1c63f2e666c5706f4cec2f3e404fe664630/Documents and tools/image/burn_firmware.png -------------------------------------------------------------------------------- /Documents and tools/image/connect_STM32cubeprogrammer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RAKWireless/WisNode-Arduino-Library/29b9c1c63f2e666c5706f4cec2f3e404fe664630/Documents and tools/image/connect_STM32cubeprogrammer.png -------------------------------------------------------------------------------- /Documents and tools/image/jump_boot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RAKWireless/WisNode-Arduino-Library/29b9c1c63f2e666c5706f4cec2f3e404fe664630/Documents and tools/image/jump_boot.png -------------------------------------------------------------------------------- /Documents and tools/image/merge_connect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RAKWireless/WisNode-Arduino-Library/29b9c1c63f2e666c5706f4cec2f3e404fe664630/Documents and tools/image/merge_connect.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WisNode-LoRa-Arduino Library User Manual 2 | 3 | ## Introduction 4 | 5 | The core of WisNode is the RAK811 LoRa module, and its interface is a universal Arduino interface, which means you can easily connect to any open source hardware with such an interface. As long as the user writes the control code on the Arduino IDE, the communication between LoRaWAN and LoRa P2P can be quickly realized. 6 | 7 | To develop Arduino program, you can refer to the API manual:[WisNode_Arduino_Library API Manual V1.1.pdf](https://github.com/RAKWireless/WisNode-Arduino-Library/blob/master/Documents%20and%20tools/WisNode_Arduino_Library%20API%20Manual%20V1.1.pdf) 8 | 9 | ## Setup 10 | 11 | ### Arduino 12 | 13 | 1. Install Arduino IDE 14 | First, you need to install the Arduino IDE. From the link below, select the version that suits your platform. 15 | [https://www.arduino.cc/en/main/software](https://www.arduino.cc/en/main/software) 16 | 17 | 2. Install the Arduino library 18 | 19 | WisNode is controlled by AT commands. RAKWireless provides an encapsulation library for Arduino developers. AT commands are encapsulated as APIs, which are convenient for developers to call. 20 | 21 | a. Download the `Arduino-RAK811-Library folder` in the repository. 22 | 23 | The current warehouse supports version RAK811 WisNode V1.3. 24 | 25 | If you are using RAK811 WisNode in V1.1 version, please download RAK811 WisNode through this link: 26 | 27 | https://github.com/RAKWireless/WisNode-Arduino-Library/tree/master/Documents%20and%20tools/WisNodeV1.1%20Arduino%20Library 28 | 29 | If you are using RAK811 WisNode in V1.2 version, please download RAK811 WisNode through this link: 30 | 31 | https://github.com/RAKWireless/WisNode-Arduino-Library/tree/master/Documents%20and%20tools/WisNodeV1.2%20Arduino%20Library 32 | 33 | b. Copy to the Arduino library directory, usually it's in `C:\Users\\Documents\Arduino\libraries` for Windows, and in `~/Documents/Arduino/libraries/` for Linux and Mac OS X. 34 | 35 |
36 | 37 | c. Reopen the Arduino IDE, you can see `Arduino-RAK811-Library` in the menu, indicating that the library is successfully installed. 38 | 39 |
40 | 41 | d. Before compiling the routine, you need to modify the serial port configuration of the development board. Open the Arduino IDE installation directory, find the `\hardware\arduino\avr\cores\arduino\HardwareSerial.h` file, and modify the size of the serial port receiving and sending buffers. 42 | 43 |
44 | ### RAK811 45 | 46 | 1. Please install the “STM32CubeProgrammer” tool on your Windows PC. You can download it from here: 47 | 48 | https://www.st.com/content/st_com/en/products/development-tools/software-development-tools/stm32-software-development-tools/stm32-programmers/stm32cubeprog.html#overview 49 | 50 | or from RAK website: 51 | 52 | https://downloads.rakwireless.com/en/LoRa/RAK811/Tools/SetupSTM32CubeProgrammer-2.1.0.rar 53 | 54 | 2. Please download the WisNode-Arduino version of the firmware from here: 55 | 56 | https://github.com/RAKWireless/WisNode-Arduino-Library/tree/master/Documents%20and%20tools/WisNode-Arduino%20version-Firmware 57 | 58 | ps:The firmware version has H and L distinction, which corresponds to different frequencies available. 59 | 60 | WisNode-Arduino version-H:EU868、IN865、US915、AU915、KR920、AS923 61 | 62 | WisNode-Arduino version-L:EU433、CN470 63 | 64 | 3. jump the “BOOT” pin and “3V3” pin for boot mode as following: 65 | 66 |
67 | 68 | 4. Connect RAK811 WisNode with your PC’s USB interface, Open the “STM32CubeProgrammer” tool, and select UART type, then configure the Port, Baudrate, and Pairty .Then press “Connect” button at the top right corner. 69 | 70 |
71 | 72 | 5. Press “Open file” and selectthe WisNode-Arduino version hex file in the pop-up window,And press the “Download” button to start the burning process: 73 | 74 |
75 | 76 | 6. Burn successfully, restore to the initial state. 77 | 78 | 79 | 80 | ## Example 81 | 82 | ### JoinNetworkOTAA 83 | 84 | RAKWireless provides LoRaWAN communication routines for WisNode, including OTAA and ABP modes. Open the OTAA example, you need to get the value of app_eui, dev_eui, app_key from your LoRa Server. And set these values to the corresponding DevEui, AppEui, AppKey variables. 85 | 86 | Compile the code, download it to the target board, and see the log from the Arduino serial monitor. 87 | 88 |
89 | 90 | ### Hardware Configuration 91 | 92 | After completing the above steps, connect RAK WisNode to Arduino Uno, and connect RAK WisNode to the jumper as shown in the figure below. 93 | 94 |
95 | 96 |
97 | 98 | ps:Since there are two other previous versions of the RAK Wisnode hardware,to accommodate all users, here are the other two versions of the connection and the success stories. 99 | 100 | 101 | 102 | If your Version of RAK WisNode is V1.1, see how to connect in this link: 103 | 104 | https://github.com/RAKWireless/WisNode-Arduino-Library/blob/master/Documents%20and%20tools/WisNodeV1.1%20Arduino%20Library/RAK811%20WisNode%20V1.1%20Hardware.md 105 | 106 | If your Version of RAK WisNode is V1.2, see how to connect in this link: 107 | 108 | https://github.com/RAKWireless/WisNode-Arduino-Library/blob/master/Documents%20and%20tools/WisNodeV1.2%20Arduino%20Library/RAK811%20WisNode%20V1.2%20Hardware.md 109 | 110 | 111 | 112 | ### Test LoRa Node with LoRaWAN 113 | 114 | Server and serial console log: 115 | 116 |
117 | 118 | If the log does not display properly, it can be resolved by restarting the board. 119 | 120 | ## Contact us 121 | 122 | If you have any questions, welcome to the forum. 123 | 124 | [forum.rakwireless.com](https://forum.rakwireless.com) 125 | 126 | --------------------------------------------------------------------------------