Device connection guide
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.
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 |
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
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 |
|
|
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 |
|
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.
Cloud development
|
Device type |
Procedure |
|
|
|
Cloud gateway device |
|
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 |
|
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 |
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
-
Does IoT Platform only support the MQTT connection protocol?
-
Can I hide the IoT Platform connection domain name behind my own domain name?
-
How does IoT Platform establish a connection between a device and the platform?
-
If a device's IoT card is replaced, will IoT Platform prevent the device from going online?
Device authentication
-
Can I download device MQTT connection parameters in batches?
-
Does the device-side SDK support automatic reconnection for the MQTT protocol?
-
Which regions and instances support per-product authentication without pre-registration?
-
Failed to obtain DeviceSecret during MQTT dynamic registration with one secret per product
MQTT connection
CoAP connection
-
What is the URI for connecting to IoT Platform over the CoAP protocol?
-
Does the IoT_CoAP_DeviceNameAuth authentication function block and wait for a specified time?
-
What does the IOTX_DEVICE_ID field mean when a CoAP client submits for authentication?
-
What error occurs if the data sent to the cloud is not in JSON format?
-
What causes coap_malloc to return NULL when calling the IoT_CoAP_Init method?