close
Lesson 3 Connect your device to QIoT Suite Lite using MQTTS
In Lesson 2 , we complete deploy sample code to your device .In this lesson, you will learn how yo use sample code to connect to QIoT Suite Lite.
And there are three parts:
A: Generate resource info inside QIoT Suite
B: Download sample code
C: Other Protocol
Part A :Generate resource info inside QIoT Suite
- Click the "Connect a Device":

- Choose MQTTS and click "Generate a Device Certificate" :

- In "Download the files to connect", click the links to download the "Device Certificate", "CA Certificate", and "Private Key" to your PC. Do not rename these files. Click "OK".
- Click "Download JSON file".

Part B :Download sample code
- Download sample code from QNAP QIoT Suite Lite GitHub.
- URL: https://github.com/qnap-dev/qnap-qiot-sdks
- Path: python/device/mtk-linkit-7688-duo/examples
- Set the data structure like as in the following image.
- The "resource.json" file must be saved in the "res" folder, and the device Certificate, CA Certificate, and Private Key must be saved in the "ssl" folder.

- Open Terminal application (such as WinSCP) on your PC and login to your device.
- LinkIt 7688 only supports the SCP protocol. SFTP can be installed using "openssh-sftp-server".
root@mylinkit:~# opkg update
root@mylinkit:~# opkg install openssh-sftp-server
- LinkIt 7688 only supports the SCP protocol. SFTP can be installed using "openssh-sftp-server".

- Open a Terminal application (such as PuTTY) on your PC.Connect to your device by using SSH and enter the folder where the sample code is stored (for example: /home/root/bundle).

- To Install sample code dependencies, enter the following commands:
root@mylinkit:~# cd {folder where you put sample code}
root@mylinkit:/home/root/bundle# pip install -r requirements.txt
- Run the sample code
root@mylinkit:/home/root/bundle# python mqtt.py
- The device will send a message to the topic "temp" (or the topic you defined)
Part C : Using another protocol
- Click "Connect a Device".

- You can select another protocol.

- Connect to your device using SSH, and enter the following commands:
root@mylinkit:~# cd /home/{{user}}/bundle
root@mylinkit:/home/root/bundle# pip install -r requirements.txt
// mqtt(dont' need certificate,just put JSON file to "res" folder):
root@mylinkit:/home/root/bundle# python mqtt.py
// http
root@mylinkit:/home/root/bundle# python http.py
// https
root@mylinkit:/home/root/bundle# python https.py
// coap
root@mylinkit:/home/root/bundle# python coap.py
- In next Lesson ,we will integrate Power BI to visualize senser data . Lesson 4 Integrate Power BI
Please visit QNAP github for QIoT Suite Lite sample code
"QNAP-Github"
全站熱搜