Device connection guide

更新时间:
复制 MD 格式

Centrally manage devices, collect and analyze data, perform remote control, and secure device communications by connecting your devices to Alibaba Cloud IoT Platform. Select a connection protocol and complete the required cloud-side and device-side development.

Prerequisites

Activate IoT Platform.

Note

After activation, try IoT Platform for free. Alibaba Cloud IoT Platform products for free trial. Billing overview.

Access Instructions

Connecting a device to IoT Platform involves two phases:

Operation

Description

Cloud-side product development

In the IoT Platform console, create a product, add Thing Specification Language (TSL) model features, add custom topics, create a device, and configure business features such as device tags, device shadows, and over-the-air (OTA) updates. You must also define a device verification method, develop product features, and register the device.

Device-side development

Obtain a device certificate and use a software development kit (SDK) to connect the device to IoT Platform. You can use a Link SDK, a self-developed SDK that uses an open protocol, an AT module, or an IoT as Bridge SDK to connect the device to IoT Platform.

The supported connection protocols, SDKs, and procedures vary by device type. The following table lists the device types that IoT Platform supports and their corresponding protocols. For details about SDKs and the complete connection flow, see the Connection flow section of this topic.

Device type

Supported connection protocols

Directly connected device

MQTT, Constrained Application Protocol (CoAP), HTTPS

Gateway device (directly connected) and non-directly connected sub-device

MQTT

LoRa device

MQTT

China Mobile and China Unicom NB-IoT device

MQTT, CoAP

Cloud gateway device

MQTT, JT/T 808, GB/T 32960, SL 651, China Telecom NB-IoT

Device that cannot be directly connected using a protocol that IoT Platform supports

Supported proprietary protocols for cloud-to-cloud integration

Note

Differences between gateway devices and cloud gateway devices:

  • Gateway device: A directly connected device that uses the MQTT protocol and can have sub-devices attached. A gateway device is authenticated using its device secret before it can connect to IoT Platform.

  • Cloud gateway device: A device that connects to a cloud gateway using the MQTT, JT/T 808, GB/T 32960, or China Telecom NB-IoT protocol.

    • A cloud gateway device that uses the MQTT, JT/T 808, GB/T 32960, or SL 651 protocol is authenticated using custom certificate information.

      • You can use an MQTT cloud gateway to migrate existing devices to Alibaba Cloud IoT Platform without modifications.

      • A device that connects using a JT/T 808 protocol cloud gateway is suitable for communication between vehicle-mounted terminals of a satellite positioning system for road transport vehicles and Alibaba Cloud IoT Platform.

      • You can use a GB/T 32960 protocol cloud gateway to connect electric vehicle devices to IoT Platform. This enables remote services and system administration for electric vehicles.

      • You can use an SL 651 protocol cloud gateway to connect telemetry station devices to IoT Platform for hydrological monitoring data collection and transmission.

    • A China Telecom NB-IoT cloud gateway device is an NB-IoT device that is developed and directly connected to the China Telecom Application Enablement Platform (AEP).

Connection protocol details

image

MQTT protocol

Authentication

  • Directly connected devices and gateway sub-devices: These devices are authenticated using a device certificate that consists of a ProductKey, DeviceName, and DeviceSecret.

  • MQTT cloud gateway devices: These devices are authenticated using the UserName field as specified in the standard MQTT protocol. This method supports custom certificates, custom device authentication methods, custom communication topics, Online Certificate Status Protocol (OCSP) for device and server certificates, and bidirectional secure authentication between devices and the server.

Device identity

Device

Description

Directly connected device

  • Create a device in the IoT Platform console or by calling a cloud API to obtain the device certificate. For more information, see Create a device and RegisterDevice.

  • Create a device using the dynamic registration with one secret per product method when the device goes online to obtain the device certificate. For more information, see Dynamic registration with one secret per product.

Gateway sub-device

A gateway device can act as a proxy for a sub-device to connect to IoT Platform. After the gateway device establishes a connection with IoT Platform, the sub-device can reuse the same connection to communicate with IoT Platform. For more information, see Gateways and sub-devices.

Cloud gateway device

  • Platform-side authentication: You must import UserName information in batches to create devices in the IoT Platform console in advance. When a device establishes a connection, IoT Platform verifies the device's identity.

  • Third-party authentication: IoT Platform calls a custom Function Compute (FC) function or HTTPS service for authentication. After successful authentication, the device identity is automatically created.

Instructions

For more information about the MQTT protocol specification and instructions, see Use the MQTT protocol.

HTTPS protocol

HTTPS is supported. We recommend TLS 1.3 to encrypt connections to Alibaba Cloud IoT Platform.

Authentication

Authentication is performed using a device certificate that consists of a ProductKey, DeviceName, and DeviceSecret.

Device identity

You can create a device in the IoT Platform console or by calling a cloud API to obtain the device certificate. For more information, see Create a device and RegisterDevice.

Instructions

For more information about the HTTPS protocol specification and instructions, see Use the HTTPS protocol.

