Integration of Lora and Sofia2

The communication between Lora and Sofia2 is done through the Multitech kit, formed by a test node that simulates the transmissions between a Lora device and a Gateway. This Gateway is needed to communicate this type of devices within the network and to send the captured data.

Kit
Used Multiconnect Conduit Kit.

Before the integration in Sofia2, the configuration between the Gateway and the test node is needed. In this brief tutorial, the steps to develop both configurations are collected, as well as all the information needed in Sofia2 to receive and store the data sent by Lora.

Configuration of Lora technology

  • Gateway configuration

    In order to use the gateway without any connection problem, an initial configuration is needed. First access to the Gateway must be done by means of serial communication, though Putty or another similar tool. Credentials needed to access by console are admin/admin. We can get its IP address with the command ifconfig. Once the IP address is known, we use the explorer to access to the Multitech webpage, where we introduce the same credentials again.

    Acceso web al gateway
    Access to the gateway webpage

    Once we start the session, and only by the first time that we do it, we will find an assistant that requires us to change the password, to select the timezone and to configure the IP address. When the last window appears, we must to configure the static IP, to select the corresponding Gateway, and to add the DNS servers.

    Once we finish the IP configuration, we will configurate Lora. To do that, we have to access to Setup -> Lora. Then, we will see a screen where we will see some configurable fields. Anyway, we only need to modify Name and Passphrases.

    Web
    Lora configuration
  • Node-Red configuration

    Once we activate the Node-Red application, we can access though the “App” menu of the webpage. By default, a program that receives Lora test data and shows them is designed, but we have to modify it in order to send the information to Sofia2. Image shows the final flow diagram, with the option “Sofia2 API WEB encoder” added. This option is uncharged of giving the desired format, adding a header to the send message and an output HTTP.

    Node-Red
    Node-Red diagram
  •  Configuration of test node

    To configurate the parameters of the test node is really simple. We only have to connect the mDot to the PC, by means of a USB, and to connect it to the test node with the kit programming cable. Then, we select the “Configuration” option in the mDot Box and we access to the device by using the Putty serial communication at 115200 baud.

    Tester
    Lora tester

    We only need to configure two parameters, using the following AT commands:

    AT+NI=1,<Name>

    AT+NK=1,<Passphrase>

    AT&W is used to save changes and  AT+Exit to exit the configuration mode.

    <Name> y <Passphrase> fields have to be the same values as used previously in the gateway.

    Configuración del tester
    Test node configuration

    In order to check if the configuration of both devices has been correct, we can do a test with the Node-Red.

Sofia2

Once that the devices have been configured, we have to develop the next steps in Sofia2. We need two new ontologies, an API rest and a rule script to deal with data. This section briefly explains with each of them.

  • Defining new ontologies

    First of all, we have to create an ontology that will receive the data sent by the test node. In this ontology we will insert raw data, without any previously filtering.

    ontologia
    Ontology example with raw data

    As we can see in the previous image, data usually have hexadecimal codifications, undesirable formats or information that needs to be treated before work with it. To do that, we have to create a rule script and a new ontology, where we will insert filtered data with the format required by the data base to correctly store it.

  • API REST

    Once the ontologies are defined, we will create an API REST of type POST, to insert data in the ontology of raw data. To do that, we have to go to the API MANAGER -> APIs, where we will find the option “New API”. There, we write the name of our API, and select the option “Publish Ontology as REST API” and the ontology desired. It is convenient to disable the maximum number of calls per minute, in order to assure that we do not lose information. At the end, we select the “POST” operation and create the API.

    API
    API

    The URL of the “Base Endpoint” field is the one that we have to insert in the Node-Red.

  • Rule script

    Once verified that the data sent directly from the device is correctly inserted in the desired ontology, we must create a script to filter them, extract all possible information and provide them with the corresponding format. To do this, we simply enter Rules-> Wizard New Rules and select the option “Generate rule using a template “. With this type of rules, each time the device sends new data to the ontology, the script will be executed and data will be processed and inserted into the final ontology.

  • Presentation on results

    We can use Sofia2’s visualization tools to show the data we’re storing quickly and easily. To do that, we have to go to the Visualization ->My Gadgets -> New Gadget, where we can select the optimal tool depending on our data. On the basic of measured data from Lora tester, the following representation could be interesting: to drawn the coordinates on a map or Signal to Noise Rate (SNR) along the time.

Mapa
Coordinates shows on a map
SNR
SNR representation.
Integration of Lora and Sofia2

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s