Alibaba Cloud IoT Platform provides device SDKs that allow devices to connect to the platform. This topic describes how to enable communication between a device and IoT Platform by using the data_model_basic_demo sample code. A street lamp is developed in this example.

Background information

  • In this topic, Link SDK for C is used on the Linux operating system. We recommend that you use 64-bit Ubuntu 16.04 to compile the SDK.
  • The following software is required for SDK development and compilation:

    make (version 4.1 or later) and gcc (version 5.4.0 or later)

    Run the following command to install the software:

    sudo apt-get install -y build-essential make gcc


  1. Obtain Link SDK for C :C SDK 4.x. .
  2. Decompress the downloaded Link SDK for C and modify the device certificate in the SDK.
    Click the data_model_basic_demo.c link to download the data_model_basic_demo.c file, replace the data_model_basic_demo.c file in the path \LinkSDK\demos, and configure the following parameters.
    char *product_key       = "a2***";
    char *device_name       = "device1";
    char *device_secret     = "8c684ef***";
    char  *mqtt_host = "a2***";
    Parameter Example Description
    • Public instance of the new version: iot-cn-***
    • Public instance of the old version: a2***
    The MQTT endpoint.
    • Endpoint of a public instance of the new version: On the Instance Details page, click View Development Configurations in the upper-right corner. In the Development Configurations panel, view the endpoint.
    • Endpoint of a public instance of the old version: The endpoint is in the format of ${YourProductKey}.iot-as-mqtt.${YourRegionId}

    For more information, see View the endpoint of an instance.

    product_key a2*** The device certificate used for authentication. This certificate is saved on premises after you add the device.

    You can also view the device certificate on the Device Details page in the IoT Platform console. For more information, see Obtain device authentication information.

    device_name device1
    device_secret 8c684ef***
  3. Log on to the Linux virtual machine and run the following command to install the required software:
    sudo apt-get install -y build-essential make gcc
  4. Upload the LinkSDK file that is modified in Step 2 to the development environment.
  5. Go to the SDK root directory /LinkSDK and run the make command to compile the sample code:
    make clean

    The generated data-model-basic-demo file is stored in the ./output directory.

  6. Run the sample code.
    The following figure shows a sample success response:Sample success response
  7. Log on to the IoT Platform console and go to the Public Instance page to view the online status and running status of your device.
    • In the left-side navigation pane, choose Devices > Devices. Then, find the device and view its online status. The value Online in the State/Enabled column indicates that the device is connected to IoT Platform. Power bank cabinet-Device online status
    • Click View in the Actions column to go to the Device Details page. Click the TSL Data tab, and then click Status to view the running status of the device.

      In this example, the following Current section displays the operating current submitted to IoT Platform by using the sample code in the data_model_basic_demo.c file.

      Street lamp-TSL data

What to do next

Subscribe to device messages from IoT Platform.