RAK11162 WisDuo LoRaWAN + BLE + Wi-Fi Module Quick Start Guide
This guide covers the setup of the RAK11162 as a Stand-Alone Device Using RUI3.
Due to the STM32WLE5's limitation of only two UART interfaces, no UART is available for the WisBlock Sensor and IO slots. As a result, WisBlock modules that rely on UART communication are not compatible with the RAK11162 Core module. Additionally, because of limited available GPIOs, the second I2C interface used by some WisBlock modules is not accessible through the IO slot.
Prerequisites
Before going through each and every step on using RAK11162 WisBlock Core, make sure to prepare the necessary items listed below:
Hardware
- RAK11162 WisBlock Core LPWAN+BLE+Wi-Fi Module
- Your choice of WisBlock Base
- Your choice of WisBlock Modules
- USB Cable
- Li-Ion/LiPo battery (optional)
- Solar charger (optional)
Software
- Download and install the Arduino IDE.
If you are using Windows 10. Do NOT install the Arduino IDE from the Microsoft App Store. Instead, install the original Arduino IDE from the Arduino official website. The Arduino app from the Microsoft App Store has problems using third-party Board Support Packages.
- Add RAK11162 as a supported board in Arduino IDE by updating Board Manager URLs in Preferences settings of Arduino IDE with this JSON URL
https://raw.githubusercontent.com/RAKWireless/RAKwireless-Arduino-BSP-Index/main/package_rakwireless_com_rui_index.json
. After that, add RAKwireless RUI SMT32 Boards via Arduino board manager. - RAK Serial Port Tool
Product Configuration
Hardware Setup
RAK11162 to WisBlock Base
The RAK11162 will not work without a WisBlock Base board. The WisBlock Base provides a USB connection for programming the RAK11162. It also provides a power source and various interfaces to RAK11162 so that it can be connected to other WisBlock Modules via different module slots.
RAKwireless offers many WisBlock Base Boards compatible with WisBlock Core. It is highly recommended for you to look on these WisBlock Base boards to see what matches your requirements in terms of available module slots, power supply options, and overall size.
To illustrate, RAK11162 can be connected to RAK19007 WisBlock Base, as shown in Figure 1.

Few pins are exposed on RAK19007, and you can easily use them via header pins. The labels are at the back, as shown in Figure 2.

More information can be found on the official documentation of the specific WisBlock Base you used in your project.
For RAK19007 WisBlock Base with RAK11162 WisBlock Core, the accessible GPIO pins are defined as follows in the Arduino IDE and Platform IO:
WB_IO1
for IO1 pinWB_IO2
for IO2 pin (Also used to control the 3.3 V supply of some WisBlock Modules to achieve low-power IoT devices.)WB_A0
for AIN
There are usable LEDs as well that can be controlled by the RAK11162 on the WisBlock Base board:
LED_GREEN
LED_BLUE
I2C_1 is also exposed on the header of the WisBlock Base board.
- RAK11162 has its I2C interface exposed on the I2C_1 header pins. These pins are as well shared to the WisBlock Base Slots A-D.
Due to the STM32WLE5's limitation of only two UART interfaces, no UART is available for the WisBlock Sensor and IO slots. As a result, WisBlock modules that rely on UART communication are not compatible with the RAK11162 Core module.
Additionally, because of limited available GPIOs, the second I2C interface used by some WisBlock modules is not accessible through the IO slot.
RAK11162 to WisBlock Modules
RAK11162 WisBlock Core is designed to be interfaced with other WisBlock Modules like sensors, displays, and other interfaces. You need to connect these modules to the compatible slots on the WisBlock Base.
Each WisBlock Modules that will be used with RAK11162 WisBlock Core have a dedicated quick start guide you can follow on how to connect to the WisBlock Base.
Listed are the quick start guide of some WisBlock modules you can buy from our store:
The listed links are just examples. All WisBlock Modules have their own quick start guide that you can use as a reference to get started on specific modules.
Figure 3 shows an illustration on how you can combine various WisBlock Modules with the RAK11162 WisBlock Core via the WisBlock Base board.

Assembling and Disassembling of WisBlock Modules
Assembling
Figure 4 shows how to mount the RAK11162 module on top of a WisBlock Base board (RAK19007). Follow carefully the procedure defined in WisBlock module assembly/disassembly instructions in order to secure the connection safely. Once attached, carefully fix the module with one or more pieces of M1.2 x 3 mm screws depending on the module.

