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:
- Integrate your TTN LoRaWAN device with TagoIO
- Setup the Analysis used to perform the downlink
- Create a dashboard with a Push Button widget
- 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 (https://tago.elevio.help/en/articles/102) 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: http://admin.tago.io/template/5f513aabd4555600277f858c
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
I hope you enjoyed this tutorial, if you had any problems, let me know.