Integrating The Things Network (TTN) with AlphaX via HTTP Integration

Learn how to seamlessly integrate TTN with AlphaX using HTTP integration, enabling automatic uplink data transfer for efficient IoT management.

Integrating The Things Network (TTN) with AlphaX allows you to seamlessly forward data from your LoRaWAN devices to the AlphaX platform. This guide provides a straightforward, step-by-step process to set up this integration using TTN's HTTP integration feature.

For general assistance with the The Things Network please use the community support to help troubleshoot.

Prerequisites:

  • TTN Account: Ensure you have an active account on The Things Network.
  • AlphaX Account: Make sure you are registered on the AlphaX platform.
  • Registered Devices: Your LoRaWAN devices should be registered and functioning within your TTN application.

Getting Started

For this help guide we will be using an Application called “Dingtek DC500 People Counter”. Yours may be named differently.

  • Log-in to your TTN Console using your username and password. Please see The Things Network community for help loging in.
  • When you have gained access to the platform, navigate to the paplication you would like to integrate with AlphaX. you will be redirected to a page that looks similar to the one below.
  • Click on the Integrations Tab on the left menu bar and it will open for you.
  • Navigate to the “Webhooks” section to start creating your integration.

Creating a Webhook

  1. When you arrive at the “Webhooks” page you will be given the option to “Add Webhook”. Click this button to get to the next screen.
  2. Click Add Webhook Button. this will navigate to a second screen
  3. Click the Custom Webhook option. You may have many options on your screen so be sure to select the right one.
  4. A form will be displayed for you to complete as shown below. Complete the form with the following information.
    – Enter an ID for your integration. This ID required
    – Select the JSON webhook format.
    – Enter the Base URL. This must be “https://conduit.alphax.cloud/post/ttnv3” for the integration to work correctly.
    – Click the + Add header entry button and add an entry for token and enter your security token from AlphaX.
  5. Go to the Enabled event types section and click Uplink message. In the selection box enter /uplink
  6. Leave the rest of the fields with the default content. i.e. Blank in most cases.

Configuring Data

The next step is to configure your data to be in the correct format. The integration will take care of the rest of the formatting automatically however, your data must be aligned to the correct channelId to be successfully imported into AlphaX.

NOTE: The unique identifier for registration into AlphaX is the Device EUI

There are two mandatory fields that are required for the integration into AlphaX to work:

  • channelId: integer Formated
  • value: Number Formatted (16 character maximum length)

NOTE: As seen above your sensor will require a different parser depending on make and model. Please refer to the manufacturer for information regarding packet format.

To create an uplink payload formatter:

  • Navigate to the payload formatter on the left hand side menu bar.
  • Click payload formatters and click on the Uplink option. On the next screen you will be given an option to select the type of uplink payload formatter you want.
  • Select Custom Javascript Format as the formatter type.
  • Enter your code into the formatter code section.

Example Parser: Fixed Length Payload for Dingtek DC500

function decodeUplink(input) { 
if (input.bytes[3]==2){
return {
data: [
{ channelId: 1, value: (input.bytes[6] | input.bytes[5] << 8)},
{ channelId: 255, value: (input.bytes[10] | input.bytes[9] << 8)/100 },
],
warnings: [],
errors: []
}
}
}

 

NOTE: Additional device formatters are provided in the Device Formatters section of our knowledge base.

Additional Considerations:

  • Payload Formatting: Ensure that the data payload from your devices is formatted in a way that AlphaX can interpret. You might need to set up a payload formatter in TTN to decode the raw payload into a structured format.
  • Data Storage: TTN's Data Storage integration temporarily stores data for about 24 hours and is not intended as a primary database. It's essential to have the HTTP integration set up to forward data to AlphaX for long-term storage and analysis.
  • Security: If AlphaX requires secure communication, ensure that the endpoint URL uses HTTPS and that any necessary authentication tokens are included in the headers.

By following these steps, your TTN application will forward uplink messages from your devices directly to AlphaX, enabling efficient data management and analysis within the AlphaX platform.