Disassembling
The procedure in disassembling any type of WisBlock module is the same.
- First, remove the screws.

- Once the screws are removed, check the silkscreen of the module to find the correct location where force can be applied.

- Apply force to the module at the position of the connector, as shown in Figure 7, to detach the module from the baseboard.

LoRa and Wi-Fi/BLE Antenna
Another important part component of RAK11162 is the antennas.


You need to ensure that these antennas are properly connected to have a good LoRa and BLE signal. Also, note that you can damage the RF section of the chip if you power the module without an antenna connected to the IPEX connector.
RAK11162 has a label on its sticker where to connect the antennas, as shown in Figure 10.

- Detailed information about the RAK11162 LoRa IPEX MHF4 antenna can be found on the 863-870 MHz antenna datasheet or the 902-928 MHz antenna datasheet.
- If the RAK11162 is not an IPEX MHF4 variant, the connection to the antennas are done via the RF pins. RAKwireless offers RF Antenna Design Service for custom PCB designs.
- Standard IPEX connector will not work on RAK11162. The IPEX antenna connectors of RAK11162 are a different variant called IPEX MHF-4. This is specially designed for low-profile circuit boards with limited spaces.
- When using the LoRa, Wi-Fi or Bluetooth Low Energy transceivers, make sure that the antennas are connected. Using these transceivers without an antenna can damage the module.
Battery and Solar Connection
RAK11162 can be powered via the USB cable or Li-Ion/LiPo battery via the dedicated connectors, as shown in Figure 11. The matching connector for the battery wires is a JST PHR-2 2 mm pitch female.
This illustration uses RAK19007 as WisBlock Base. There are other WisBlock Base boards available, and you need to check the datasheet of the specific WisBlock Base board for the right polarity and other parameters.
- Batteries can cause harm if not handled properly.
- Only 3.7-4.2 V Rechargeable LiPo batteries are supported. It is highly recommended not to use other types of batteries with the system unless you know what you are doing.
- If a non-rechargeable battery is used, it has to be unplugged first before connecting the USB cable to the USB port of the board to configure the device. Not doing so might damage the battery or cause a fire.
- Only 5 V solar panels are supported. Do not use 12 V solar panels. It will destroy the charging unit and eventually other electronic parts.
- Make sure the battery wires match the polarity on the WisBlock Base board. Not all batteries have the same wiring.


The battery can be recharged as well via small solar panel, as shown in Figure 13. The matching connector for the solar panel wires is an JST ZHR-2 1.5 mm pitch female.

Specification of the battery and solar panel can be found on the datasheet of the WisBlock Base.
Software Setup
The default firmware of the RAK11162 is based on RUI3, which allows you to develop your own custom firmware to connect sensors and other peripherals to it. To develop your custom firmware using the Arduino IDE:
- Add RAKwireless RUI STM32 Boards to the Arduino board manager, which will be discussed in this guide.
- Use RUI3 APIs for your intended application.
- Send AT commands and upload custom firmware via UART or wirelessly via BLE.
The AT commands in RAK11162 are still available even if you compile custom firmware via RUI3, and there is an option to disable them.
RAK11162 RUI3 Board Support Package in Arduino IDE
If you don't have an Arduino IDE yet, download it on the Arduino official website.
For Windows 10 and up users: If your Arduino IDE was installed from the Microsoft App Store, you need to reinstall your Arduino IDE by downloading it from the Arduino official website. The Arduino app from the Microsoft App Store has problems using third-party Board Support Packages.
After successfully installing the Arduino IDE, configure it to add the RAK11162 to its board selection by following these steps:
- Open Arduino IDE and go to File > Preferences.

- To add the RAK11162 to your Arduino Boards list, edit the Additional Board Manager URLs. Click the icon, as shown in Figure 15.

- Copy the URL
https://raw.githubusercontent.com/RAKWireless/RAKwireless-Arduino-BSP-Index/main/package_rakwireless_com_rui_index.json
and paste it on the field. If other URLs are already there, just add them on the next line. After adding the URL, click OK.

- Restart the Arduino IDE.
- Open the Boards Manager from the Tools menu.

- Write
RAK
in the search bar, as shown in Figure 18. This will display the available RAKwireless module boards that can be added to your Arduino board list. Select and install the latest version of the RAKwireless RUI STM32 Boards.

- Once the BSP is installed, select Tools > Boards Manager > RAKwireless RUI STM32 Modules > WisDuo RAK11160 Board.

