cancel
Showing results for 
Search instead for 
Did you mean: 

How to create a LoRaWAN server on local PC (1/2)

Filip SCHWANK
ST Employee


The usual free offer for a LoRaWAN server usually consists of only one network with up to 10 devices per registration. So the purpose of this tutorial is to show, that the Network server of the LoRaWAN network can be quite simple and running on a local PC.
For this tutorial I’ve selected this open-source server: https://gotthardp.github.io/lorawan-server
It acts as Network server only, so in comparison to Loriot or TTN, an Application server is needed to fully handle the frames.
The usual Application server is the Cayenne myDevices, but to show a real simple application, it is possible to communicate with the Nwk server using MQTT connection to a Node Red server.

Requirements

  • A PC or laptop, in the tutorial Windows installation is shown but many Linux distributions are supported as well as Mac OS.
  • A packet LoRa forwarder, in this case the STM32F7 Nucleo from the P-NUCLEO-LRWAN2 package is used, but any other packet forwarder should work.
  • An end node, in this case STM32WL, but any LoraWAN node is possible to use, e.g. from the P-NUCLEO-LRWAN2 package.

26.jpg
1 End Node - STM32WL
27.png 
2 Packet forwarder - STM32F7 Nucleo + RisingHF module
 

Network server installation steps


For the Nwk server only two things are needed. For the server itself to run, support of Erlang is needed. Then the server is just a zip package in case of binary format – or it is possible to compile from sources. In this tutorial I’m using 0.6.7 release of the Nwk server and Esl-Erlang OTP 23 on Windows x64.
https://github.com/gotthardp/lorawan-server/blob/master/doc/Installation.md#user-content-using-the-binary-release-on-windows
https://www.erlang-solutions.com/resources/download.html

  1. The installation of the Erlang is a simple ‚wizard‘ procedure.

28.png
 

  1. After unpacking the Nwk server it should look like this:

29.png

  1. Now it should be possible to run the server. On Windows, go to the bin folder and write ‘cmd’ into the folder address. Write ‘lorawan-server.bat’ into the console and the server should start. DO NOT CLOSE THIS WINDOW.

30.png

  1. Now the http server administration has started alongside with the Nwk server and it is possible to login to http://localhost:8080/ using username ‚admin‘ and psw ‚admin‘.

31.png
 

Nwk server configuration

Now that the server is successfully installed, it is possible to add Lora devices and networks. The configuration of the server itself can be kept as is, in default values. For LoRaWAN functionality with the node a network must be created. Resp. several straightforward steps must be taken:
 

  1. Define area and its administrator32.png

 

  1. Gateway configuration


33.png
First, to get the necessary information – GW MAC, we need to plug in the GW/packet forwarder and point it to our server. The F7 GW in this tutorial has AT command interface available via the ST-Link virtual COM port. To connect to it, simply plug in the micro usb cable to the blue extension board to power the GW and another micro usb cable to the ST-Link side. By default, the driver should be automatically installed, and the device should be able to connect. The connection parameters are 115200bps, 8bits, 1 stop bit, no parity. It is possible to use any com port terminal, in this tutorial it is Termite.

After powering the GW, or toggling the black Reset button, something like this should appear:
34.png
The GW can be anywhere in your local network, what is important, that the GW has an assigned IP address and that the LoraWAN server IP is pointing to the PC hosting the server. In this tutorial, I use direct wire connection to a laptop, so a static network must be defined in the Internet setting in Windows. Therefore, the steps 1-2 are not needed if the GW is connected to a router with DHCP IP assignment.

  1. In the system tray right click on your internet connection, Network & Internet settings, Change adapter options.

35.png

  1. 1. Adapter options, 2. Open its properties, 3. Open IPV4 settings, 4. Set IP, e.g. 192.168.1.5 for the PC, with subnet mask 255.255.255.0

36.png

  1. Open again the GW terminal, send AT+HELP for the list of commands, one of the commands is AT+IP=STATIC,ip,netmask,gateway which we can set in following way: AT+IP=STATIC,192.168.1.7, 255.255.255.0,192.168.1.5

37.png

 

  1. To point the GW to our server, use command AT+PKTFWD=address,port_up,[port_down], in this case: AT+PKTFWD=192.168.1.5,1680,1680
  2. Now reset the GW and it should be able to establish a UDP connection with the server 38.png
  3. If the connection was not successful, check the firewall settings and allow any connection the Windows pop up.

 

  1. Now it is possible to fill out the GW MAC – ID to the adding a GW form

39.png
 

  1. Adding a network

To add a network, Region depends on the country, in this case EU 863-870MHz, NetID can be 000000 for private network, Max Data Rate should be SF7 for EU. The rest can be left at default/suggested values. Just to note, not every parameter is required, but when one is missing, sometimes the popup window to inform the user does not appear. 40.png
41.png

42.png
43.png
 

  1. If we now look back at our running server, we should see a GW connection in the dashboards, with some motes from the GW.

44.png

  1. Adding devices

Last step on the network server side is to define a group for devices which will be added. To do that, again a few steps is needed:

  1. Create a group 45.png
  2. Create a profile. Join and FCnt check is modified to avoid possible errors when resetting devices too often. Application – by default it is semtech-mote layer embedded in this LoRaWAN server, later we will change it to our Application server. ADR can be left as is. 46.png
  3. Now it is possible to add the actual devices, to register a OTAA device, use Commisioned, for ABP use Activated and fill out the form. In this tutorial the registration is handled by the Application server, so we will skip this form. But if you register a device manually, you will see in the dashboard some unhandled frames coming from the node or ‚not a Semtech mote‘ event, because the default Application server does not recognize data coming from the node.
  4. (Optional) If you want to add a device manually, you need to go to Devices -> Commisioned and fill out the form. To find the data, the easiest is to open a terminal with the device and in case of End_Node application all the necessary information will be printed on the screen.

47.png
48.png
This is a joined device, but the information necessary to be filled is visible as well. Only the Node field is not necessary to fill out, as it is generated automatically by the network.

The application server

For the application server part, please continue to the second part of this tutorial here:
How to create a LoRaWAN server on local PC(2/2) - Application server
 

Comments
Harish Mekali
Associate II

cmd window running "lorawan-server.bat" closes automatically when I start the "http://localhost:8080/admin" on chrome.

Please let me know the method to avoid it.

Thank you.

LauraCx
ST Employee

Hi Harish,

@Filip SCHWANK​  can help you with your question.

Filip SCHWANK
ST Employee

Hi Harish,

make sure that you have the Erlang OTP - preferably the v23 as described in the tutorial.

When you open the chrome tab, does the login appear or it crashes immediately?

Best regards,

Filip

Harish Mekali
Associate II

Hi Filip Schwank,

Thanks for the reply.

I have reinstalled Erlang OTP V23 for windows and tried, but the same error persists.

Error on chrome:

This site can’t be reached

localhost refused to connect.

Login does not appear on the chrome tab.

Roberto48
Associate

Hi,

I installed the lorawan-server software succesfully, I'm using OTP V24.
But when I entered my gateway it is not possible to enter the Status info (not connected)
Maybe it has something to do with the Semtech-mote.
I'm using the TTIG gateway for connecting to thethings.network.

Please provide me with the needed info.  I hope it's possible to connect to the TTIG GW.

Thanks!

Rob

 

 

Version history
Last update:
‎2024-06-18 02:59 AM
Updated by:
Contributors