DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • What Are Events? Process, Data, and Application Integrators
  • Is SASE the Solution for Third-Party Risk?
  • 7 Salesforce CRM Integration Methods You Must Know About
  • Microservices Testing: Key Strategies and Tools

Trending

  • DGS GraphQL and Spring Boot
  • Scalable, Resilient Data Orchestration: The Power of Intelligent Systems
  • Unmasking Entity-Based Data Masking: Best Practices 2025
  • Apache Doris vs Elasticsearch: An In-Depth Comparative Analysis
  1. DZone
  2. Data Engineering
  3. IoT
  4. Integrating The Things Network Devices with the ThingsBoard Platform

Integrating The Things Network Devices with the ThingsBoard Platform

Learn how to integrate devices on The Things Network with the ThingsBoard platform.

By 
Vitaliy Paromskiy user avatar
Vitaliy Paromskiy
·
Jun. 14, 18 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
9.7K Views

Join the DZone community and get the full member experience.

Join For Free

Introduction

Currently, more and more devices are connected to the global network using LPWAN technologies, like Sigfox, NB-IOT, and LoRa. While selected networks resolve connection tasks, there are plenty of other tasks that should also be resolved. It can be device provisioning and maintenance, data visualization and analytics, and building business workflows on top of the data submitted from devices. The ThingsBoard IoT platform can resolve all of those tasks. And, the most interesting part of the ThingsBoard that it is an open-source project.

What is The Things Network (TTN)?

The Things Network is a global, community-driven LPWAN provider that is based on a LoRaWAN stack. 

What is the ThingsBoard?

It is an open-source IoT platform for data collection, processing, visualization, and device management. Since the ThingsBoard Version 2.0, the new event bases workflow engine is available for all platform users.

How to Integrate

1. Register Application in the TTN
This application will be used for integrating TTN devices with the ThingsBoard. The application ID and access key will be used for integrating two platforms. In fact, integration is performed over the MQTT channel. ThingsBoard acts like an MQTT client where TTN is an MQTT broker.

Here is what the application configuration will look like:
Image title

Note: The 'Handler Registration' option will determine the region where an application will be registered. We will need this info when configuring integration in the ThingsBoard.


2. Create an Uplink Data Converter in the ThingsBoard
Next, use the data converter for transforming an incoming payload in the required message format. Here is an example of incoming payload:

{
  "app_id": "tb_platform",
  "dev_id": "thermostat_a",
  "hardware_serial": "*********",
  "port": 1,
  "counter": 0,
  "payload_raw": "Dw==",
  "payload_fields": {
    "temperature": 15
    },
  "metadata": {
    "time": "2018-06-07T17:31:18.670792607Z"
    }
}


There are integration specific fields in the incoming payload, like app_id   or dev_id  . Hardware _serial fields  contain device EUI from TTN platform. The actual payload from the device stored inside payload_raw  and payload_fields  properties.

For example, our device submits a 1-byte payload that contains current temperature value. And, we want to save this value as a telemetry of the device. Here is what the converter will look like:

var data = decodeToJson(payload);
var deviceName = data.dev_id;
var deviceType = data.app_id;

var result = {
  deviceName: deviceName,
  deviceType: deviceType,
  telemetry: {
  temperature: data.payload_fields.temperature
  }
};

function decodeToString(payload) {
return String.fromCharCode.apply(String, payload);
}

function decodeToJson(payload) {
  var str = decodeToString(payload);
  var data = JSON.parse(str);
  return data;
}

return result;


3. Create ThingsBoard Integration
The final step is to create 'integration' on the ThingsBoard side. Open Integrations section and add new Integration with type TheThingsNetwork. Select the uplink data converter from the previous step and fill in the required fields:
Image title


4. Verify the Results

After the device sends an uplink message from TheThingsNetwork, it will be automatically registered in the ThingsBoard and the submitted data will be saved as a telemetry of the device. Here is what it will look like:

Image title


For sending Downlink messages to the device, when some events occur, the administrator can configure the required workflow in the ThingsBoard Rule engine. The integration Downlink node is used for sending such messages. More details you can be found in this ThingsBoard Rule engine tutorial.

Image title


What's Next?

Now, integration is finished. From this point, when a device sends a payload to the  tb_application , it will be transferred directly to the ThingsBoard platform. If a device was not seen before, a new device will be created.

It is also possible to send Downlink messages and process any events using the event-based workflow engine inside the ThingsBoard. 


You can find more details about those in the following links:

1. https://thingsboard.io/docs/user-guide/integrations/ttn/
2. https://thingsboard.io/docs/user-guide/rule-engine-2-0/re-getting-started/
3. https://www.thethingsnetwork.org/docs/

Network Workflow engine Open source Data visualization Integration application Payload (computing) Global network MQTT Event

Opinions expressed by DZone contributors are their own.

Related

  • What Are Events? Process, Data, and Application Integrators
  • Is SASE the Solution for Third-Party Risk?
  • 7 Salesforce CRM Integration Methods You Must Know About
  • Microservices Testing: Key Strategies and Tools

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!