Compile an Example With Arduino
- After adding the RAK11162 to the Arduino IDE, test your setup by running a simple program.

- Connect the RAK11162 via USB and check the RAK11162 COM port using Windows Device Manager. Double-check the USB cable and USB port if the module is not detected.

- Choose RAK11162 in the board selection by navigating to Tools > Boards Manager and choosing RAKwireless RUI STM32 Modules > WisDuo RAK11160 Board.

- Open the Tools menu and select a COM port. COM27 is currently used.

- Click on the Serial Monitor icon to connect to the COM port.

- Once connected to the COM port, send AT commands to the RAK11162. For example, to check the RUI version, type
AT+VER=?
in the text field and press Send, as shown in Figure 25.

- Copy the example code below and paste it into Arduino IDE.
Click to view the example code.
void setup() {
Serial.begin(115200);
}
void loop() {
Serial.println("Hello");
delay(5000);
}

- Click the Verify button to compile and check for errors.

- When the compilation is complete, click the Upload button to flash the firmware to the RAK11162.

- Upon successful upload, the Device programmed message will appear.

- The RAK11162 should automatically enter BOOT mode when firmware is uploaded via the Arduino IDE.
- If it does not, BOOT mode can be manually activated by sending the
AT+BOOT
command. In BOOT mode, standard AT commands will no longer work unlessAT+RUN
is sent to exit BOOT mode.
- After the Device Programmed is completed, you will see the "Hello" message every 5 seconds in the console.

LoRaWAN Example
This example illustrates how to program the RAK11162 as a stand-alone LoRaWAN end-device via RUI3 Arduino APIs. To use RAK11162 as a LoRaWAN end-device, it must be within reach of a working LoRaWAN gateway registered to a LoRaWAN network server (LNS) or with a built-in network server.
If you are new to LoRaWAN, here are a few good references about LoRaWAN and gateways:
To enable the RAK11162 module as a LoRaWAN end-device, a device must first be registered with the LoRaWAN network server. This guide covers both TTN and ChirpStack LoRaWAN network servers and the associated Arduino codes and AT commands for the RAK11162.
- TheThingsNetwork Guide: How to login, register new accounts, and create new applications on TTN.
- RAK11162 TTN OTAA Guide: How to add OTAA device on TTN and what AT commands to use on RAK11162 OTAA activation.
- RAK11162 TTN ABP Guide: How to add ABP device on TTN and what AT commands to use on RAK11162 ABP activation.
- ChirpStack Guide: How to create new applications on ChirpStack.
- RAK11162 ChirpStack OTAA Guide: How to add OTAA device to ChirpStack and what AT commands to use on RAK11162 OTAA activation.
- RAK11162 ChirpStack ABP Guide: How to add ABP device on ChirpStack and what AT commands to use on RAK11162 ABP activation.
Connect With The Things Network (TTN)
This section shows how to connect the RAK11162 module to the TTN platform.
A working gateway connected to TTN is required, or the device must be within the coverage of a TTN community network.

As shown in Figure 32, The Things Stack (TTN V3) is an open-source LoRaWAN network server suitable for global, geo-distributed public and private deployments as well as for small local networks. The architecture follows the LoRaWAN Network Reference Model for standards compliance and interoperability. This project is actively maintained by The Things Industries.
LoRaWAN is a protocol for low-power wide-area networks. It allows large-scale Internet of Things deployments where low-powered devices efficiently communicate with internet-connected applications over long-range wireless connections.
The RAK11162 WisDuo module can be part of this ecosystem as a device, and the objective of this section is to demonstrate how simple it is to send data to The Things Stack using the LoRaWAN protocol. To achieve this, the RAK11162 WisDuo module must be located within the coverage of a LoRaWAN gateway connected to The Things Stack server.
- Sign up for a TTN account.
a. Go to The Things Network and click on Sign up.

b. Select a community type by clicking Get started.

c. Sign up through The Things ID by clicking Sign up for free.

d. Enter your details, agree to the Terms and Conditions, and click Sign up to The Things ID.

e. Then, select a cluster as shown in Figure 36.

Use the same login credentials on the TTN V2 if you have one. If you have no account yet, create one.
- Once logged in to the platform, create an application by clicking Create an application.

- Navigate to the Applications tab.

- Fill in the necessary information about your application, then click Create application.

