RAK3372 WisBlock LPWAN Module Quick Start Guide
This quick start guide shows how can you use the RAK3372 as a WisBlock Core module. It is a step-by-step guide on how to prepare your hardware as well as how to set up the needed software.
There are more features and applications possible for RAK3372 WisBlock Core but this guide only demonstrates LED Breathing and LoRaWAN OTAA example.
Following this guide successfully ensures that you have a working RAK3372 WisBlock Core.
This guide also includes instructions on how to perform firmware update.
Prerequisite
Package Inclusions
Before going through each step in the installation guide of the RAK3372 WisBlock Core Module, make sure to prepare the necessary items listed below:
Hardware
- RAK3372 WisBlock Core
- Your choice of WisBlock Base
- USB Cable
- Li-Ion/LiPo battery (optional)
- Solar charger (optional)
Software
Arduino IDE
- 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 RAK3172 as a supported board in Arduino IDE by updating Board Manager URLs in Preferences settings of Arduino IDE with the JSON URL below.
https://raw.githubusercontent.com/RAKWireless/RAKwireless-Arduino-BSP-Index/main/package_rakwireless.com_rui_index.json
After that, you can then add RAKwireless RUI STM32 Boards via Arduino board manager.
Product Configuration
Hardware Setup
Your RAK3372 will not work on its own. It needs at least to be connected to a WisBlock Base together with an antenna. You can then interface various WisBlock Modules via the available slots in the WisBlock Base. You can also add a battery as a power source and optional solar charging. All hardware-related configurations for your RAK3372 are discussed here.
This section covers:
- RAK3372 Connection to Base Board
- Assembling and Disassembling of WisBlock Modules
- Antenna and Battery/Solar Connection
RAK3372 to WisBlock Base
The RAK3372 will not work without a WisBlock Base board. The WisBlock Base provides a USB connection for programming the RAK3372. It also provides a power source and various interfaces to RAK3372 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 to look at these WisBlock Base boards to see what matches your requirements in terms of available module slots, power supply options, and overall size.
- RAK3372 WB_IO3 (WisBlock IO Pin 3) is connected to PB12 of the RAK3172 module. This pin is internally connected to a 10k resistor as mentioned on the pin definition table of the RAK3172 datasheet. Other WisBlock modules that use this pin will have possible conflict.
To illustrate, RAK3372 can be connected to RAK19007 WisBlock Base, as shown in Figure 1.
Some 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.
Each WisBlock Base board has its own set of header pins available for you to use. However, these header pins are not exactly the same in each WisBlock Base. It is common to see IO pins and communication protocol pins like I2C and UART in the WisBlock Base board. More information can be found on the official documentation of the specific WisBlock Base you used in your project.
You can access the AT command via UART2 by default (and also possible via UART1). Firmware update is only possible via UART2. A built-in USB-Serial converter is on the board to easily connect the RAK3372 to the USB port of the PC.
There are useable LEDs as well in the WisBlock Base. You can control them in your code via the GREEN_LED
and BLUE_RED
macro.
Assembling and Disassembling of WisBlock Modules
Assembling
Figure 3 shows how to mount the RAK3372 module on top of a WisBlock Base board (RAK19007). Follow carefully the procedure defined in WisBlock module assembly/disassembly instructions 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 6, to detach the module from the baseboard.
LoRa Antenna
Another important component of RAK3372 is the antenna.
You need to ensure that it is properly connected to have a good LoRa 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.
Detailed information about the RAK3372 LoRa PCB antenna can be found on the antenna datasheet. Keep in mind that the PCB antenna is intended ideally only for prototyping and device evaluation. For enterprise deployments, it is advisable to consider a better antenna for reliable performance.
- When using the LoRa transceiver, make sure that it is connected to an antenna. Using the transceiver chip without an antenna can damage the system.
- Make sure to fix the module with screws to ensure proper function.
Battery and Solar Connection
RAK3372 can be powered via the USB cable or Li-Ion/LiPo battery via the dedicated connectors, as shown in Figure 9. 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 baseboard. Not all batteries have the same wiring.
The battery can be recharged, as well, via a small solar panel, as shown in Figure 10. The matching connector for the solar panel wires is an JST ZHR-2 1.5 mm pitch female.
Specifications of the battery and solar panel can be found on the datasheet of the WisBlock Base.
Software Initial Guide
Software Setup
The default firmware of RAK3372 is based on RUI3, which allows you to develop your custom firmware to connect sensors and other peripherals to it. To develop your custom firmware using Arduino IDE, you need first to add RAKwireless RUI STM32 Boards in the Arduino board manager, which will be discussed in this guide. You can then use RUI3 APIs for your intended application. You can upload the custom firmware via UART. The AT commands of RAK3372 is still available even if you compile custom firmware via RUI3. You can send AT commands via UART2 connection.
RAK3372 RUI3 Board Support Package in Arduino IDE
If you don't have an Arduino IDE yet, you can download it from the Arduino official website and follow the installation procedure depending on your machine.
For Windows 10 and up users: If your Arduino IDE is installed from the Microsoft App Store, you need to reinstall your Arduino IDE by getting it from the Arduino official website. The Arduino app from the Microsoft App Store has problems using third-party Board Support Packages.
Once the Arduino IDE has been installed successfully, you can now configure the IDE to add the RAK3372 to its board selection by following these steps.
- Open Arduino IDE and go to File > Preferences.
- To add the RAK3372 to your Arduino Boards list, edit the Additional Board Manager URLs. Click the icon, as shown in Figure 12.
- Copy the URL below and paste it on the field, as shown in Figure 13. If there are other URLs already there, just add them on the next line. After adding the URL, click OK.
https://raw.githubusercontent.com/RAKWireless/RAKwireless-Arduino-BSP-Index/main/package_rakwireless.com_rui_index.json
-
Restart the Arduino IDE.
-
Open the Boards Manager from Tools Menu.
-
Write
RAK
in the search bar, as shown in Figure 15. This will show the available RAKwireless module boards that you can add to your Arduino Board list. -
Click on the area highlighted in blue to select RAKwireless RUI STM32 Boards. Install the latest version of the RAKwireless RUI STM32 Boards by clicking the Install button.
Configure RAK3372 on Boards Manager
- Once the BSP is installed, select Tools > Boards Manager > RAKWireless RUI STM32 Modules > WisDuo RAK3172 Evaluation Board. The RAK3372 WisBlock Core uses the RAK3172 WisDuo module, so you must select that board as shown in Figure 16.
RAK3372 COM Port on Device Manager
Connect the RAK3372 via UART and check RAK3372 COM Port using Windows Device Manager.
Compile an Example with Arduino LED Breathing
-
After completing the steps on adding your RAK3372 WisBlock Core to the Arduino IDE, you can now try to run a simple program to test your setup. There is a built-in LED in the WisBlock Base board that you can control via RUI3 custom firmware.
-
Launch Arduino IDE and configure WisDuo RAK3172 Evaluation Board on board selection. See Figure 16.
-
Connect the RAK3372 via UART and check RAK3372 COM Port. See Figure 17.
-
Open the Tools Menu and select a COM port. COM28 is currently used. COM port number varies depending on the PC.
- You can now see the serial monitor icon and click it to connect the COM port.
- If the connection is successful, you can send AT Commands to RAK3372. For example: To check the RUI version, type
AT+VER=?
on the text area, then click on the Send button, as shown in Figure 20. If there is no reply, make sure you have selected the right COM port or double-check the USB connection.
- Open Arduino_Led_Breathing example code.
- Click on the Verify icon to check if you have successfully compiled the example code.
- Click the Upload icon to send the compiled firmware to your RAK3372 WisBlock Core module.
RAK3172 module in the WisBlock Core should automatically go to BOOT mode when the firmware is uploaded via Arduino IDE.
- If the upload is successful, you will see the Upgrade Complete message.
- After the Device Programmed is completed, you will see that LEDs are blinking.
LoRaWAN Example
This example illustrates how to program RAK3372 WisBlock Core as a stand-alone LoRaWAN end-device via RUI3 Arduino APIs. To use the RAK3372 WisBlock Core module as a LoRaWAN end-device, it needs to 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:
- LoRaWAN 101
- What is a LoRaWAN Gateway
- How do LoRaWAN Gateways work?
- Things to Consider When Picking A LoRaWAN Gateway
RAKwireless LoRaWAN gateway models like WisGate Edge have built-in network servers. It is also common that the LoRaWAN network server is external or in the cloud. The popular LoRaWAN network server in the cloud that you can use for free (but offers enterprise service, too) is TTN.
To correctly run this example, it is necessary to configure the LoRaWAN parameters and create an OTAA application on your LoRaWAN gateway.
Register the LoRaWAN Gateway on TTNv3 Community Edition
After configuring your gateway, you need to register it in TTNv3:
- Log in to the TTNv3 Network Server with a web browser.
- Navigate to the Console page and click on gateway icon, as shown in Figure 25.
- On General Settings, enter the Gateway ID, Gateway EUI, and Gateway Name. This information is available in your LoRaWAN gateway configuration. Select the Gateway Server address according to the region where the LoRaWAN gateway will be installed.
- Select the Frequency plan for your region (used by TTN), then click on the Create gateway button. This will add a new gateway to TTNv3.
Creating LoRaWAN Applications in TTN
- The first step is to go to The Things Network platform and select a cluster, as shown in Figure 28.
You can use the same login credentials on the TTN V2 if you have one. If you have no account yet, you need to create one.
- To register as a new user to TTN, click on Login with The Things ID then select register on the next page, as shown in Figure 29 and Figure 30.
-
You should now be on the step of creating your TTN account. Fill in all the necessary details and activate your account.
-
After creating an account, you should log in on the platform using your username/email and password then click Submit, as shown in Figure 31.
- Click Authorize to proceed.
- Now that you are logged in to the platform, the next step is to create an application. Click Create an application.
- To have an application registered, you need to input first the specific details and necessary information about your application then click Create application.
- If you had no error during the previous step, you should now be on the application console page. The next step is to add end-devices to your TTN application. LoRaWAN specification enforces that each end-device has to be personalized and activated. There are two options for registering devices depending on the activation mode you select. Activation can be done either via Over-The-Air-Activation (OTAA) or Activation-By-Personalization (ABP). This guide will show OTAA.
TTN OTAA Device Registration
- Go to your application console to be able to register a device. To start adding an OTAA end-device, click + Add end device, as shown in Figure 35.
- To register the module, click first Manually then configure the activation method by selecting Over the air activation (OTAA) and compatible LoRaWAN version then click the Start button, as shown in Figure 36 and Figure 37.
- Then you need to put a unique End device ID and EUIs (DevEUI and AppEUI), as shown in Figure 38. Check if your module has a DevEUI on the sticker or QR that you can scan then use this as the device unique DevEUI.
Optionally, you can add a more descriptive End device name and End device description about your device.
- After filling in all the details, click Network layer settings to proceed to the next step.
It is advisable to use a meaningful end-device ID, end-device name, and end-device description that will match your device's purpose. The end-device ID rak-device
is for illustration purposes only.
- The next step is to set up the Frequency plan, a compatible Regional Parameter version, and the LoRaWAN class supported. Then you can click Join settings.
- The last step in the registration of a new OTAA end-device is the configuration of the AppKey. To get the AppKey, you must click the generate button. Then click Add end device to finish your new device registration.
You should now be able to see the device on the TTN console after you fully register your device, as shown in Figure 41.
- The AppEUI, DevEUI, and AppKey are the parameters that you will need to activate your LoRaWAN end-device via OTAA. The AppKey is hidden by default for security reasons, but you can easily show it by clicking the show button. You can also copy the parameters quickly 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.
Uploading LoRaWAN Example to RAK3372
After a successful registration of the RAK3372 device on the LNS, you can now proceed with running the LoRaWAN OTAA demo application example.
- Launch the Arduino IDE and configure WisDuo RAK3172 Evaluation Board on board selection. See Figure 16.
- Connect the RAK3372 via UART and check RAK3372 COM Port. See Figure 17.
- Open the example code under RAK WisBlock RUI examples: File -> Examples -> RAK WisBlock RUI examples -> Example -> LoRaWan_OTAA.
- In the example code, you need to modify the device EUI OTAA_DEVEUI, the application EUI OTAA_APPEUI, and the application key OTAA_APPKEY.
- The OTAA_DEVEUI parameter should match the device EUI registered in your network server. Note that your RAK3372 module has a sticker with a QR code printed on it. You can use the QR code information to configure the OTAA_DEVEUI parameter. The OTAA_DEVEUI format is MSB first.
// OTAA Device EUI MSB
#define OTAA_DEVEUI {0x11, 0x33, 0x55, 0x77, 0x99, 0x22, 0x44, 0x66}
- The OTAA_APPEUI parameter. This parameter should also be the same as the APPEUI in the network server you configured.
// OTAA Application EUI MSB
#define OTAA_APPEUI {0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09}
- Another important parameter to change is the application key OTAA_APPKEY. This parameter should also be the same as the APPKEY in the network server you configured. The OTAA_APPKEY format is MSB first.
// OTAA Application Key MSB
#define OTAA_APPKEY {0x04, 0xFA, 0x4E, 0x62, 0x6E, 0xF5, 0xCF, 0x22, 0x7C, 0x96, 0x96, 0x01, 0x17, 0x62, 0x75, 0xC2}
- Depending on the Regional Band you selected, you might need to configure the sub-band of your RAK module to match the gateway and LoRaWAN network server. This is especially important for Regional Bands like US915, AU915, and CN470.
This guide uses EU868. However, if you use other regional bands, you need to update the band and possibly the channels. For example, if you use US915 and AU915, you also need to set up the channel mask using the mask.set
API. Channels 8 to 15 are the most commonly used channels in the US915 and AU915 bands which corresponds to a mask equal to two.
Here's example on using US915 with OTAA_BAND equal to 5:
if (!api.lorawan.band.set(OTAA_BAND)) {
Serial.printf("LoRaWan OTAA - set band is incorrect! \r\n");
return;
}
uint16_t maskBuff = 0x0002;
if (!api.lorawan.mask.set(&maskBuff)) {
Serial.printf("LoRaWan OTAA - set mask is incorrect! \r\n");
return;
}
RAK3372 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 = 8
- RAK_REGION_AS923-2 = 9
- RAK_REGION_AS923-3 = 10
- RAK_REGION_AS923-4 = 11
- Make sure you have configured the correct RAK board before uploading the code. See Configure RAK3372 on Boards Manager section.
- Also, check RAK3372 COM Port on Device Manager section.
- Open the Tools Menu and select a COM port. COM28 is currently used.
- The last step is to upload the code by clicking the Upload icon on Arduino IDE. Take note that you should select the right board and COM port.
- You should now be able to see the console logs using the serial monitor of Arduino IDE. Sometimes COM port will be disconnected, so you won't be able to see the terminal output immediately. You can reconnect the module or try to push the reset button to see the terminal output.
- Check on the LoRaWAN network TTN console logs if your device has been successfully joined with the
join-request
andjoin-accept
messages.
Miscellaneous
Upgrading the Firmware
If you want to upgrade to the latest version of the firmware of the module, you can follow this section. The latest firmware can be found in the software section of RAK3172 Datasheet.
What if the RAK3372 WisBlock Core module stops responding to AT commands and/or firmware updates?
You can recover your device by using the .hex
file in the datasheet and uploading it using STM32CubeProgrammer. The guide on updating STM32 firmware using STM32CubeProgrammer can be found in the Learn section.
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.
RAK3172 should automatically go to BOOT mode when the firmware is uploaded via RAK DFU Tool or WisToolBox.
-
Download the latest application firmware of the RAK3172.
-
Download the RAK Device Firmware Upgrade (DFU) tool.
-
Connect the RAK3372 module with a computer through a USB to TTL.
-
Open the Device Firmware Upgrade tool. Select the serial port and baud rate (115200) of the module and click the Select Port button.
If your firmware upload always fails, check your current baud rate setting using the AT+BAUD=?
command and use that baud rate value in the RAK DFU Tool. You can also 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 RAK3372 will be ready to work with the new firmware.