Sending Data From Node to The Things Stack


lora web home lorawan


To receive uplinks and send downlinks to your end device, you first need to add your device in The Things Stack Community Edition. Devices are added within applications. Applications are useful for grouping devices by purpose or location, for example.

Registering your device can be done in two ways, via The Things Stack Console or via the CLI. Before adding your end device, make sure you know of which type your device is – ABP (Activation By Personalization) or OTAA (Over-The-Air-Activation). Depending on the type, some steps differ during the registration procedure. Learn why using OTAA devices is highly recommended.

For this tutorial, I register the device via The Things Stack Console and this Shield-LoRa-RFM is an OTAA device.

Step 1: Hardware Setup

Attach the Shield-LoRa-RFM to Arduino UNO board. I am using the CT-Uno from Cytron Technologies.

ALWAYS remember to connect an antenna to the Shield-LoRa-RFM before powering up the Arduino board.

photo 2021 12 07 09 29 43

Make sure a LoRa gateway is active in your area and the LoRa node can send messages to that gateway. You can build your own gateway or use any available gateway from this map. Kindly refer to this tutorial if you want to build your own gateway.



Step 2: Arduino IDE Setup

Install the latest open source Arduino IDE here.

Install the MCCI LoRaWAN LMIC library.

  • In the Arduino IDE, select menu Sketch | Include Library | Manage Libraries
  • In the search box enter: MCCI
  • Click the MCCI LoRaWAN LMIC library by Terry Moore.
  • Select the latest version and press the Install button.
  • For this tutorial I installed version 4.1.0


Configure the MCCI LoRaWAN LMIC Library according to your situation.

Edit file lmic_project_config.h. This file can be found at:



I made the following changes to MY lmic_project_config.h file.

Make changes according to YOUR situation by uncomment your related region.



Step 3: The Things Stack Setup

Create an account on The Things Stack Community Edition (TTS CE).

Login The Things Stack Community Edition console.

Make sure you select a cluster (Europe, North America, Australia) near your location.


Add an application. For example:

Application ID: new-application (must be unique)

Application name: new-application (can be anything)



Then, register end device (choose manually) :

  • Frequency plan: Choose based on your region
  • LoRaWAN version: MAC V1.0.2
  • Regional Parameters version: PHY V1.0.2 REV B
  • Activation mode: Over the air activation (OTAA)
  • Additional LoRaWAN class capabilities: None (class A only)

Note: Why use MAC V1.0.2?

Because the MCCI LoRaWAN LMIC Library has only been tested with LoRaWAN 1.0.2/1.0.3 networks.


The HopeRF RFM95 LoRa transceiver module does not have a built-in DevEUI or AppEUI. In such a case you should let the TTSCE console generate the required DevEUI or AppEUI. Herebelow is an example of generated AppEUI, DevEUI and AppKey in the TTSCE console.


The AppEUI, DevEUI and AppKey are used in the Arduino sketch. In this Arduino sketch, the DevEUI or AppEUI must be converted to an array of 16 bytes in LSB order.  The AppKey must be converted to an array of 32 bytes in MSB order. I have found an online tool which converts these values to a bytes array in its correct order (LSB/MSB). Kindly use this online tool to prevent any negligence.



Step 4: Upload The Code in Arduino

In the Arduino IDE, select menu File | Examples | MCCI LoRaWAN LMIC library and select the ttn-otaa sketch. Re-save the ttn-otaa sketch and call it ttsce-otaa-helloworld or anything that you want.

From the online tool, copy DevEUI, AppEUI and AppKey that you had converted and paste to the ttsce-otaa-helloworld sketch.



Modify the ttsce-otaa-helloworld sketch. For this part, you can double check by checking on the shield board itself to find the correct pin mapping. This is the pin mapping for Cytron Shield-LoRa-RFM board.



In this sketch, the message “Hello World” will be transmitted every 60 seconds.

See variables: mydata[] and TX_INTERVAL. You can change to any other messages or increase/decrease the transmission interval if you want to. 



Connect the Arduino board to your computer using the USB cable.

In the Arduino IDE, select menu Tools > Board and select: Arduino Uno. Then, select menu Tools > Port: your port.


Compile ttsce-otaa-helloworld sketch. You should not see any errors (but there are warnings).

Upload the ttsce-otaa-helloworld sketch to the Arduino board. You should not see any errors.



Step 5: Display Data on The Things Stack

In The Things Stack Community Edition console, the “Hello, world” message (in hex) is received every 60 seconds.

If you want to convert the payload into a readable text:

  • Select your application in the “Application Overview” screen.
  • Select “Payload formatters”.
  • Select “Uplink”.
  • Select “Formatter type: Javascript”.


Copy and paste the decode uplink payload formatter in the textbox.

On the bottom of the page press the “Save changes” button.


Finally, if both your node and gateway functioning well, you should see the number of sent uplinks and received downlinks updated each minute with the message “Hello World” displayed in the live data.










Leave a Comment

Your email address will not be published.

Share this Tutorial

Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest
Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest

Latest Tutorial

Interface RFid RC522 Reader using Maker Pi Pico and CircuitPython
Maker UNO DHT11 Alphanumeric Display
Internet Clock using Maker Pi Pico and CircuitPython
Snap & Fit ABS Case Stressberry Test
Maze Pro Passive Aluminum Case Stressberry Test
Tutorials of Cytron Technologies Scroll to Top