If you had no errors in the previous step, the application console page should now be visible. The next step is to add end-devices to your TTN application.
LoRaWAN specifications enforce that each end-device has to be personalized and activated. There are two options for registering devices, depending on the activation mode selected. Activation can be done either via Over-The-Air-Activation (OTAA) or Activation-By-Personalization (ABP).
TTN OTAA Device Registration
- Go to your application console to register a device. To start adding an OTAA end-device, click +Register end device, as shown in Figure 40.

- Register the board by selecting Enter end device specifics manually.

- Configure the Frequency plan, compatible LoRaWAN version, and supported Regional Parameters version.


- Set the JoinEUI by entering zeros into the field.

- Click Show advanced activation, LoRaWAN class and cluster settings.

- Configure the following, then click Confirm.
- Activation mode: Over the air activation (OTAA)
- Additional LoRaWAN class capabilities: None (class A only)

- Once completed, enter the device's DevEUI credential in the DevEUI field. This will automatically generate the specific end-device ID of your board.
- The AppEUI, DevEUI, and AppKey are hidden in this section as these are unique to a specific device. The DevEUI is specific to every RAK11162 device, while the AppEUI and AppKey should be generated individually for each device and application.
- The AppEUI is the same as JoinEUI.

- Click Generate under AppKey, as shown in Figure 39.

- Once done, click Register end device to complete the process.

After completing the device registration, the device should appear on the TTN console, as shown in Figure 50.
- The AppEUI, DevEUI, and AppKey are the parameters required to activate your LoRaWAN end-device via OTAA. For security reasons, the AppKey is hidden by default but can be revealed by clicking the Show button. The parameters can also be quickly copied using the Copy button.
- The three OTAA parameters on the TTN device console are MSB by default.
- These parameters are always accessible on the device console page, as shown in Figure 50.

Upload OTAA LoRaWAN Example to RAK11162
After successfully registering the RAK11162 device to the LoRaWAN Network Server, proceed with running the LoRaWAN OTAA demo application example.
- Open the example code under RAK WisBlock RUI examples.

- In the example code, modify the device EUI (DevEUI) and application key (AppKey).
- The DevEUI must match the one registered on your network server. This is the same DevEUI in the RAK11162 sticker if this is the one you used in Step 7 of the TTN OTAA Device Registration section. DevEUI is MSB.
// OTAA Device EUI MSB
uint8_t node_device_eui[8] = {0xAC, 0x1F, 0x09, 0xFF, 0xFE, 0x03, 0xEF, 0xAB};
- Another important parameter to update is the AppKey, which must match the one configured on your network server in Step 8 of the TTN OTAA Device Registration. AppKey is an MSB.
// OTAA Application Key MSB
uint8_t node_app_key[16] = {0xD9, 0xB8, 0x70, 0x18, 0x3E, 0xF1, 0x00, 0x1D, 0x1B, 0x4F, 0x2B, 0x4C, 0xBF, 0x60, 0xCA, 0x83};

- This guide uses the EU868 regional band, so no changes are needed in the example code. For a different region, update the band in the code accordingly.
RAK11162 supports the following regions:
- RAK_REGION_EU433 = 0
- RAK_REGION_CN470 = 1
- RAK_REGION_RU864 = 2
- RAK_REGION_IN865 = 3
- RAK_REGION_EU868 = 4
- RAK_REGION_US915 = 5
- RAK_REGION_AU915 = 6
- RAK_REGION_KR920 = 7
- RAK_REGION_AS923-1 = 8
- RAK_REGION_AS923-2 = 9
- RAK_REGION_AS923-3 = 10
Additionally, for US915, configuring the channel mask is necessary, with channels 8 to 15 being the most commonly used in this band.
This is the additional code on how to do it:
if(!(ret = api.lorawan.band.set(5))) // configure to US915
{
Serial.printf("LoRaWan OTAA - set band is incorrect! \r\n");
return;
}
uint16_t maskBuff = 0x0002; // configure the mask for channels 8-15
api.lorawan.mask.set(&maskBuff);
- The last step is to upload the code by clicking the Upload icon. Take note that you should select the right board and port.
- The RAK11162 should automatically enter BOOT mode when firmware is uploaded via Arduino IDE.
- If BOOT mode is not initiated, send
AT+BOOT
manually to force BOOT mode.

The terminal logs should now be visible in the Serial Monitor of the Arduino IDE. If the COM port disconnects, the terminal output may not appear immediately. Reconnecting the module or pressing the reset button can help restore the output.

- Check the Live data section on the LoRaWAN network server to see if the device has successfully joined with the
join request
andjoin accept
logs.