CoAP protocol

UDP is supported. You can use DTLS and symmetric encryption modes to connect to Alibaba Cloud IoT Platform.

Authentication

Devices are authenticated using a device certificate that contains a ProductKey, DeviceName, and DeviceSecret.

Device identity

You can create a device in the IoT Platform console or by calling a cloud API to obtain the device certificate. For more information, see Create a device and RegisterDevice.

Instructions

For more information about the Constrained Application Protocol (CoAP) specification and instructions, see Use the CoAP protocol.

JT/T 808 protocol

The JT/T 808 protocol for cloud gateways is used in the automotive industry. It supports custom certificates, custom device authentication methods, custom communication topics, OCSP for device and server certificates, and bidirectional secure authentication between devices and the server.

Authentication

  • Platform-side authentication: You must import Manufacturer ID, Terminal Model, and Terminal ID information in batches to create devices in the IoT Platform console beforehand. When a device establishes a connection, IoT Platform verifies the device's identity.

  • Third-party authentication: IoT Platform calls a custom FC function for authentication. After successful authentication, the device identity is automatically created.

Instructions

For more information about connecting a device using a JT/T 808 protocol cloud gateway, see Overview of JT/T 808 protocol cloud gateways.

GB/T 32960 protocol

The GB/T 32960 protocol for cloud gateways is used in the automotive industry. It supports custom certificates, custom device authentication methods, custom communication topics, OCSP for device and server certificates, and bidirectional secure authentication between devices and the server.

Authentication

  • Platform-side authentication: You must import vehicle identification number (VIN) information in batches to create devices in the IoT Platform console beforehand. When a device establishes a connection, IoT Platform verifies the device's identity.

  • Third-party authentication: IoT Platform calls a custom FC function for authentication. After successful authentication, the device identity is automatically created.

Instructions

For more information about connecting a device using a GB/T 32960 protocol cloud gateway, see Overview of GB/T 32960 protocol cloud gateways.

SL 651 protocol

SL 651 is a communication protocol for hydrological monitoring data that was developed by the Hydrological Bureau of the Ministry of Water Resources of China. It specifies technical parameters such as the format, content, and transmission method for hydrological monitoring data collection and transmission. It supports connecting telemetry station devices to IoT Platform over TCP (not recommended due to low security) and TLS.

Authentication

  • Platform-side authentication: You must import the telemetry station address (telemetryAddress) and password (password) into IoT Platform. IoT Platform authenticates the device based on this information.

  • Third-party authentication: IoT Platform calls a custom FC function for authentication. After successful authentication, the device identity is automatically created.

Instructions

For more information about connecting a device using an SL 651 protocol cloud gateway, see Overview of SL 651 protocol cloud gateways.

Other protocols

Protocols such as GB/T 26875.3-2011 and Modbus are not natively supported. If a device cannot connect directly to Alibaba Cloud IoT Platform, you can use the IoT as Bridge SDK to build a bridging service that creates a bidirectional data tunnel between the device or platform and IoT Platform.

For instructions, see Use the IoT as Bridge SDK.

Connection flow

After you activate IoT Platform, you can connect a device. The following figure shows the complete connection flow, covering both cloud-side product development and device-side development.

image

Cloud development

Device type

Procedure

  • Directly connected device

  • Gateway device

  • Non-directly connected sub-device

  • LoRa device

  • China Mobile and China Unicom NB-IoT device

  • Device that uses a proprietary protocol

  1. Purchase an Enterprise Edition instance: The public instance for trial use provides limited resources and supports only basic device connection and communication features.

    For commercial use, we recommend that you purchase an Enterprise Edition instance. For more information about instance types and features, see Differences between Enterprise Edition instance types.

  2. Create a product: Set the Node Type and Authentication Method for the product. The node type defines the type of devices that belong to the product. The authentication method specifies how to authenticate a device that attempts to connect to IoT Platform.

    For more information about authentication methods, see Device security authentication.

  3. (Optional) Configure product features: Develop product communication features as needed. For more information about the communication principles, see What is a topic?.

    • Define TSL model features: If the device uses TSL model topics to communicate with IoT Platform, define TSL model features for the product to which the device belongs.

    • Define device communication topics: If the device uses custom topics to communicate with IoT Platform, define custom topic classes for the product to which the device belongs.

      For more information about how to add a custom topic class and use it for communication, see Use custom topics for communication.

    • Parse messages: IoT Platform defines the Alink JSON format as the standard data format for device messages. If a device sends raw data in pass-through mode to IoT Platform, configure a message parsing script to convert the data from the device's custom format to the JSON format.

  4. Register a device: Add the device to the created product in IoT Platform.

    For more information, see Create a single device, Create multiple devices at a time, Create a LoRa device, and Add a gateway and a sub-device.

    Note

    You do not need to register devices in the IoT Platform console in the following cases:

    • You can use pre-registration-free authentication with one device secret per product type.

    • The device uses ID²-based authentication and the ID² whitelist is disabled.

  5. (Optional) Configure business features: If your device uses features such as device tags, device jobs, device shadows, Remote Configuration, and OTA updates, configure the features in the IoT Platform console first. Then, develop the corresponding feature logic on the device.

    Note

    A device that uses a proprietary protocol and connects to IoT Platform using an IoT as Bridge SDK supports only OTA updates.

