硬件连接:
(供电开关打在B5V,使用TTL供电)
接二极管有两个作用
1.防止同一个电脑上两个虚拟串口直通,这样可能导致设备管理器反复枚举(不是必然事件)。
2.可以一个TTL转串口同时监听L610和F411,两个L610和F411的TX因为有背靠背的二极管隔壁不会相连。
AT监听结果:
AT
AT
OK
AT+CPIN?
AT+CPIN?
+CPIN: READY
OK
AT+MIPCALL=1
AT+MIPCALL=1
OK
+MIPCALL: 10.207.83.188
AT+MIPCALL=1
AT+MIPCALL=1
ERROR
AT+TCDEVINFOSET=1,“IGA6ZV5NNK”,“lamp_01”,“n41ziNuSI2jyY3jbYh1HvQ==”
AT+TCDEVINFOSET=1,“IGA6ZV5NNK”,“lamp_01”,“n41ziNuSI2jyY3jbYh1HvQ==”
OK
+TCDEVINFOSET: OK
AT+TCMQTTCONN=1,20000,240,1,1
AT+TCMQTTCONN=1,20000,240,1,1
OK
+TCMQTTCONN: OK
AT+TCMQTTSUB=“
t
h
i
n
g
/
d
o
w
n
/
p
r
o
p
e
r
t
y
/
I
G
A
6
Z
V
5
N
N
K
/
l
a
m
p
0
1
"
,
1
A
T
+
T
C
M
Q
T
T
S
U
B
=
"
thing/down/property/IGA6ZV5NNK/lamp_01",1 AT+TCMQTTSUB="
thing/down/property/IGA6ZV5NNK/lamp01",1AT+TCMQTTSUB="thing/down/property/IGA6ZV5NNK/lamp_01”,1
OK
+TCMQTTSUB: OK
AT+MIPCALL=1
AT+MIPCALL=1
ERROR
AT+TCDEVINFOSET=1,“IGA6ZV5NNK”,“lamp_01”,“n41ziNuSI2jyY3jbYh1HvQ==”
AT+TCDEVINFOSET=1,“IGA6ZV5NNK”,“lamp_01”,“n41ziNuSI2jyY3jbYh1HvQ==”
OK
+TCDEVINFOSET: OK
AT+TCMQTTCONN=1,20000,240,1,1
AT+TCMQTTCONN=1,20000,240,1,1
+CME ERROR: 4
AT+TCMQTTSUB=“
t
h
i
n
g
/
d
o
w
n
/
p
r
o
p
e
r
t
y
/
I
G
A
6
Z
V
5
N
N
K
/
l
a
m
p
0
1
"
,
1
A
T
+
T
C
M
Q
T
T
S
U
B
=
"
thing/down/property/IGA6ZV5NNK/lamp_01",1 AT+TCMQTTSUB="
thing/down/property/IGA6ZV5NNK/lamp01",1AT+TCMQTTSUB="thing/down/property/IGA6ZV5NNK/lamp_01”,1
OK
+TCMQTTSUB: OK
腾讯云收到的效果:
附主函数代码:
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART1_UART_Init();
MX_USART2_UART_Init();
/* USER CODE BEGIN 2 */
l610_send_cmd("AT","OK",20);
HAL_Delay(1000);
l610_send_cmd("AT+CPIN?","+CPIN: READY",20);
HAL_Delay(1000);
l610_send("AT+MIPCALL=1");//IP地址获取
HAL_Delay(1000);
//避免第一次上电时获取IP过慢 重新再发送命令取保连腾讯云成功
l610_send("AT+MIPCALL=1");//IP地址获取
HAL_Delay(1000);
printf("IP获取完成!!!\r\n");
l610_send("AT+TCDEVINFOSET=1,\"IGA6ZV5NNK\",\"lamp_01\",\"n41ziNuSI2jyY3jbYh1HvQ==\"");
HAL_Delay(1000);
l610_send("AT+TCMQTTCONN=1,20000,240,1,1");
HAL_Delay(1000);
l610_send("AT+TCMQTTSUB=\"$thing/down/property/IGA6ZV5NNK/lamp_01\",1");
HAL_Delay(1000);
//避免第一次上电时获取IP过慢 重新再发送命令取保连腾讯云成功
l610_send("AT+MIPCALL=1");//IP地址获取
HAL_Delay(1000);
printf("IP获取完成!!!\r\n");
l610_send("AT+TCDEVINFOSET=1,\"IGA6ZV5NNK\",\"lamp_01\",\"n41ziNuSI2jyY3jbYh1HvQ==\"");
HAL_Delay(1000);
l610_send("AT+TCMQTTCONN=1,20000,240,1,1");
HAL_Delay(1000);
l610_send("AT+TCMQTTSUB=\"$thing/down/property/IGA6ZV5NNK/lamp_01\",1");
HAL_Delay(1000);
printf("初始化成功!!!\r\n");
版权声明:本文为CSDN博主「灵长目动物」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/IUPAD/article/details/121734011
硬件连接:
(供电开关打在B5V,使用TTL供电)
接二极管有两个作用
1.防止同一个电脑上两个虚拟串口直通,这样可能导致设备管理器反复枚举(不是必然事件)。
2.可以一个TTL转串口同时监听L610和F411,两个L610和F411的TX因为有背靠背的二极管隔壁不会相连。
AT监听结果:
AT
AT
OK
AT+CPIN?
AT+CPIN?
+CPIN: READY
OK
AT+MIPCALL=1
AT+MIPCALL=1
OK
+MIPCALL: 10.207.83.188
AT+MIPCALL=1
AT+MIPCALL=1
ERROR
AT+TCDEVINFOSET=1,“IGA6ZV5NNK”,“lamp_01”,“n41ziNuSI2jyY3jbYh1HvQ==”
AT+TCDEVINFOSET=1,“IGA6ZV5NNK”,“lamp_01”,“n41ziNuSI2jyY3jbYh1HvQ==”
OK
+TCDEVINFOSET: OK
AT+TCMQTTCONN=1,20000,240,1,1
AT+TCMQTTCONN=1,20000,240,1,1
OK
+TCMQTTCONN: OK
AT+TCMQTTSUB=“
t
h
i
n
g
/
d
o
w
n
/
p
r
o
p
e
r
t
y
/
I
G
A
6
Z
V
5
N
N
K
/
l
a
m
p
0
1
"
,
1
A
T
+
T
C
M
Q
T
T
S
U
B
=
"
thing/down/property/IGA6ZV5NNK/lamp_01",1 AT+TCMQTTSUB="
thing/down/property/IGA6ZV5NNK/lamp01",1AT+TCMQTTSUB="thing/down/property/IGA6ZV5NNK/lamp_01”,1
OK
+TCMQTTSUB: OK
AT+MIPCALL=1
AT+MIPCALL=1
ERROR
AT+TCDEVINFOSET=1,“IGA6ZV5NNK”,“lamp_01”,“n41ziNuSI2jyY3jbYh1HvQ==”
AT+TCDEVINFOSET=1,“IGA6ZV5NNK”,“lamp_01”,“n41ziNuSI2jyY3jbYh1HvQ==”
OK
+TCDEVINFOSET: OK
AT+TCMQTTCONN=1,20000,240,1,1
AT+TCMQTTCONN=1,20000,240,1,1
+CME ERROR: 4
AT+TCMQTTSUB=“
t
h
i
n
g
/
d
o
w
n
/
p
r
o
p
e
r
t
y
/
I
G
A
6
Z
V
5
N
N
K
/
l
a
m
p
0
1
"
,
1
A
T
+
T
C
M
Q
T
T
S
U
B
=
"
thing/down/property/IGA6ZV5NNK/lamp_01",1 AT+TCMQTTSUB="
thing/down/property/IGA6ZV5NNK/lamp01",1AT+TCMQTTSUB="thing/down/property/IGA6ZV5NNK/lamp_01”,1
OK
+TCMQTTSUB: OK
腾讯云收到的效果:
附主函数代码:
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART1_UART_Init();
MX_USART2_UART_Init();
/* USER CODE BEGIN 2 */
l610_send_cmd("AT","OK",20);
HAL_Delay(1000);
l610_send_cmd("AT+CPIN?","+CPIN: READY",20);
HAL_Delay(1000);
l610_send("AT+MIPCALL=1");//IP地址获取
HAL_Delay(1000);
//避免第一次上电时获取IP过慢 重新再发送命令取保连腾讯云成功
l610_send("AT+MIPCALL=1");//IP地址获取
HAL_Delay(1000);
printf("IP获取完成!!!\r\n");
l610_send("AT+TCDEVINFOSET=1,\"IGA6ZV5NNK\",\"lamp_01\",\"n41ziNuSI2jyY3jbYh1HvQ==\"");
HAL_Delay(1000);
l610_send("AT+TCMQTTCONN=1,20000,240,1,1");
HAL_Delay(1000);
l610_send("AT+TCMQTTSUB=\"$thing/down/property/IGA6ZV5NNK/lamp_01\",1");
HAL_Delay(1000);
//避免第一次上电时获取IP过慢 重新再发送命令取保连腾讯云成功
l610_send("AT+MIPCALL=1");//IP地址获取
HAL_Delay(1000);
printf("IP获取完成!!!\r\n");
l610_send("AT+TCDEVINFOSET=1,\"IGA6ZV5NNK\",\"lamp_01\",\"n41ziNuSI2jyY3jbYh1HvQ==\"");
HAL_Delay(1000);
l610_send("AT+TCMQTTCONN=1,20000,240,1,1");
HAL_Delay(1000);
l610_send("AT+TCMQTTSUB=\"$thing/down/property/IGA6ZV5NNK/lamp_01\",1");
HAL_Delay(1000);
printf("初始化成功!!!\r\n");
版权声明:本文为CSDN博主「灵长目动物」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/IUPAD/article/details/121734011
暂无评论