TTN ABP Device Registration
- To register an ABP device, go to your application console and select the application to which you want your device to be added. Then click +Register end device, as shown in Figure 56.

- Register the board by selecting Enter end device specifics manually.

- Configure the Frequency plan, compatible LoRaWAN version, and supported Regional Parameters version.


- Click Show advanced activation, LoRaWAN class and cluster settings.

- Configure the following, then click Confirm.
- Activation mode: Activation by personalization (ABP)
- Additional LoRaWAN class capabilities: None (class A only)
- Network defaults (tick off the box): Use network's default MAC settings

- Once completed, enter the device's DevEUI credentials in the DevEUI field. Alternatively, use the Generate button to create create a DevEUI automatically.
- The DevEUI, Device address, AppKey, and NwkSKey are hidden in this section as they are unique to each device. The DevEUI is specific to every RAK11162 device, while the Device address, AppKey, and NwkSKey should be generated individually for each device and application.

- Click Generate under Device address, AppSKey, and NwkSKey, as shown in Figure 63 to Figure 65 respectively.



- Once done, click Register end device to complete the process.

After completing the device registration, the device should appear on the TTN console, as shown in Figure 67.

Upload ABP LoRaWAN Example to RAK11162
After successfully registering the RAK11162 module to the LoRaWAN Network Server as an ABP device, proceed with running the LoRaWAN ABP demo application example.
- Open the example code under RAK WisBlock RUI examples.

- In the example code, modify the device address (DEVADDR), application session key (APPSKEY), and network session key (NWKSKEY). All these parameters should match the ones generated on the LoRaWAN network server.

- This guide uses the EU868 regional band, so no changes are needed in the example code. For a different region, update the band in the code accordingly.
RAK11162 supports the following regions:
- RAK_REGION_EU433 = 0
- RAK_REGION_CN470 = 1
- RAK_REGION_RU864 = 2
- RAK_REGION_IN865 = 3
- RAK_REGION_EU868 = 4
- RAK_REGION_US915 = 5
- RAK_REGION_AU915 = 6
- RAK_REGION_KR920 = 7
- RAK_REGION_AS923-1 = 8
- RAK_REGION_AS923-2 = 9
- RAK_REGION_AS923-3 = 10
Additionally, for US915, configuring the channel mask is necessary, with channels 8 to 15 being the most commonly used in this band.
This is the additional code on how to do it.
if(!(ret = api.lorawan.band.set(5))) // configure to US915
{
Serial.printf("LoRaWan OTAA - set band is incorrect! \r\n");
return;
}
uint16_t maskBuff = 0x0002; // configure the mask for channels 8-15
api.lorawan.mask.set(&maskBuff);
- The last step is to upload the code by clicking the Upload icon. Note that you should select the right board and port, as shown in the previous example LED Blinking.
- The RAK11162 should automatically enter BOOT mode when firmware is uploaded via Arduino IDE.
- If BOOT mode is not initiated, send
AT+BOOT
manually to force BOOT mode.

The terminal logs should now be visible in the Serial Monitor of the Arduino IDE. If the COM port disconnects, the terminal output may not appear immediately. Reconnecting the module or pressing the reset button can help restore the output.

- Check the Live data section on the LoRaWAN network server if your device is able to send uplink packets.

- On ABP, frame counters for both uplink and downlink need to be tracked by the device firmware. However, on RUI3 ABP, there is no tracking, and frame counts will go back to zero when the device resets. This will result in failures on uplinks and downlinks. To prevent this issue, enable the Resets frame counters option by following these steps:
a. On The Things Network (TTN) Console and go to General settings.

b. Expand the Network Layer by clicking the Expand button.

c. Click on the Advanced MAC settings dropdown.

d. Check Resets frame counters
. With this enabled, all uplinks and downlinks will be successful even if the device resets/restarts.

Connect With ChirpStack
This section shows how to connect the RAK11162 module to the ChirpStack platform.

The ChirpStack, previously known as the LoRaServer project, provides open-source components for building LoRaWAN networks. In the case of TTN, the RAK11162 module is located in the periphery and will transmit the data to the backend servers through a LoRaWAN gateway. Learn more about ChirpStack.
In this guide, it is assumed that you are using a RAK Gateway and its built-in ChirpStack. Also, the gateway with the ChirpStack must be configured successfully. The frequency band of the nodes should be consistent with the frequency band of the gateway and ChirpStack installation.
Create a New Application on ChirpStack
- Log in to the ChirpStack server using your ChirpStack credentials.
- Navigate to the Applications section and click +CREATE to create a new application.
By default, creating a new application is recommended, but existing ones can also be reused.

