Getting Started
Create a template, set up the integration and import your first device
Last updated
Create a template, set up the integration and import your first device
Last updated
The easiest way to prototype a device on Blynk and correctly configure the integration is to use a device that is already connected to The Things Network. Once the device is connected and successfully goes online, create a new template on Blynk for this device. Once you have created a new template, navigate to the Developer Zone -> Integrations -> The Things Network. Click the "+ Add" button and select the template you previously created.
In the application settings, fill in The Things Network hostname, username, and password. To obtain the credentials, navigate to the application page you wish to connect on The Things Network. Click on the Integrations button in the left sidebar and select MQTT. Copy the Public TLS address under the MQTT server host section and paste it into Blynk (if you are going to use non-TLS MQTT address, change the switch to "Insecure"). Then, copy the username from the page and paste it into Blynk. After that, click on the "Generate new API key" button, copy the password, and paste it into Blynk.
Click the "Connect" button at the bottom of the application card on Blynk. You will see the integration status change to "Connected".
At this point, the metadata for TheThingsNetwork Device will be created in the template if it wasn't created before. Blynk uses this metadata to identify each device in The Things Network application.
Once this is done, Blynk will automatically create the device connected to The Things Network as soon as it sends any data. This device will then be available on the Devices page.
Once your first device is connected to Blynk, it's time to transfer some data! Start by configuring the Payload formatter on The Things Network.
If you are using any provided TheThingsNetwork Payload Formatter, such as a Payload Formatter imported from the TheThingsNetwork Device Repository, additional steps might be required to convert the data format into the format required by Blynk.
For uplinks, Blynk requires the data to be in key-value pair format, where the key is either the datastream name or pin (such as v1
or a10
) and the value is the datastream value. The value type must match the datastream value type! Here is an example of the decoded uplink:
In this example, Blynk will set the datastream with the name "temperature" to the value 24.1 and the datastream with the name "humidity" to the value 54. The datastreams configuration for this example may look like this:
Each time Blynk receives an update from the device, it will trigger the Online lifecycle event. Therefore, it is recommended to configure a meaningful wait time to prevent your device from being stuck in the offline state.
Additionally, refer to the System DataStreams section, which provides details on how to retrieve RSSI, SNR, and Firmware Version information.
For each datastream update via the web dashboard, mobile application, automation, etc., Blynk will send a separate downlink to the device. Here is an example of the downlink that Blynk will send to the device, indicating that the datastream with the name "speed" (pin v2
) has been updated to the value 3
:
The ts
field represents the timestamp in Unix milliseconds format when the value was actually updated.
Each application has its own status, representing its current state:
Not Connected: This initial status indicates that the application has not been saved yet. Therefore, Blynk has not yet connected to the application, and the integration will not work. This status also applies when Blynk initially fails to connect to The Things Network with the specified parameters.
Connected: This status represents the normal state of the integration. Everything should operate normally in this status.
Broken: This status indicates a problem related to the application. Possible issues include Blynk failing to establish a connection with The Things Network server (e.g., due to a server restart), invalid credentials, or an internal error on The Things Network. In this status, Blynk will periodically try to reconnect to The Things Network server to fix the integration. Once the integration operates normally, Blynk will automatically change the status to Connected.