Mobile AT | Five minutes to play with Wing China Telecom IoT open platform with zero basics
Wing preparation
This manual is applicable to the M0R1 series (RDA5981) and M0M1 (WI6900) WIFI modules and subsequent AT command WIFI modules. You can use this manual to conduct connection tests on the Wing China Telecom Internet of Things open platform.
New product
1) Open the Wing China Telecom IoT open platform, and after activating the service, click to enter the product center on the right.
2) Click the "Create Product" button in the upper right corner:
3) Create a product according to the requirements and illustrations. Pay special attention here to the authentication method: string certification to be collected, and the security type: one type, one secret. Here is an example of creating a lamp:
4) At this time we will see the product we just created in the product center: MQTT device test
Add device
1) After creating the product, you can enter the product MQTT device test to add the device.
2) Click "Add Device" in the upper right corner, and we set a device "Light 1":
3) After completion, we can view the created device
4) We need to record several parameters:
5) Click on the details in "Product Overview":
record the feature string and device access IP port in the product details.
WIFI module and device connection
The following will explain in detail the content and precautions related to device connection from three aspects: AT command method, network configuration, connection to Wing China Telecom IoT open platform, and subscription information. This article only introduces the MQTT method to connect and receive data. Please study other methods separately as needed.
AT command mode
First, download the AT firmware according to the official tutorial of Mailing (the factory default is the AT all-in-one function firmware).
M0R1 is connected to serial port 1 of the device, and M0M1 is connected to serial port 0. The development board can directly connect the USB to TTL port to the computer. Other self-designed boards can be connected using USB to TTL and other tools (pay attention to level conversion).
The AT commands sent by the MCU to the WIFI module must end with \n, or it can also end with \r\n.
Serial port default parameters: baud rate 115200, 8 bits, 1 stop bit, no parity bit.
Configure network
1) Set the account and password to connect to the router
set up | return |
---|---|
AT+WJAP=APtest,12345678 | +ok (APtest is the AP of the router, 12345678 is the password of the router) |
Inquire | return |
---|---|
AT+WJAP | +ok=APtest,12345678 (APtest is the AP of the router, 12345678 is the password of the router) |
2) Set the WIFI module working mode
set up | return |
---|---|
AT+WMODE=STA | +ok |
Inquire | return |
---|---|
AT+WMODE | +ok=STA (modes include: APSTA, STA, AP) |
3) Check whether the router is connected
Inquire | return |
---|---|
AT+WSLK | +ok=APtest(FE12546F6D23) |
Turn on MQTT status display
set up | return |
---|---|
AT+STATUS=on | +ok |
AT command connects to Wing China Telecom Internet of Things Open Platform
Previously we recorded some parameters for platform connection.
Platform URL: mqtt.ctwing.com, port: 1883
Characteristic string: M9g_d-i2oqeTbpjcPHEWPEPVvjdwB_kWg8CM8UcMBSQ, this parameter is used for the password of the MQTT connection.
Device ID: 1007003400000000001, this parameter is used for the client id of the MQTT connection.
Platform login user name, used for MQTT connection user.
1) Set CLIENT ID:
set up | return |
---|---|
AT+MCID=1007003400000000001 | +ok |
Inquire | return |
---|---|
AT+MCID | +ok=1007003400000000001 |
2) Set the user name and password. The platform login name here is assumed to be: my_test
set up | return |
---|---|
AT+MUSER=my_test,M9g_d-i2oqeTbpjcPHEWPEPVvjdwB_kWg8CM8UcMBSQ | +ok |
Inquire | return |
---|---|
AT+MOUSE | +ok=my_test,M9g_d-i2oqeTbpjcPHEWPEPVvjdwB_kWg8CM8UcMBSQ |
3) Connect the device to Wing China Telecom IoT open platform:
set up | return |
---|---|
AT+MSOCK=1883,mqtt.ctwing.cn | +ok |
At this time, the WIFI module serial port comes out: +MQTT: OK, indicating that the platform connection is successful!
4) The connection part is over here. Refresh the page and you can see that our device has been activated and online.
Subscribe to news
1) From the Topic list, we can know that the device needs to subscribe to a device_control topic. I use this topic for demonstration here:
set up | return |
---|---|
AT+MSUB=QOS1,device_control | +ok |
2) Select "Device Management" in the platform and click the "Instruction Delivery" button:
3) At this time, the input interface will pop up. Note here that the data in json format must be entered. After clicking OK, the instruction will be issued:
4) At this time We can receive data from the serial port tool, which is exactly the same length and content as the data sent by the page.
The module actively reports the message: +MQD,45,device_control:{"red":128,"power":"on","green": 18, "blue": 66}
5) Find the "Command Issuance Log" on the Wing China Telecom Internet of Things Open Platform. We can see the relationship between the sending time and the time when the serial port receives data.
6) Click "Operation" to see the specific content of the sent data:
At this point, the interaction between the Wing WIFI module and the Wing China Telecom IoT open platform is completed.
illustrate
If you encounter problems using the module, you can join the QQ group with the group number 519630819 to communicate.
For related products, please pay attention to: shop.mqlinks.com