Fill in the required parameters, as shown Figure 79.

- For this setup, create an Application named rak_node_test.
ChirpStack LoraServer supports multiple system configurations, with only one by default.
- Service profile: Field is to select the system profile.
- Payload codec: It is the parsing method for selecting load data, such as parsing LPP format data.

- Choose the application created in the previous step, then select the DEVICES tab, as shown in Figure 81 and Figure 82.


- Once inside the DEVICE tab, create a new device (LoRaWAN node) by clicking the +CREATE button.

- Once the node is created, fill in the necessary data. Click the icon to automatically generate a Device EUI, or manually enter the correct Device EUI in the edit box.

Fill in the parameters requested:
- Device name and Device description: These are descriptive texts about your device.
- Device EUI: This interface allows you to generate a Device EUI automatically by clicking the generate icon. A specific Device EUI can also be entered directly into the form.
- Device Profile:
- If you want to join in OTAA mode, select DeviceProfile_OTAA.
- If you want to join in ABP mode, select DeviceProfile_ABP.
- Device profiles DeviceProfile_OTAA and DeviceProfile_ABP are only available if you are using the built-in ChirpStack LoRaWAN Server of RAK Gateways.
- If you have your own ChirpStack installation, set up the device profile with
LoRaWAN MAC version 1.0.4
andLoRaWAN Regional Parameters revision B
to make it compatible with RAK11162.

ChirpStack OTAA Device Registration
- If you have selected DeviceProfile_OTAA, as shown in Figure 86, after the device is created, an Application Key must be created for this device.

- A previously created Application Key can be entered here, or a new one can be generated automatically by clicking the icon highlighted in red in Figure 87.

- Once the Application Key is added to the form, the process can be finalized by clicking the SET DEVICE-KEYS button.
- As shown in Figure 88, a new device should be listed in the DEVICES tab. The most important parameters, such as the Device EUI, are shown in the summary.

- To end the process, it is a good practice to review that the Application Key is properly associated with this device. The Application Key can be verified in the KEYS (OTAA) tab, as shown in Figure 89.

- After registering the RAK11162 in ChirpStack as an OTAA device, create a custom firmware using the Arduino IDE for the RAK11162 or use OTAA AT Commands with an external MCU host.
Standard OTAA mode requires the Device EUI, Application Key, and Application EUI, but in ChirpStack’s implementation, only the Device EUI and the Application Key are mandatory. The Application EUI is not required and is not recorded in the Application tab. However, the Device EUI can be reused as the Application EUI when configuring the node.
ChirpStack ABP Device Registration
- When registering a new device, selecting DeviceProfile_ABP, as shown in Figure 90, signals to the ChirpStack platform that the device will join the LoRaWAN network using ABP mode.
Tick Disable counting frame verification to prevent synchronization issues during testing. When the module restarts, the frame counter resets to zero, which ChirpStack may interpret as a replay attack. While disabling this feature is safe for testing, ensure it is enabled in production. Note that in RAK11162, the frame counter resets upon reboot.

- After selecting the ABP mode, the following parameters will appear under the ACTIVATION tab:
- Device Address
- Network Session Key
- Application Session Key