Cloud gateway device

  1. Purchase an Exclusive instance: Only Enterprise Edition instances of the Exclusive type support the cloud gateway feature. For more information about how to purchase an instance, see Purchase an Enterprise Edition instance.

  2. Confirm the cloud gateway protocol that the device uses:

    • China Telecom NB-IoT: A China Telecom NB-IoT device must be directly connected to the China Telecom AEP.

    • MQTT: Use features such as custom certificates, custom device authentication methods, and custom communication topics to migrate existing devices to Alibaba Cloud IoT Platform without modifications.

    • JT/T 808: We recommend that you use TLS for connection. This method supports server-side one-way authentication, OCSP for device and server certificates, and bidirectional secure authentication between devices and the server. This protocol is suitable for communication between vehicle-mounted terminals of a satellite positioning system for road transport vehicles and Alibaba Cloud IoT Platform.

    • GB/T 32960: We recommend that you use TLS for connection. This method supports server-side one-way authentication, OCSP for device and server certificates, and bidirectional secure authentication between devices and the server. This protocol is suitable for communication between electric vehicle devices and Alibaba Cloud IoT Platform.

    • SL 651: We recommend that you use TLS for connection. This method supports server-side one-way authentication, OCSP for device and server certificates, and bidirectional secure authentication between devices and the server. This protocol is suitable for communication between telemetry station devices and Alibaba Cloud IoT Platform for hydrological monitoring data collection and transmission.

  3. Follow the cloud-side development flow:

Note

You can also call cloud APIs to manage IoT Platform, including products, devices, topics, server-side subscriptions, data forwarding, and message communication.

For more information, see the API list. To learn how to use cloud SDKs and view usage examples, see Cloud SDKs and OpenAPI examples.

Device-side development

Device type

Connection method

Description

  • Directly connected device

  • Gateway device

  • Non-directly connected sub-device

  • LoRa device

  • China Mobile and China Unicom NB-IoT device

Connect using a Link SDK

IoT Platform provides SDKs for various types of devices in the following languages: C, Android, Python, Java, iOS, and Node.js.

If the provided device SDKs do not meet your requirements, develop your own SDK. For example, you can use an open source ApsaraMQ for MQTT client to connect to IoT Platform.

IoT Platform provides Paho-MQTT examples in multiple languages, including Android, Java, C (embedded), C (non-embedded), C#, Python, Rust, and Go.

You can develop various features of IoT Platform based on the Alink protocol.

Connect using a module

You can use an AT module that supports MQTT and HTTPS commands, or a general-purpose TCP AT module.

IoT Platform provides the following SDK examples: Integrate an SDK on a module that supports MQTT and Integrate an SDK on a TCP-based wide area network (WAN) module.

Device that uses a proprietary protocol

Cloud-to-cloud SDK integration

This SDK supports data forwarding from other IoT platforms to Alibaba Cloud IoT Platform.

Cloud gateway device

Connect using an MQTT protocol cloud gateway

You can use custom certificate information for device identity authentication. This lets you migrate existing devices to Alibaba Cloud IoT Platform without modifications.

IoT Platform provides the following SDK examples: C connection example (Alibaba Cloud FC authentication) and Java connection example (mutual authentication).

Connect using a JT/T 808 protocol cloud gateway

You can use custom certificate information for device identity authentication. This method is suitable for connecting devices with vehicle-mounted terminals of a satellite positioning system for road transport vehicles to IoT Platform.

IoT Platform provides a C SDK example: Connection example (platform-side authentication).

Connect using a GB/T 32960 protocol cloud gateway

You can use custom certificate information for device identity authentication. This is suitable for connecting electric vehicle devices to IoT Platform.

IoT Platform provides an SDK example that uses a GitHub open source project: Connection example (platform-side authentication).

Connect using an SL 651 protocol cloud gateway

You can use custom certificate information for device identity authentication. This is suitable for connecting telemetry station devices to IoT Platform.

What to do next

After connecting your device to IoT Platform, you can manage device data using features such as message forwarding, DataService Studio, and monitoring and O&M.

  • Message forwarding: Use server-side subscription and data forwarding to route device messages. This enables device-to-server communication and data storage.

  • DataService Studio: Use data backup, data parsing, storage management, metric management, SQL analytics, report analysis, and data intelligence to extract value from your IoT data.

  • : Use real-time monitoring, Simple Log Service, and online debugging to monitor and manage device and communication metrics.

For more information, see Features.

FAQ

Device connection

Device authentication

MQTT connection

CoAP connection

HTTP connection

Device porting

Generic Protocol Access

Device status

Other related questions