2179 views|3 replies

6841

Posts

11

Resources
The OP
 

[Evaluation of EC-01F-Kit, the EC-01F NB-IoT development board] Part 2: Manual connection and data publishing of MQTT [Copy link]

This post was last edited by lugl4313820 on 2021-12-17 22:50

Today I used the serial port assistant to upload MQTT to my server. After half a day's hard work, I finally completed the module connection, networking, MQTT connection and login, and data publishing. Now I share it with you as follows :

1. Hardware preparation :

TTL to USB , I use CP210X USB to UART . There are many modules to choose from, the communication rate is 9600 , CH340 , etc.

2. Software preparation:

1 ) Serial Port Assistant. I use the Friendly Serial Port Assistant here. It has a memory function for sent commands and is more convenient:

Another thing is to open the " NB-IoT Series Module AT Command Set " of Anxinke . If you have never used AT commands, you may need to spend some time to familiarize yourself with it. I used to use Anxinke's A6 module, but I couldn't use it well. Later, after using the serial port N times, I felt that if you want to use AT commands well, you must use the serial port well, especially waiting for the reply of the command. This delay must be mastered in a suitable program, otherwise the command is sent too quickly and the module does not respond, or the delay time is too short, and the command fails to be sent ===, N pits. However, today it seems that the response time of EC-01 is much faster than that of A6 when it was 2G, but it is still a little slower than that of Hezhou's Air302.

2) Basic knowledge of MQTT

The MQTT protocol is lightweight, simple, open and easy to implement, which makes it widely applicable. It only needs to publish and subscribe , especially for traffic-sensitive and low-power applications.

For MQTT, you just need to master the MQTT server, port number, subscribe to topics, publish messages, and receive messages. I suggest you read these articles:

[MCU Notes] Use ESP8266's WIFI-MQTT serial port transparent transmission module to implement TLINK platform testing_Feng Yu's blog-CSDN blog_esp8266 connects to tlink

( https://blog.csdn.net/qq997758497/article/details/105964878)

tlink-Developer Center-Tutorial

( https://www.tlink.io/help.htm?menu=2&page=57)

3 ) MQTT forwarding server

I have my own MQTT server, so I can get started quickly. If you don't have an MQTT server, it will be a little difficult to implement, because this NB-Iot is not like a wifi module, you can build a server in your home LAN. But many websites have MQTT access protocols, such as Alibaba Cloud, tlink , Shanghai Hezhou, etc. It seems that Anxinke also has a server for testing, but there will be many restrictions.

With the above preparations, you can start the network test

  • Officially enter the network

Because the development board is a low-power module, I directly converted the 3.3V power supply from USB to TTL . After connecting the power supply, the LED light of the module was not very bright, so I thought the module did not have a power-on column. This module seems to start up by itself when powered on.

If OK is returned after sending AT , it means the module is working properly.

The first step is to check the network registration status :

AT+CREG ? Then query the registration status, signal quality, etc.

[22:05:01.447] AT+CREG?

[22:05:01.467]

[22:05:01.468] +CREG: 0,6

[22:05:01.482]

[22:05:01.488] OK

Step 2: Create an MQTT client

AT+ECMTOPEN=0," mqtt server ID or domain name ",1883 ( usually the port is 1883, some people don't want to be attacked, you can also change the custom port) The AT command manual describes it this way.

AT+ECMTCONN=0," clientID "," user name "," login password "

If OK is returned, it means the login is successful.

Step 3: Publish data

AT+ECMTPUB=0,0,0,0," temp /","{ \"value\":10.11}"

If OK is returned, it means the data is published successfully.

So far, the manual AT command has completed the data publishing work of MQTT . It seems that only 3 commands are needed, but it took a lot of twists and turns from there to nothing. I hope it will be helpful to everyone.

AT+ECMTOPEN=0,"host_name ",port

AT+ECMTCONN=0,"clientID"," user_name "," password "

AT+ECMTPUB=0,0,0,0," temp /","{ \"value\":10.11}"

In general, this module is simple to upload and publish MQTT data. Later, I will cooperate with the microcontroller to complete the subsequent testing work.

This post is from RF/Wirelessly

Latest reply

This happened during my test, but it didn't seem to have any effect. It would automatically connect when I published it.   Details Published on 2021-12-30 09:18
 

2w

Posts

74

Resources
2
 

Great experience to share.

This post is from RF/Wirelessly
Add and join groups EEWorld service account EEWorld subscription account Automotive development circle
Personal signature

加油!在电子行业默默贡献自己的力量!:)

 
 

61

Posts

1

Resources
3
 

How to deal with frequent disconnections and reconnections here?

This post is from RF/Wirelessly

Comments

This happened during my test, but it didn't seem to have any effect. It would automatically connect when I published it.  Details Published on 2021-12-30 09:18
Personal signature

intersil Techwell应用工程师

 
 
 

6069

Posts

6

Resources
4
 
Li Baiyi posted on 2021-12-22 13:22 How to deal with frequent disconnections and reconnections here?

This happened during my test, but it didn't seem to have any effect. It would automatically connect when I published it.

This post is from RF/Wirelessly
Personal signature

在爱好的道路上不断前进,在生活的迷雾中播撒光引

 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

快速回复 返回顶部 Return list