Connect Devices to ThingsEye

Last modified by Alec Chen on 2025/11/19 15:54

 

Table of Contents:

1. Overview

This instructions will show you how to connect a device that has been registered to the server to the Thingseye platform.

2. UDP Protocol – Direct Connection

2.1 UDP Interface
Server Address: server1.thingseye.io
Port: 11560

Data sent to the above UDP interface will not directly enter the client's database.

For detailed information on how to forward data to clients, please contact the ThingsEye team.

Note: Currently, UDP connections require port forwarding. Please contact the ThingsEye team before connecting and provide them with your device's IMEI.


2.2 Testing with Dragino NB Device

2.2.1 Configuring the NB-IoT End Node

The device here is an S31-NB, and it has been configured as follows:

Set to use the ThingsEye UDP server: AT+SERVADDR=server1.thingseye.io,11560

Use UDP uplink and JSON protocol: AT+PRO=2,5

Equipped with an NB-IoT card to access the NB-IoT network.

The S31-NB's cellular module IMEI is: 863663062789483

2.2.2 Check Uplink Data
Enable Debug Module

1758762334133-608.png


After reactivating the S31-NB, we can see it in the debug window:

1758762371290-726.png

1728378218744-800.png


2.2.4 Automatic Device Creation
The default tenant UDP server is already configured to decode Dragino-NB/-CB NB-IoT nodes. Therefore, each end node sends data to the server. The tenant will automatically create devices on the server.

1728378968101-683.png

1728379050044-764.png


3.  Connect to The Things Stack

3.1 Network Structure

The network diagram below illustrates the connection between the devices and The Things Stack, as well as how the data can be integrated with the ThingsEye IoT platform.

1732679444539-853.jpg

3.2 Creat Integration for The Things Stack.

Add Integration

1728535775119-971.png

Choose Connection Type

1728535857345-950.png

Input Uplink Data Converter Code

1728535941851-388.png

Demo JavaScript Code: https://raw.githubusercontent.com/ThingsEye-io/te-platform/refs/heads/main/Data%20Converters/The_Things_Network_MQTT_Uplink_Converter.js 

Input Downlink Converter

1728536142721-488.png

Example Javascript Code as below: https://raw.githubusercontent.com/ThingsEye-io/te-platform/refs/heads/main/Data%20Converters/The_Things_Network_MQTT_Downlink_Converter.js

Set up Connection to The Things Network application

1728536305503-380.png

Test Connection & Add iIntegration

1728536374214-962.png

After add , we can see the integration here:

1728536420275-153.png

We can use Simulate Uplink to simulate an uplink in the things stack. Then we should be able to see the message in ThingsEye

1728536524638-768.png

1728536541040-814.png


4.Connect chirpstack to Thingseye by way of MQTT

  • How to connect chirpstack to Thingseye by way of MQTT? The following tutorial will show you

4.1 Network Structure

The network diagram below illustrates the connection between the devices andchirpstack, as well as how the data can be integrated with the ThingsEye IoT platform.

1732679647697-982.jpg

4.2 Thingseye adds MQTT integration

Go to the Integrations page in the Integrations center section. Click the plus button to start adding a new integration. Select the type "MQTT" integration and click "Next";

1758762634175-353.png

4.3 Add an uplink and downlink data converter

In the function decoder field, specify the uplink script to parse and transform the data.

1758763061703-634.png

  • Uplink——JavaScript:

var data = decodeToJson(payload);

var deviceName = data.deviceInfo.deviceName;

var deviceType = data.applicationName;

var devEui = data.deviceInfo.devEui

var label = data.deviceInfo.devEui

var model = {};

var data2 = data.object;

var flg = data.fPort

for (var key in data2) {

    // 将属性名存入新对象中

    model[key] = data2[key];

}

//var obj =  {"devid":deviceName}

var result = {

    deviceName: deviceName,

    deviceType: deviceType,

    telemetry: model,

    groupName: "Case Study",

    //label:label,

    attributes:{"devEui":devEui,

        //"timevalue":"test",

        "inactivityTimeout":1260000

        // "High_humidity_alarm":"not set",

        // "High_temperature_alarm":"not set",

        // "Low_humidity_alarm":"not set",

        // "Low_temperature_alarm":"not set",

        // "Low_voltage_alarm":"not set"

        //"customerName": "Civionic Engineering & Consulting (2014) Inc."

    }

};

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;


In the function decoder field, specify the downlink script to parse and transform the data.

1758763019466-819.png

  • Dowblink——JavaScript:

// Encode downlink data from incoming Rule Engine message

// msg - JSON message payload downlink message json

// msgType - type of message, for ex. 'ATTRIBUTES_UPDATED', 'POST_TELEMETRY_REQUEST', etc.

// metadata - list of key-value pairs with additional data about the message

// integrationMetadata - list of key-value pairs with additional data defined in Integration executing this converter

// /** Encoder **/

//var data = {"value":99};

// // Process data from incoming message and metadata

// data.tempFreq = msg.temperatureUploadFrequency;

// data.humFreq = msg.humidityUploadFrequency;

// data.devSerialNumber = metadata['ss_serialNumber'];

// // Result object with encoded downlink payload

var result = {

    // downlink data content type: JSON, TEXT or BINARY (base64 format)

    contentType: "TEXT",

    // downlink data

    data: msg.shared_value ,//JSON.stringify(data),

    // Optional metadata object presented in key/value format

    metadata: {

            topic: '/test/down/'+metadata.deviceName

    }

};

return result;


4.4 Configure the connection

Generate MQTT certificate integrated on chirpstack

Chirpstack generates CA certificate, TLS certificate, and TLS key respectively

They correspond to the CA certificate file, Certificate file, and Private key file on thingseye

图片4.png

图片5.png

  • Copy the contents of the certificates and paste them into the linked file below, a total of three certificates are required

Integrated Certificate File demo Download Address:

https://github.com/ThingsEye-io/te-platform/tree/main/chirpstack

Enter the server address Host: lns1.thingseye.io on the Connection configuration

Port: 8883

Credentials type: PEM

Upload the certificate and key file

图片6.png

图片7.png


The default for Topic is:

application/chirpstack application id/device/+/event/up

图片8.png

屏幕截图 2024-11-25 095805.png


4.5 Check the connection

图片9.png

图片10.png


5. Check Data Uplink Log

User can check the devices log in Intergration.

1729562069134-315.png