Sending downlink to a TTN device from a Button widget

Many users are unaware that it is possible to downlink a device from a Push Button widget on a dashboard. Today, I will show you how to downlink from a Push Button widget to a TTN device. To get started, let’s define the steps required to accomplish this task:

  1. Integrate your TTN LoRaWAN device with TagoIO
  2. Setup the Analysis used to perform the downlink
  3. Create a dashboard with a Push Button widget
  4. Setup the button to trigger the Analysis to perform a downlink

By following these steps, at the end of the tutorial you will have a button that can be used to send downlinks to your TTN device, as shown in the GIF below:


Step 1: Integrate your TTN LoRaWAN device with TagoIO

Let’s start this tutorial by setting up a TTN device. If you already have a TTN device fully configured to receive downlinks, skip to the next step. If not, read this article ( to learn how to integrate your device with the TagoIO platform.

Step 2: Setup the Analysis used to perform the downlink

In order to setup the Analysis, install the analysis available from the following link:

Analysis Template:

After that, you will need to set up the environment variables that will be used by the script. Go to the ’ Environment Variables’ tab of your device:

These are the environment variables that you need to set up:

  • account_token: Any account token from your account with full permissions. Go to your account configurations, tokens section and generate a new one.
  • device_id : Device ID of the device that you want to send the payload to. You can get this by going to your device and entering the More section.
  • payload: The payload you want to send to your device.
  • default_PORT: The port you want to send to your device.

Once that is complete, the Analysis is already installed and we can proceed to the next step, which will be dashboard creation with the Push Button widget.

Step 3: Create a dashboard with a Push Button widget

This part is very simple. First, simply create a dashboard with the name you want. With that done, create a new widget and choose the Push Button widget. Once you have that selected, we can start configuring this widget.

Step 4: Setup the button to trigger the Analysis to perform a downlink

In addition to configuring the button to enable downlink, we will also take this last step of the tutorial to configure other aspects of the button, such as its appearance, to make it look like the button you saw at the beginning of this tutorial. After you’ve done that, go to the “Variable Alias” tab and disable the “Show variable names” option.

Finally, go to the “Visualization” tab and select the Analysis that will be used to perform the downlink. With that done, your button is already fully functional, but if you want to leave your button like the example at the beginning of the post, copy the text available in the image and set your button to “Mono-stable”. The colors that I used for the button were #1A6FD5 and #1EC862.

I hope you enjoyed this tutorial, if you had any problems, let me know.


I have the button set up and integrated correctly. The log is showing this:

[2020-07-13 17:40:43] sending downlink
[2020-07-13 17:40:43] {"id":"5f0ce872056fc7002784200b","key":"downlink","value":"comm_method","sent":false}
[2020-07-13 17:40:43] Starting
[2020-07-13 17:40:43] Starting analysis 5f03c830f615ff002b08107d

However I see no downlink data showing up on my TTN Data console. Any tips on debugging this?

Solved my own problem:
My duty cycle was too high on the uplink. The radio had no chance to downlink.

There is a bug in your example:

The downlink payload being sent is the NAME of the variable, not the CONTENTS of the variable.

For example If the variable is named “sleep_mode”, and the the two values for this state are “0” and “1”
the actual payload showing up on TTN is “sleep_mode” in hex, not 0 or 1 depending on the button state.

Hi @graemerae,

This script is a generic example, you are free to edit and send the downlink payload according to what you need.