- The parameters can be generated as random numbers by the platform or can be set with user values. Once these parameters are filled in properly, the process is completed by clicking on the ACTIVATE DEVICE button.
- After registering the RAK11162 in ChirpStack as an ABP device, create a custom firmware using Arduino IDE for RAK11162 or use ABP AT Commands with external MCU host.
Wi-Fi Example With RUI3 API
The RUI3 BSP does not include an example for the usage of Wi-Fi on the RAK11162. This simple example code shows how to connect to an Wi-Fi AP in station mode.
For easier understanding, the code is split here into several parts.
- Testing the connection to ESP8684 by powering up the ESP8684 and check the response received.
The ESP8684 can be forced into low power mode by controlling the PA0 GPIO of the STM32WLE5. If set to low, the ESP8684 is shut down, if set to high, the ESP8684 is powering up.
Connection to the ESP8684 is done by sending an
AT
to it through Serial1 of the STM32WLE5 and wait for the response, which should includeOK
.
AT
OK
Click to view the example code.
// Initialize interface to ESP8684
Serial1.begin(115200);
// Enable ESP8684
pinMode(WB_ESP8684, OUTPUT);
digitalWrite(WB_ESP8684, HIGH);
// Wait for ESP8684 bootup
bool found_esp8684 = false;
time_t start = millis();
while ((millis() - start) < 30000)
{
Serial1.println("AT");
Serial1.flush();
if (wait_ok_response(10000))
{
Serial.println("ESP8684 found");
found_esp8684 = true;
break;
}
delay(500);
}
- Set the ESP8684 into Wi-Fi station mode to be able to connect to a Wi-Fi AP.
AT+CWMODE=1,1
OK
Click to view the example code.
// Set ESP8684 into station mode and enable auto connect AT+CWMODE=1,1
// Clear send buffer
memset(wrx_buf, 0, 512);
snprintf(wrx_buf, 511, "AT+CWMODE=1,1\r\n");
Serial1.printf("%s", wrx_buf);
Serial1.flush();
if (wait_ok_response(10000))
{
Serial.printf("\r\nESP8684 mode set: ==>%s<==\r\n", wtx_buf);
}
else
{
Serial.printf("\r\nESP8684 mode failed: ==>%s<==\r\n", wtx_buf);
}
- Request connection to the selected Wi-Fi AP
AT+cwjap="<MQTT_WIFI_APN>","<MQTT_WIFI_PW>"
WIFI DISCONNECT
WIFI CONNECTED
WIFI GOT IP
OK
Click to view the example code.
// Connect ESP8684 to Wi-Fi AP
// Clear send buffer
memset(wrx_buf, 0, 512);
snprintf(wrx_buf, 511, "AT+CWJAP=\"%s\",\"%s\"\r\n", MQTT_WIFI_APN, MQTT_WIFI_PW);
Serial1.printf("%s", wrx_buf);
Serial1.flush();
/** Expected response ********************
AT+cwjap="<MQTT_WIFI_APN>","<MQTT_WIFI_PW>"
WIFI DISCONNECT
WIFI CONNECTED
WIFI GOT IP
OK
*****************************************/
if (wait_ok_response(10000))
{
Serial.printf("\r\nESP8684 connected: ==>%s<==\r\n", wtx_buf);
}
else
{
Serial.printf("\r\nESP8684 not connected: ==>%s<==\r\n", wtx_buf);
}
Here is the complete example code:
Click to view the example code.
#include <Arduino.h>
// Define enable pin for ESP8684
#define WB_ESP8684 PA0
/** Wi-Fi TX buffer */
char wtx_buf[512];
/** Wi-Fi RX buffer */
char wrx_buf[512];
/** Wi-Fi AP name */
char MQTT_WIFI_APN[32] = "RAKwireless";
/** Wi-Fi AP password */
char MQTT_WIFI_PW[32] = "RAKwireless";
/**
* @brief Wait for response from ESP8684
*
* @param timeout time to wait in milliseconds
* @param wait_for character array to wait for
* @return true "OK" string received
* @return false "OK" string not received, timeout
*/
bool wait_ok_response(time_t timeout)
{
time_t start = millis();
int buff_idx = 0;
bool got_ok = false;
// Clear TX buffer
memset(wtx_buf, 0, 512);
while ((millis() - start) < timeout)
{
if (Serial1.available() != 0)
{
char rcvd = Serial1.read();
wtx_buf[buff_idx] = rcvd;
buff_idx++;
if (buff_idx == 512)
{
// Buffer overflow, return false
return false;
}
if (strstr(wtx_buf, "OK") != NULL)
{
return true;
}
}
delay(5);
}
return false;
}
/**
* @brief Arduino setup function, called once
*
*/
void setup(void)
{
// Start Serial
Serial.begin(115200);
// Delay for 5 seconds to give the chance for AT+BOOT
delay(5000);
api.system.firmwareVersion.set("RAK11160-WIFI");
Serial.println("RAK11160 Wi-Fi");
Serial.println("---------------------------------------------------------------");
Serial.println("Setup the device with WisToolBox or AT commands before using it");
Serial.println("---------------------------------------------------------------");
// Initialize interface to ESP8684
Serial1.begin(115200);
// Enable ESP8684
pinMode(WB_ESP8684, OUTPUT);
digitalWrite(WB_ESP8684, HIGH);
// Wait for ESP8684 bootup
bool found_esp8684 = false;
time_t start = millis();
while ((millis() - start) < 30000)
{
Serial1.println("AT");
Serial1.flush();
/** Expected response ********************
AT
OK
*****************************************/
if (wait_ok_response(10000))
{
Serial.println("ESP8684 found");
found_esp8684 = true;
break;
}
delay(500);
}
// Set ESP8684 into station mode and enable auto connect AT+CWMODE=1,1
// Clear send buffer
memset(wrx_buf, 0, 512);
snprintf(wrx_buf, 511, "AT+CWMODE=1,1\r\n");
Serial1.printf("%s", wrx_buf);
Serial1.flush();
/** Expected response ********************
AT+CWMODE=1,1
OK
*****************************************/
if (wait_ok_response(10000))
{
Serial.printf("\r\nESP8684 mode set: ==>%s<==\r\n", wtx_buf);
}
else
{
Serial.printf("\r\nESP8684 mode failed: ==>%s<==\r\n", wtx_buf);
}
// Connect ESP8684 to Wi-Fi AP
// Clear send buffer
memset(wrx_buf, 0, 512);
snprintf(wrx_buf, 511, "AT+CWJAP=\"%s\",\"%s\"\r\n", MQTT_WIFI_APN, MQTT_WIFI_PW);
Serial1.printf("%s", wrx_buf);
Serial1.flush();
/** Expected response ********************
AT+cwjap="<MQTT_WIFI_APN>","<MQTT_WIFI_PW>"
WIFI DISCONNECT
WIFI CONNECTED
WIFI GOT IP
OK
*****************************************/
if (wait_ok_response(10000))
{
Serial.printf("\r\nESP8684 connected: ==>%s<==\r\n", wtx_buf);
}
else
{
Serial.printf("\r\nESP8684 not connected: ==>%s<==\r\n", wtx_buf);
}
}
/**
* @brief Arduino loop. Not used
*
*/
void loop(void)
{
api.system.sleep.all();
}
There are many options to setup the ESP8684, only the basic commands are shown here. For a full description how to control the ESP8684, check the Espressif AT command manual.
More examples for the RAK11162 can be found in the RUI3-Best-Practices on GitHub. A more functional example that uses the RAK11162 as a gateway between LoRa P2P devices and an MQTT server can be found in the RUI3-Best-Practices
Miscellaneous
Upgrade the Firmware
To upgrade the module to the latest firmware version, follow the steps in this section. The latest firmware can be found in the software section of RAK11162 Datasheet.
What if the RAK11160 module stops responding to AT commands and firmware updates?
To recover your device, use the .hex
file found in the datasheet and upload it using STM32CubeProgrammer. The guide on updating STM32 firmware using STM32CubeProgrammer can be found on RAK Learn site:
Uploading the .hex file via STM32CubeProgrammer will erase all configured data on the device.
Firmware Upgrade Through UART2
Minimum Hardware and Software Requirements
Refer to the table for the minimum hardware and software required to perform the firmware upgrade via UART2:
Hardware/Software | Requirement |
---|---|
Computer | A Windows/Ubuntu/Mac computer |
Firmware File | Bin firmware file downloaded from the website |
Others | A USB to TTL module |
Firmware Upgrade Procedure
Execute the following procedure to upgrade the firmware in Device Firmware Upgrade (DFU) mode through the UART2 interface.
- The RAK11162 should automatically enter BOOT mode when firmware is uploaded via RAK DFU Tool or WisToolBox.
- If BOOT mode is not initiated, manually send
AT+BOOT
command to start bootloader mode.
-
Download the latest application firmware of the RAK11160.
Refer to the table below:
Model | Version | Source |
---|---|---|
RAK11160 (.bin) | RUI3 Application Code only (default baudrate = 115200) | Download |
RAK11160 (.hex) | RUI3 Bootloader and Application Code (default baudrate = 115200) | Download |
-
Download the RAK Device Firmware Upgrade (DFU) tool.
-
Connect the RAK11162 module with a computer through a USB to TTL.
-
Open the RAK Device Firmware Upgrade Tool. Select the serial port and baud rate (115200) of the module and click the Select Port button.
- If the firmware upload repeatedly fails, check your current baud rate setting using the
AT+BAUD=?
command and use that baud rate value in the RAK DFU Tool. - Another option is to check if you selected the right COM port.

- Select the application firmware file of the module with the suffix .bin.

- Click the Upgrade button to upgrade the device. After the upgrade is complete, the RAK11162 will be ready to work with the new firmware.


Arduino Installation
Refer to Software section.