Skip to main content
All CollectionsUser Guides
Events: Manage downlink messages with TTN and Ubidots
Events: Manage downlink messages with TTN and Ubidots

Learn how to make downlink messages to The Things Network back-end with Ubidots

David Sepúlveda avatar
Written by David Sepúlveda
Updated over a month ago

IMPORTANT NOTE
THIS GUIDE AS DEPRECATED ON JANUARY, 2022.


A downlink message comprehends the last mile in the IoT communication cycle, it enables devices, connected to the application layer through protocols requiring intermediary platforms, to be controlled or setup-modified from afar. Such an example are devices using LoRaWAN communication protocol and The Things Network, TTN, as a network server. TTN provides an API triggered by POST request to forward messages from the cloud down to devices, that is, downlink messages.

Following this guide, you will be able to send messages from Ubidots platform to a TTN-connected device using the events module and TTN downlink API

Requirements

Table of Contents

1. Setup a downlink event in Ubidots to TTN
2. Result

1. Setup a downlink event in Ubidots to TTN

The below steps indicate how to create an event in Ubidots to perform a downlink message to the TTN back-end, and hence control devices from Ubidots UI.

Step 1: Open Events module located under the Data dropdown.
Step 2: Create a new event and setup the condition to be triggered upon based on the control variable values.
Step 3: Next, in the Actions section, create a "TTN downlink" action.

Step 4: Head to your TTN console and select the application hosting the device you want to make a downlink to.

Step 5: Extract the below information from your application console panel: 

  • Region: The zone where your TTN app belongs to.

  • Application ID: found in the Application overview

  • Application Access Key: found at the bottom of the Application overview.

  • Process ID:  found on the integration tab, corresponds to the integration ID used to send data to Ubidots.
    IMPORTANT NOTE: for downlink purposes, HTTP integration is required.

An example of above data: 

Region: Europe (ttn-eu)
Application ID: ttn-downlink-test
Application Access Key: ttn-account-v2.BhwQf8fdRhU76vIN7nK-XFnA4Lv02_gcuU
Process ID: my-process-id-dlm

Step 6: Fill the left panel of the Ubidots action with the parameters obtained in Step 5

Step 7: Enter the required information in the right options panel of the event action. This information correspond to the payload sent in the POST request to TTN API:

  • Device ID: correspond to the unique identifier assign when the device is created in the TTN application.

  • Port: the port through which the device is communicating to TTN. This is found in the device's details by scrolling down.

  • Confirmed: Whether the downlink should be confirmed by the LoRaWAN device.

  • Payload Type: Use "raw payload" to send binary data, or "payload fields" if your TTN application has an encoder payload function to encode JSON to binary.
    Payload Fields: A JSON object with "fields" will be sent to TTN, which can be then encoded by your TTN encoder payload function
    Raw Payload: Base64 encoded payload.

An example of above data and how it'd look once fill in the right options panel:

ACTIVE TRIGGER VIEW

Device ID: fipy-ubidots
Port: 1
Confirmed: Disable
Payload Type: Payload fields
Payload Fields: Variable – Last Value

Step 8: Set the "Back to normal" option if required, just the same as in Step 5 . This will trigger a second downlink message once the event condition is no longer true.

An example of above data and how it'd look once fill in the "Back to normal" option:

BACK TO NORMAL VIEW

Device ID: fipy-ubidots
Port: 1
Confirmed: Disable
Payload Type: Raw payload
Payload Fields: SG9sYQ== (means "hola" – hello in Spanish).

Step 9: Follow up to the last step in the event creation, name it, defined day and hour active windows and save it.

2. Result

After setting up your downlink event to be triggered once a condition es met, you should see something similar to the below GIF in your TTN application Data tab.
We setup this event example to be triggered when a control variable is 1, sending a JSON Payload fields :

{"variable": 1}

And then, when control variable is switch off and value is 0, performs a second downlink messages sending a Raw payload base64 encoded:

SG9sYQ==


Other users also looked at:

Did this answer your question?