BLOG developers portal FAQs

How to integrate LoRa with thethings.iO IoT platform

IoT

As you know, thethings.iO is the most simple enterprise IoT platform. An IoT platform consists of helping and improving life of developers that are connecting products to the Internet. And as good makers, we love integrating new systems and platforms to thethings.iO that enable our clients of connecting to the Internet more devices.

In today’s post we will show you what is LoRa and its basics. We’ll also show how can it be integrated within thethings.iO platform.

LPWAN protocols

Nowadays, there is a growing interest to connect devices to the Internet, and there is an emphasis on low power wireless commutations (LPWAN).

LPWAN is designed to allow long range communications at a low rate transmission among low power connected things. LPWAN stands for Low Power Wide Area Network standard.

Devices, such as ESP8266 are capable to connect to WiFi networks. We all know that its reach is limited to few meters around the access point. IoT devices require to bridge much bigger distances since we want to use them everywhere. IoT devices usually work on batteries and we don’t have lots of power for transmission.

The dilemma is… how to reach many kilometres without spending too much power? To create radio connections for a certain distance we can either increase transmission power of the system or decrease the bandwidth of the channel and that’s the key of LPWAN protocols. LPWAN is not comparable with WiFi or 2G networks, and not all a replacement for these technologies since size of data payload is not a strong point of LPWAN. On the other hand, we have all the numerous benefits that we commented before.

As you probably know there are different LPWAN protocols such as SigFox, NB-IoT or LTE-M. As you know thethings.iO is the most simple IoT platform for Sigfox, is getting compatible with NB-IoT (I don’t want to spoiler now). Nevertheless today we want to connect thethings.iO with LoRa.

LoRa

LoRa is a Low Power Wide-Area Network (LPWAN) solution coming out France and it is intended for systems that require the ability to send and receive low amounts of data over a range of many kilometres without high power costs. It is not an open protocol as it is driven by a chip company called Semtech.

The LoRa wireless system makes use of the unlicensed frequencies that are available worldwide. The most widely used frequencies / bands are 868 MHz (Europe), 915 MHz (North America) and 433 MHz (Asia). LoRa is capable of providing data rates from between 0.3kbps to 50kbps which varies based on required range and interference. The LoRaWAN protocol provides both signing and encryption for parts of LoRaWAN packets.

LoRa topology. Source: https://www.mwrinfosecurity.com/

LoRa solutions are made up of nodes and gateways that communicate with a network server. Nodes represent connected things and they are typically low powered and communicate wirelessly with one or many gateways. Gateways are fewer in number, and transfer data from the nodes back to the network server using standard IP connections. A LoRa solution therefore follows a “star of star” topology, where multiple nodes talk to one or more gateways. Network server represents the edge of the systems that would store and parse the data sent from the nodes.

About The Things Network

The Things Network is a community-based, global initiative to provide free LPWAN coverage over LoRa. LoRaWAN coverage is entirely crowdsourced. Members also contribute by providing support or through software development.

The Things Network Backend route messages from gateways to the right application through the Internet, and back. In our case, the application would be thethings.iO platform. The question is, how can we integrate The Things Network data with our platform? How can receive the data  sent through The Things Network in thethings.iO

Integrating The Things Network within thethings.iO

In order to integrate both platforms we encourage you to read this article https://developers.thethings.io/docs/http-integrations#section-a-integration-example-with-the-things-network in our Developer Center at the thethings.iO, but here you can find a summary of the steps.

  1. Get and customize your callback URL with the productid and the hash. You can find both parameter in the Product Details of the Things Manager. The base path of the URL should be like this https://subscription.thethings.io/http/{productId}/{hash}?idname=dev_id*.
  2. Insert this url at the HTTP Integration section of The Things Network Platform.
  3. Finally, go back to thethings.iO Cloud Code section a create function with the name http_parser. Here you can find an example:
function main(params, callback){
  var result = [
      {
        "key": "temperature",
        "value": params.payload.payload_fields.temperature
      },
      {
        "key": "$settings.name",
        "value": params.payload.hardware_serial
      },
      {
        "key": "$geo",
        "value": [params.payload.metadata.longitude,params.payload.metadata.latitude]
      },
  ];

   callback(null, result);
}

Once the URL is configured and the Cloud Code function is coded, everything is ready to start receiving data and monitoring from thethings.iO IoT Platform.

We hope all this information will be helpful for you. If you want to know more about us, you can create an account by clicking here, sign up to receive our monthly newsletter or follow us on Twitter! Stay tuned and be the first in knowing the latest news of the IoT world and thethings.iO