Use FRED (Cloud Node-RED) with LoRaWAN

LoRa wireless modulation is a very popular wireless communication technology for IoT development. Its long range and low power consumption features make it suitable for many IoT applications. After we tested out the LoRa P2P network in our last blog post, this post will focus on setting up a network of LoRa devices following the LoRaWan protocol and sending data to the The Things Network. It is important to point out that this example uses the Raspberry Pi as a single channel gateway/packet forwarder. It is physically different from a fully functional eight channels LoRaWAN gateway. This test setup is only for test purposes and it cannot be used as a real LoRaWan gateway.

About LoRaWAN

LoRaWAN™ is a Low Power Wide Area Network (LPWAN) specification intended for wireless battery operated Things in a regional, national or global network. LoRaWAN targets key requirements of Internet of Things such as secure bi-directional communication, mobility and localization services. The LoRaWAN specification provides seamless interoperability among smart Things without the need of complex local installations and gives back the freedom to the user, developer, businesses enabling the rollout of Internet of Things.

LoRaWAN network architecture is typically laid out in a star-of-stars topology in which gateways is a transparent bridge relaying messages between end-devices and a central network server in the backend. Gateways are connected to the network server via standard IP connections while end-devices use single-hop wireless communication to one or many gateways. All end-point communication is generally bi-directional, but also supports operation such as multicast enabling software upgrade over the air or other mass distribution messages to reduce the on-air communication time.


For the end nodes, we used the Adafruit Feather M0 Lora board. We also used DHT 22 (temperature and humidity sensor) and BH1750 (light intensity) sensors to provide data. We also added a 16×2 LCD display to show the data being sent without using the serial monitor on a laptop. This is very useful when we take the end-node out of the office for distance tests. Since we use LMIC library for the LoRaWAN protocol, we also need to wire the LoRa transceiver differently than in the last post. Here is an example of the connection on the end-node.

(The number shows on the LCD display is the temperature reading, humidity reading, and light lux reading.)

For the gateway, we used the Dragino lora Lora/GPS HAT on a Raspberry Pi 2.


(photo from CNX-software)


For this network connection, we used the LMIC library to drive the transceivers on each end-node and the Dragino LoRa HAT. It is a library that follows the LoRaWAN protocol and is compatible with the Things Network configuration. We also need to register an account on the Things Network.

We used the node-red-contrib-ttn node to receive data on FRED, our cloud hosted Node-RED platform.

Diagram Flow:



on the Things Network:

In order to get data going in the Things Network, you will need to register an account.

You will need to register on the Things Network:

  • Your gateway

You will need to register a gateway ID. For every packet sent from the gateway, the gateway ID will be signed to the packet.

  • An application on the Things Network console:

The application is where your data will be sent to. You will need the network session key and application key once you have created an application.

  • Within the application, register your end-node

In each application, you will register the end-node devices. You can either choose “ABP” (Activate By Personalization”) or “OTAA” (Over The Air Authentication”).


The development on the end-node is very straightforward. This GitHub repo shows very detailed instructions for using the Feather M0 board for LoRaWAN connection.


In this particular test run, we follow this guide to setup the Dragino HAT on a Raspberry Pi. The guide provides clean sample code for setting up the Pi to send/receive messages targeting the Things Network.

The Things Network is undergoing changes and updates in their API and backend architecture – the router IP used in the official Dragino wiki is currently outdated. You will need to look up the correct IP for your destination from the Things Network documents.

Since our setup is a single channel gateway, the gateway will only be able to receive 1 in every 8 packets sent from each end-node on average. The reason for this is the LoRaWAN specification requires the end-nodes to follow a frequency hopping pattern, and our single channel gateway is only able to listen to one out of eight frequency channels and one out of six spreading factors at all time.

A good tool to troubleshoot at this point is to use the tcpdump on Raspberry Pi to monitor the packets you receive and send on a specific port.


You can receive messages on FRED with the TTN node developed by the Things Network. You can find more information from their documentation.

Our flow on FRED is very similar to the previous LoRa post. A buffer message is sent to the Things Network from the Raspberry Pi gateway, and we receive a buffer message on FRED. We need to convert the buffer message to something more useful:Screen Shot 2017-03-20 at 3.41.12 PM


If you set up the hardware correctly, you should be able to obtain the data from the TTN node in buffer form. You will need to convert the buffer to string like we did in the LoRa P2P connection blog post.

Screen Shot 2017-03-17 at 11.09.22 AM

Overall, we had set up a mocked LoRaWan network using a Raspberry Pi as a single channel gateway. We also used the Things Network platform to connect and receive data from the end-nodes. We used the TTN node on FRED to monitor, process and visualize the data packets. Having this simple test network set up, we are excited to see you use FRED for some interesting LoRaWan projects!

About Sense Tecnic

Sense Tecnic Systems Inc have been building IoT applications and services since 2010. We provide FRED, cloud hosted Node-RED as a service to the community. We also offer a commercial version to our customers, as well as professional services. Learn more.