首先下载AT固件
发布的固件 - ESP32 - — ESP-AT 用户指南 latest 文档
下载烧录工具
下载指导 - ESP32 - — ESP-AT 用户指南 latest 文档
烧录后注意usb的串口是不能发AT指令的
需要用16和17脚
用AT指令确认OK后连WIFI
AT+CWMODE=1 //设置客户端模式
AT+CWLAP //搜索WIFI
AT+CWJAP="WIFI名","密码" //连接wifi
AT+CIPSTA? //获取IP
去ThingsBoard在线版创建一个设备并获取id
https://thingsboard.cloud/
进连接测试界面复制这条测试命令
mosquitto_pub -d -q 1 -h mqtt.thingsboard.cloud -p 1883 -t v1/devices/me/telemetry -u "4Fi3AvSAP1gxFxqRdKod" -m "{temperature:25}"
解析这条命令的意思
域名-- mqtt.thingsboard.cloud
端口-- 1883
主题-- v1/devices/me/telemetry
user-- "4Fi3AvSAP1gxFxqRdKod"
内容-- "{temperature:25}"
qos-- 1
设备ID
id-- cc3170e0-1a9b-11ef-bf00-a758a0264878
ESP--AT固件指令
AT+MQTTUSERCFG=0,<scheme>,<"client_id">,<"username">,<"password">,<cert_key_ID>,<CA_ID>,<"path">
AT+MQTTCONN=<LinkID>,<"host">,<port>,<reconnect>
AT+MQTTPUB=<LinkID>,<"topic">,<"data">,<qos>,<retain>
对应最终命令
AT+MQTTUSERCFG=0,1,"cc3170e0-1a9b-11ef-bf00-a758a0264872","4Fi3AvSAP1gxFxqRdKot","",0,0,"mqtt.thingsboard.cloud"
AT+MQTTCONN=0,"mqtt.thingsboard.cloud",1883,1
AT+MQTTCONN?
AT+MQTTPUB=0,"v1/devices/me/telemetry","{temperature:25}",1,0
数据内容有变化时
AT+MQTTPUB=0,"v1/devices/me/telemetry","{batteryLevel:96}",1,0