Overview
This guide is about learning how to set up a complete LoRaWAN application from device, gateway up to network server. It composes of the following sections:
- Setting Up the Gateway
- Setting Up the Network Server
- Setting Up the Device
- Setting Up IoT Dashboard Using Ubidots
Setting Up the Gateway
Configuring the RAK7246 WisGate Developer D0
This section will guide you on how to set up and configure your gateway.
đź“ť NOTE: If you are new to LoRaWAN, here are a few good references about LoRaWAN and gateways: |
Here are the steps in configuring the RAK7246 WisGate Developer D0:
By default, the gateway will work in Wi-Fi AP Mode, which means that you can find an SSID named "Rakwireless_XXXX" on your PC Wi-Fi network list.
📝 NOTE: “XXXX” is the last 2 bytes of your RAK7246 WiFi MAC address. Connect to this Wi-Fi SSID using the password provided below. Also, the default IP address of the gateway provided below will be needed in connecting via SSH.
|
Log into the gateway.
-
- Windows OS SSH (Secure Shell) is typically used to log in to a remote machine and execute commands. There are a lot of free and good SSH Clients out there, namely Putty, BitVise SSH Client, MobaXterm and many more. Feel free to choose one that fits your needs, but in this guide, Putty is used.
- Windows OS SSH (Secure Shell) is typically used to log in to a remote machine and execute commands. There are a lot of free and good SSH Clients out there, namely Putty, BitVise SSH Client, MobaXterm and many more. Feel free to choose one that fits your needs, but in this guide, Putty is used.
- Mac OS Open the Terminal of Mac OS. Launch the Terminal application found in the
/Applications/Utilities/
directory, but you can also launch it from Spotlight. Press Command + Spacebar and type “Terminal”, then return.
If you have connected to the gateway through Wi-Fi AP Mode, the IP Address is 192.168.230.1. It will then prompt you to enter the username and password. Enter the default credentials:
-
- Username: pi
- Password: raspberry
From the previous step, get the Gateway ID by typing sudo gateway-config
to your chosen SSH Client terminal editor. It can be found on top of the terminal console, as shown in the red box in Figure 5. You may copy it on a txt file or any notepad software. It will be used in setting up the gateway in TTN V3. See Figure 5 for reference. You will use it also as Gateway EUI in the latter part of this guide. In this example, the Gateway ID is B827EBFFFE81.
đź“ť NOTE: In this guide, you will be using TTN (The Things Network) as the LNS (LoRaWAN Network Server). There are many other LNS available that you can use, as well. The configuration steps will be different depending on your chosen LNS, but the general LoRaWAN principle is the same. Like for RAK WisGate Edge Gateways, it has built-in LNS that you can use. |
You can now connect your gateway through Wi-Fi to access TTN. It can easily be done with the wireless capabilities of the Raspberry Pi Zero W by choosing "5 Configure WIFI". By default, the RAK7246 WisGate Developer D0 Gateway works in Wi-Fi AP Mode. For the gateway to connect to the router, it must work in Wi-Fi Client Mode.
There are 5 options to choose from in the Wi-Fi configuration menu:
- Enable AP Mode/Disable Client Mode - the gateway will work in Wi-Fi Access Point Mode after rebooting, while the Wi-Fi Client Mode will be disabled (this is the default mode).
- Enable Client Mode/Disable AP Mode - the gateway will work in Wi-Fi Client mode after rebooting, while Wi-FI AP Mode will be disabled.
- Modify SSID and pwd for AP Mode - used to modify the SSID and password of the Wi-Fi AP. Only works if the Wi-Fi AP Mode is enabled.
- Add New SSID for Client - this is used if you want to connect to a new Wi-Fi network. Only works in Wi-Fi Client mode.
- Change Wi-Fi Country - this is used to modify the Resident Country to match Wi-Fi standards.
đź“ť NOTE: To enable Wi-Fi Client Mode, you have to disable first the Wi-Fi AP Mode. |
Once Wi-Fi AP Mode has been disabled by choosing "2 Enable Client Mode/Disable AP Mode", you can now then connect to a new Wi-Fi Network by choosing "4 Add New SSID for Client".
- Start by selecting your country of residence.
- Enter the SSID of the network you want to connect.
đź“ť NOTE: Ensure to input the correct Wi-Fi SSID and password, or you will not be able to connect to the RAK7246 again via SSH in Wi-Fi AP Mode. If stuck in this situation, follow the Optional Configurations procedure listed in the Accessing the Internet, which is applicable for all Raspberry Pi-based gateways to work again in Wi-Fi AP mode. |
- Enter the SSID of the network you want to connect.
- Lastly, reboot the gateway using the command sudo reboot in the command line, and it will connect to the router successfully.
sudo reboot
After rebooting the RAK7246 WisGate Developer D0, you should check if it is connected successfully to your Wi-Fi network. You may use your local network modem/router admin console to check if RAK7246 is successfully connected.
In this example, the admin console can be accessed via http://192.168.0.1
. It is also common to have it on http://192.168.1.1
on some routers. Take note of the IP address allotted to the RAK7246 by your Wi-Fi network.
You can also use Advance IP Scanner for Windows OS, or Angry IP Scanner for Mac OS, and locate the IP address of RAK7246 WisGate Developer D0 in your Wi-Fi device.
As seen in Figure 12, it is 192.168.0.28
, where the company is Raspberry Pi Foundation. You can use that IP address to configure other related parameters of RAK7246 WisGate Developer D0
by logging in to the SSH Client Software, as stated in the previous step, now with the IP address of RAK7246 WisGate Developer D0
from your Wi-Fi network.
đź“ť NOTE:
|
To link your gateway to TTN, you need to set up first the RAK Gateway LoRa by choosing "2 Setup RAK Gateway LoRa concentrator".
Then, you need to select Server is TTN as the LoRaWAN server and select the right frequency that will match your gateway and region. The supported frequency plan of TTN can be found on their website.
For this example, you will be using EU868 Frequency Plan. Choose “4 EU_863_870”.
After choosing the correct frequency, the success message will appear, as shown in Figure 16.
You need to check if the right SERVER_ADDRESS is used to connect to TTN V3. To do this, choose “4 Edit packet-forwarder config” from the configuration options.
You will be editing a JSON file to configure the server_address to eu1.cloud.thethings.network. To save the changes you made, if there is any, press CTRL + X
to exit the editor and select yes to confirm the changes.
đź“ť NOTE:
There are three server clusters available for TTN V3. In this guide, you will use The available TTN V3 clusters are:
|
Restart the Packet-forwarder by choosing “3 Restart Packet-forwarder” from the configuration options.
Setting Up the Network Server
Connect RAK7246 WisGate Developer D0 to TTNv3
This section shows how to connect RAK7246 WisGate Developer D0 to TTNv3.
Create a TTN account if you don't have one yet.
Make sure you are in the right TTN cluster, and then log in to TTN. Use your The Things ID credentials to log in.
After you have logged in, you need to register your gateway to TTNv3. To register, choose Go to gateways. If you have already registered your gateways before, head on to Gateways > + Add gateway.
Fill in the needed information:
- Owner – Automatically filled by The Things Stack, based on your account or created Organization. (e.g. rak-discovery)
- Gateway ID – This will be the unique ID of your gateway in the Network. ID must contain only lowercase letters, numbers, and dashes (-). (e.g. rak-d0-ph-las-pinas)
- Gateway EUI - A 64 bit extended unique identifier for your gateway. This is where the Gateway you get on step 4 of Configuring the RAK7246 WisGate Developer D0 above. (e.g. B827EBFFFE81)
- Gateway name – A name for your gateway. (e.g. RAK D0 Pilar Las Pinas PH)
- Gateway description (optional) - Optional gateway description; can also be used to save notes about the gateway.
- Gateway Server address - The address of the Gateway Server to connect to (i.e. eu1.cloud.thethings.network).
- Frequency plan - The frequency plan used by the gateway.
đź“ť NOTE:
|
To register your gateway, scroll down and click Create gateway.
Gateway is now registered to TTN V3. Click Live data to check if the gateway already working.
Creating a LoRaWAN Application in TTN
This section will guide you on how to set up using The Things Stack Community Edition.
Go to the TTN website.
Go to CONSOLE, then choose Europe 1.
After choosing Europe 1, click on Create an application.
Add the WisBlock Kit 2 by clicking the Create application.
Click End devices, then Add end device.
Choose Manually to register the end device. Fill in the required details and click Register end device.
In the End devices tab, click General settings, then fill in the End device name and End device description. After that, press Save changes.
Then, click on Payload formatters > Uplink > Formatter type and choose Javascript.
Delete the default code of the Formatter parameter field. Copy and paste the code below, and click Save changes.
function Decoder(bytes, port)
{
var decoded = {};
if (port== 2)
{
var temp = ((bytes[1]) << 8) | (bytes[2]);
temp = (temp/100.0);
decoded.temp = temp;
var hum = ((bytes[3]) << 8) | (bytes[4]);
hum = (hum/100.0);
decoded.hum = hum;
var press = (bytes[5] << 24) | (bytes[6] << 16) | (bytes[7] << 8) | (bytes[8]);
press = (press / 100.0);
decoded.press = press;
var light = ((bytes[9]) << 8) | (bytes[10]);
light = (light / 100.0);
decoded.light = light;
return decoded;
}
}
After doing all the steps, set up first your Lora device so that it can send data to your The Things Stack account.
Setting Up the Device
This section will guide you on how to set up your device.
Download the Arduino IDE, then install it on your PC or laptop.
⚠️ WARNING: If you are using Windows 10: Do NOT install the Arduino IDE from the Microsoft App Store. 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. |
Open the Arduino IDE, then install the RAKwireless BSP support for the Arduino Board Manager.
Click on File -> Preferences. In the Preferences window, look for Additional Boards Manager URLs, then click the icon on the right side.
Copy https://raw.githubusercontent.com/RAKwireless/RAKwireless-Arduino-BSP-Index/main/package_rakwireless_index.json
and paste it into the new window, then click OK > OK.
Go to Tools > Board: "Arduino Uno" > Boards Manager. Type RAK in the search bar, and the RAKwireless Core modules will be shown in the window.
Choose RAKwireless nRF Boards, then click Install. After installing the RAK4631 Arduino BSP (Board Support Package), click Close.
After the installation of the RAKwireless nRF Boards core module, copy the code in the GitHub repo, and paste it to the Arduino IDE. Save this file as "Weather_Monitoring.ino".
Install all the libraries needed by the WisBlock Kit 2, as shown in Figure 57. Just click the links in the sketch, then install them one by one.
After all the libraries are installed, go to Tools > Board: “Arduino Uno” > RAKwireless nRF Modules > WisBlock RAK4631.
Compile the "Weather_Monitoring.ino" by pressing the check button in the Arduino IDE. Wait after the code compiled is successful, and the Done compiling status appears.
After a successful compilation, assemble the hardware of WisBlock Kit 2. All parts are shown in Figure 69. All details about WisBlock Kit 2 can be found on the GitHub Repo.
- Connect the RAK4631 in the CPU SLOT of the RAK5005-O.
- Next, attach the following WisBlock to their corresponding slots:
- RAK1901 to the SLOT A
- RAK1903 to the SLOT B
Finally, place the RAK1902 to the SLOT D. Screw all the edges so that the connection is firm and tight to avoid a loose connection.
Attached also are the LORA and BLE antennas to the RAK4631 LPWAN CPU.
⚠️ WARNING: Make sure to attach the antennas first before powering on the WisBlock Kit 2 to avoid damaging the Weather Monitoring kit. |
Go back to your The Things Stack account. Go to Applications > Wisblock Kit2 Weather Monitoring > End devices > Wisblock kit2 weather monitoring.
Copy the AppEUI, DevEUI, and AppKey, then paste them into any text editor. Use the Toggle, Copy, and Visibility buttons to copy the correct format.
Open again your Arduino IDE. Change the keys of the sketch/code the keys from The Things Stack end device copied to the text editor from line 74 to line 76. Connect your complete assembled WisBlock Kit 2 to your PC or laptop to the USB.
Upload your sketch/code Weather_Monitoring.ino to the WisBlock RAK4631 after updating the keys by pressing the Upload button. Double check if the Arduino IDE Board and Port is using WisBlock RAK4631 to have a successful code uploading.
Check again your The Things Stack account and go to Applications > Wisblock Kit2 Weather Monitoring > Live Data. Wait for the uplink data messages that are updated every 20 seconds.
Setting Up IoT Dashboard Using Ubidots
This section will guide you on how to integrate your application using Ubidots.
Go to ubidots.com, then click SIGN UP.
Choose TAKE ME TO UBIDOTS STEM, and fill in all the requirements to sign up for an account.
Go to Devices > Devices, and click Create Device.
A window on the right side pops up, and choose the following:
- Connectivity: LoraWAN
- Hardware Type: Dev Kits
- Device: Blank Device.
Then, a window will appear, and fill in Device name and Device label. Once done, press the check button.
- Device name: Weather Monitoring
- Device label: wisblock-kit2-weather-monitoring
After adding the device, fill in the Description and SET LOCATION.
After filling in, go to Plugins, then click Create Data Plugin.
A window on the right side pops up, and choose The Things Stack. Follow the instructions given by the plugin, then click the forward button.
Under the Ubidots Token, use Default token, then click again the forward button.
Finally, press the check button to install the plugin.
After installing the plugin, click on The Things Stack, then go to Decoder.
At the Decoding Function, execute the following steps, and then click SAVE & MAKE LIVE.
- Uncomment line 37 (Remove
//
) - Comment line 41 and line 42 (Add
//
) - Comment line 48 and line 59 (Add
/*
&*/
)
Go back to the The Things Stack account and select Go to applications.
Head on to your device under Applications menu, then click wisblock-kit2-weathermonitoring.
Under your device tab, choose Integrations > Webhooks and then click the Add webhook button.
Choose Custom webhook, then fill in all the necessary fields like Webhook ID and Webhook format.
Go back again to your Ubidots account Weather Monitoring to obtain Base URL, X-Auth-Token, and Uplink message.
After filling in the important fields, click the Add webhook button.
Now, you need to create a dashboard in Ubidots. Click Data > Dashboards, then click the Add new Dashboard button.
Edit the Add new Dashboard window to your desired details, then press check button.
Click Add new Widget. A window appears on the right side, and choose Thermometer.
Edit the Thermometer widget. Change it into Temperature, then click the Add Variables button.
A window will pop up. Click wisblock-kit2-weather-monitoring, select the temp variable, then press the check button.
Finally, click the check button to save.
After adding the Temperature widget, click on the plus sign at the right side to add another widget. This time, choose Gauge, and add the Humidity widget.
After editing the name into Humidity, click Add Variables. Select wisblock-kit2-weather-monitoring, choose the hum variable, then press the check button.
Finally, click the check button to save.
Use the same method in adding the Temperature and Humidity widgets. Just click on the plus sign at the right to add another widget, then choose Gauge.
This time, add the Pressure widget under Gauge, then click Add Variables.
After editing the name into Pressure, click wisblock-kit2-weather-monitoring, choose the press variable, then press the check button.
Edit the Range into 0-1000. After doing it, click the check button to save.
Finally, the last widget to be created is the Luminosity. Click on the plus sign at the right to add another widget, choose Gauge, add the Luminosity widget, then click Add Variables.
After editing the name into Luminosity, click wisblock-kit2-weather-monitoring, choose the light variable, then click check button.
Edit the Range into 0-1000. After doing it, click the check button to save.
After adding the four widgets, you will then see the same page, as shown in Figure 131.
Then, go to Devices > Devices menu, and edit the variables.
-
For the temp variable:
-
Description: Temperature
- Unit: °C
-
- For the hum variable:
- Description: Humidity
- Unit: %RH
- For the press variable:
- Description: Pressure
- Unit: hkPa
- For the light variable:
- Description: Luminosity
- Unit: lux
After doing all these steps, you already finished the WisBlock Kit 2 Weather Monitoring Project using Ubidots.
Updated